Course A-2

[신고 사업장 정보] 수정

목표

  • GPM에 기존 등록되어 있는 데이터 컴포넌트를 확인하여 SSMS(SQL Server Management Studio)를 통해 [A-1]에서 정의한 테이블과 저장 프로시저를 수정하고 프로그램에 반영. 파일 첨부 기능을 구현한 다음 GPM에서 배포 과정을 실습합니다.

  • 학습 인정 시간: 2 시간 30 분

주의 사항

  • 새로운 데이터 컴포넌트를 등록하지 않고, 이미 등록된 항목을 사용합니다.

  • [GPM→테이블 관리]에서 새로운 필드를 추가하는게 아닌, SSMS 개체 탐색기에서 테이블의 [디자인] 메뉴를 통해 수정합니다.

수정된 프로그램 화면

1. 테이블 수정

1.1) 필드 추가

  • orgTaxSite_xxx 테이블에 "attdatnum, insert_userid, insert_time, insert_pc, update_userid, update_time, update_pc" 7개의 필드를 추가합니다.

  • 추가하는 필드 중 attdatnum 필드만 Null을 허용하지 않으며, 기본값은 ('') 로 설정합니다.

  • [GPM→모델링→데이터 컴포넌트] 메뉴에서 필드를 검색하여 데이터 형식을 확인하고, SSMS 도구를 이용해 수정합니다.

1.2) 업무용어 매핑 [GPM→모델링→테이블 관리]

  • 위에서 SSMS 도구를 통해 실제 테이블 스키마를 수정했고, GPM에서 새로 추가된 필드들에 대한 업무용어(데이터 컴포넌트)를 매핑합니다.

  • "테이블" 탭에서 테이블을 선택하고, "업무용어" 탭으로 이동하여 새로 등록한 필드를 검색 후 드래그 드랍으로 용어를 세팅한 다음 저장 버튼을 클릭합니다.

2. SP 수정

  • 생성했던 저장 프로시저를 필터합니다.

2.1) 조회용 프로시저 수정 [P_DEV001_xxx_Q]

  • 조회 결과 필드를 추가합니다.

2.2) 저장용 프로시저 수정 [P_DEV001_xxx_S]

  • 새로 추가된 필드에 값을 받아올 파라미터 추가

  • 삽입 시 : attdatnum, insert_userid, insert_time, insert_pc 필드 처리

  • 수정 시 : attdatnum, update_userid, update_time, update_pc 필드 처리

  • 삭제 시 첨부 번호(attdatnum)로 등록된 첨부 파일을 제거하기 위해 첨부 번호를 반환하는 쿼리 작성

3. 화면 개발

3.1) 화면 디자인 수정

  • '메모' 항목 아래 LabelEx, ButtonEditEx, TextEditEx 컨트롤을 각각 추가하고 아래의 괄호 안에 명시된 속성에 대한 값을 설정합니다.

    • LabelEx (Name: lblFiles)

    • ButtonEdit (Name: txtFiles / BingindField: "files")

    • TextEditEx (Name: txtAttdatnum / BingindField: "attdatnum" / Visible: false)

3.2) 용어 정보 수정 [GPM Tools→용어 정보]

  • 용어 사전 영역의 '용어' 조건'에 "첨부파일"로 검색하여 사진과 같이 용어를 드래그 앤 드랍하여 설정하고 "용어 적용/저장" 버튼을 클릭합니다.

4. 기능 구현

4.1) 변경된 저장 프로시저 정보 반영

  • 파라미터 정보가 변경된 저장용 프로시저(P_DEV001_xxx_S)에 대한 코드 업데이트

  • [GPM Tools→폼생성]에서 "Class" 항목만 체크한 상태로 "코드 적용" 버튼을 클릭합니다.

  • 새로 추가된 파라미터(@p_attdatnum, @p_id, @p_pc)에 대한 정상 반영되었는지 확인합니다.

private sealed class P_DEV001_xxx_S : ProcedureInfo
{
	public P_DEV001_xxx_S() : base("P_DEV001_xxx_S") { }

	protected override void AddParamInfo()
	{
		_paramList.Add(new ParamInfo("@p_work_type", "varchar", 10, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_tax_site_code_xxx", "varchar", 4, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_tax_site_name_xxx", "nvarchar", 200, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_biz_regno_xxx", "varchar", 20, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_biz_type_xxx", "varchar", 20, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_biz_items_xxx", "nvarchar", 400, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_chief_name_xxx", "nvarchar", 200, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_chief_socialno_xxx", "varchar", 20, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_zip_code_xxx", "varchar", 20, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_address_xxx", "varchar", 10, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_tel_xxx", "nvarchar", 400, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_fax_xxx", "varchar", 30, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_memo_xxx", "nvarchar", 1200, "Input", typeof(System.String)));
		_paramList.Add(new ParamInfo("@p_use_yn_xxx", "varchar", 1, "Input", typeof(System.String)));
	}

	public void AddParamData(System.String p_work_type, System.String p_tax_site_code_xxx, System.String p_tax_site_name_xxx, System.String p_biz_regno_xxx, 
							System.String p_biz_type_xxx, System.String p_biz_items_xxx, System.String p_chief_name_xxx, System.String p_chief_socialno_xxx, 
							System.String p_zip_code_xxx, System.String p_address_xxx, System.String p_tel_xxx, System.String p_fax_xxx, 
							System.String p_memo_xxx, System.String p_use_yn_xxx)
	{
		AddParamData(new object[] {
			p_work_type,
			p_tax_site_code_xxx,
			p_tax_site_name_xxx,
			p_biz_regno_xxx,
			p_biz_type_xxx,
			p_biz_items_xxx,
			p_chief_name_xxx,
			p_chief_socialno_xxx,
			p_zip_code_xxx,
			p_address_xxx,
			p_tel_xxx,
			p_fax_xxx,
			p_memo_xxx,
			p_use_yn_xxx
		});
	}
}

4.2) 저장용 프로시저 호출 메서드 수정 [Func_P_DEV001_xxx_S]

  • 신고 사업장 데이터의 저장이 성공적으로 처리되면, 작업 타입(workType)에 따라 첨부 파일에 대한 처리를 합니다.

private bool Func_P_DEV001_xxx_S(string workType)
{
    if (!ValidateControls(grpMaster))
    {
        return false;
    }

    string siteCode = txtTax_site_code_xxx1.Text;
    string siteName = txtTax_site_name_xxx1.Text;
    string bizRegno = txtBiz_regno_xxx1.Text;

    string bizType = cboBiz_type_xxx.EditValue?.ToString() ?? string.Empty;
    string bizItems = txtBiz_items_xxx.Text;
    string chiefName = txtChief_name_xxx.Text;
    string chiefSocialno = txtChief_socialno_xxx.Text;

    string zipCode = txtZip_code_xxx.Text;
    string address = txtAddress_xxx.Text;
    string tel = txtTel_xxx.Text;
    string fax = txtFax_xxx.Text;
    string memo = memoMemo_xxx.Text;
    string useYN = chkUse_yn_xxx.EditValue?.ToString() ?? string.Empty;

    string attdatnum = txtAttdatnum.Text;
    string pcInfo = $"{GetClientPCName()}/{GetIPAddress()}";

    try
    {
	P_DEV001_xxx_S procInfo = new P_DEV001_xxx_S();

	procInfo.AddParamData(
            workType,
	    siteCode,
	    siteName,
	    bizRegno,
	    bizType,
	    bizItems,
	    chiefName,
	    chiefSocialno,
	    zipCode,
	    address,
	    tel,
	    fax,
	    memo,
	    useYN,
            attdatnum,
            SessionInfo.UserId,
            pcInfo);

        ResultSet result = ExecuteProcedure(procInfo);

        bool isSuccess = result?.IsSuccess ?? false;

        if (isSuccess)
        {
            if (workType.Equals("D"))
            {
                // 삭제시 반환받은 첨부번호로 등록된 파일 제거
                AttachmentHelper.DeleteAttachments(result?.ReturnString);
            }
            else
            {
                _FindRowValue = result?.ReturnString;
            }
            AttachmentHelper.Commit();
        }

	return isSuccess;
    }
    catch (Exception ex)
    {
        ShowErrorMessageBox(ex);
	return false;
    }
}

4.3) 파일 첨부

파일 첨부에 대한 자세한 내용은 [파일 첨부 기능 문서]를 확인바랍니다.

  • 파일명(txtFiles)은 자동으로 세팅되며, 사용자로부터 값을 입력받는 컨트롤이 아니기 때문에 읽기 전용 처리를 해주고, 첨부번호(txtAttdatnum)는 시스템 내부적으로 처리하기 위한 목적이므로 보이지 않도록 설정한다.

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);

    EnabledRetrieveButton = true;
    EnabledNewButton = true;
    EnabledDeleteButton = true;

    // 파일명 컨트롤의 버튼은 제외한 읽기 전용 처리
    ReadOnlyControl(txtFiles, true, false);

    ResetParameters();
}
  • 파일을 첨부한 상태에서 저장하지 않은 경우, 변경된 첨부 파일 로그의 초기화하기 위해 AttachmentHelper.AcceptChanges 메서드를 호출하도록 작성합니다.

  • ButtonEditEx 타입의 txtFiles개체에 ButtonClick 이벤트 핸들러를 등록합니다.

public DEV001_xxx()
{
    InitializeComponent();

    // 검색 조건 초기화 ToolTip
    IBaseButton paramResetButton = grpTop.CustomHeaderButtons.FindFirst(x => x.Properties.Tag?.Equals("reset") ?? false);
    if (paramResetButton != null)
    {
        paramResetButton.Properties.ToolTip = GetFormMessage("PROJECTBASE_026", "검색 조건을 초기화 합니다.");
    }

    grpTop.CustomButtonClick += GroupControlEx_CustomButtonClick;
    gvwList.FocusedRowChanged += GridViewEx_FocusedRowChanged;

    // 파일 첨부 팝업창 열기
    txtFiles.ButtonClick += OnButtonClick;
}

private void OnButtonClick(object sender, EventArgs e)
{
    if (sender.Equals(txtFiles))
    {
        AttachmentHelper.OpenAttachmentsPopup(txtAttdatnum, txtFiles);
    }
}

5. 배포

5.1) 메뉴 등록 [GPM→개발→메뉴 편집]

  • 신규 버튼을 클릭하여 메뉴 정보를 입력하고 저장 버튼을 클릭합니다.

5.2) 폼 어셈블리 배포 [GPM→운영→어셈블리 배포]

  • "프로젝트 폴더→bin→Debug"폴더에서 작업했던 폼 어셈블리 파일을 선택하여 드래그 드랍 후 배포 버튼을 클릭합니다.

5.3) 메뉴 배포 [GPM→운영→메뉴 배포]

  • [전체 메뉴] 영역에서 위에서 등록했던 메뉴를 선택하여 [배포된 메뉴] 영역으로 드래그 드랍하여 배포합니다.

  • GSTBrowser에서 상단 우측의 "메뉴 새로고침"을 실행하고 좌측 프로그램 메뉴에서 확인합니다.

6. 체크 리스트

  • 새로운 데이터를 생성하고, [요약 정보] 영역에서 해당 데이터를 선택하여 Alt+F2 키를 눌러 '등록 정보'가 정상 표현되는지 확인합니다.

  • 위에서 생성했던 데이터에 임의 항목을 수정하고 저장한 다음 GridView의 행을 선택하고 Alt+F2 키를 눌러 '수정 정보'가 정상 표현되는지 확인합니다.

  • 파일 첨부에 새로운 파일을 등록하여 저장되는지 확인합니다.

  • 기존 등록되어 있는 첨부 파일에 추가로 파일을 등록하고 정상 저장되는지 확인합니다.

  • [기본 정보] 영역에 첨부된 파일명이 정상 표현되는지 확인합니다.

  • GSTBrowser에서 배포된 메뉴가 제대로 실행되는지 확인합니다.

Last updated

Was this helpful?