#region Copyright © 2015 CLIPSOFT Co.,Ltd. All Rights Reserved.
//
// All rights are reserved. Reproduction or transmission in whole or in part, 
// in any form or by any means, electronic, mechanical or otherwise, is 
// prohibited without the prior written consent of the copyright owner.
//
// Filename:ConsentSelectTabPageAll.cs
//
#endregion
using System;
using System.Drawing;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Configuration;
using CLIP.eForm.Consent.UI.ConsentSvcRef;
using ClipSoft.eForm.Base.Dialog;

namespace CLIP.eForm.Consent.UI {
  /// <summary>
  /// 동의서 전체목록 탭 클래스
  /// </summary>
  /// <remarks>
  /// <p>[설계자]</p>
  /// <p>  클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  /// <p>[원본 작성자]</p>
  /// <p>  클립소프트 기술부 4팀 이창훈 (chlee@clipsoft.co.kr)</p>
  /// <p>[수정 작성자]</p>
  /// <p>  클립소프트 기술부 이인희</p>
  /// <p>----------------------------------------------------------------------------------------</p>
  /// <p>[HISTORY]</p>
  /// <p> 2016-07-01 : 최초작성</p>
  /// <p>----------------------------------------------------------------------------------------</p>
  /// </remarks>  
  public partial class ConsentSelectTabPageAll : UserControl {
    private ConsentSvcRef.ConsentSvcSoapClient consentWebService = null;

    private IConsentMain consentMain = null;
    private ConsentCommandCtrl commandControl = null;

    private string searchStartDate = string.Empty;

    public ConsentSelectTabPageAll() {
      InitializeComponent();
    }

    private void ConsentSelectTabPageAll_Load(object sender, EventArgs e) {
      Boolean isInWpfDesignerMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
      Boolean isInFormsDesignerMode = (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv");
      if (isInWpfDesignerMode || isInFormsDesignerMode) {
        // is in any designer mode 
        return;
      }

      if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
        return;
      }

      consentMain = ConsentMainControl.GetConsentMainInterface(this);
      commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
      consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);

      this.dateTimePickerEndDate.Value = DateTime.Now;
      // dbs227, 발행리스트 시작일자를 한달전으로 설정
      //this.dateTimePickerStartDate.Value = DateTime.Now.AddMonths(-1);
      this.dateTimePickerStartDate.Value = DateTime.Now.AddDays(-7);

      InitDataGrid();
      BindDataGridRows();
    }

    private void InitDataGrid() {
      this.dataGridViewConsentSelectResult.DataSource = null;
      this.dataGridViewConsentSelectResult.Columns.Clear();

      this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick -= dataGridViewConsentSelectResult_ColumnHeaderMouseClick;
      this.dataGridViewConsentSelectResult.CellMouseClick -= dataGridViewConsentSelectResult_CellClick;
      // 이벤트 추가
      this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewConsentSelectResult_ColumnHeaderMouseClick);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "등록번호", "pid", true, 60, DataGridViewContentAlignment.MiddleCenter);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCRTAG", "ocrTag", true, 80);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "성명", "patientName", true, 60, DataGridViewContentAlignment.MiddleCenter);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료/\n입원일", "inDd", true, 80, DataGridViewContentAlignment.MiddleCenter);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서명", "formName", true, 180);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태", "consentState", true, 60, DataGridViewContentAlignment.MiddleCenter);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자", "modifyUserName", true, 70, DataGridViewContentAlignment.MiddleCenter);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자", "createUserName", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성일시", "createDatetime", true, 120, DataGridViewContentAlignment.MiddleCenter);

      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "consentMstRid", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "createUserId", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "ordType", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "ordDeptCd", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "cretNo", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "opRsrvNo", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "consentStateEng", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "formCd", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "formGuid", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "formRid", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "printOnly", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "printCnt", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "ocrTagPrntYn", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "formPrntNm", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "certUseYn", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "opDiagNm", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "opNm", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "userDrFlag", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "linkFormCd", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "jinjeongCd", false);
      CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "", "modifyUserId", false);

      // 사용자별
      //if(rdoUser.Checked) {

      //  // dbs227, 일괄저장 기능
      //  // 이벤트 해재
      //  this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick -= dataGridViewConsentSelectResult_ColumnHeaderMouseClick;
      //  this.dataGridViewConsentSelectResult.CellMouseClick -= dataGridViewConsentSelectResult_CellClick;
      //  // 이벤트 추가
      //  this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewConsentSelectResult_ColumnHeaderMouseClick);
      //  //this.dataGridViewConsentSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewConsentSelectResult_RowPostPaint);
      //  // 체크박스 컬럼을 추가
      //  CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewConsentSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter);

      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "등록번호", "PatientCode", true, 60, DataGridViewContentAlignment.MiddleCenter);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "성명", "PatientName", true, 60, DataGridViewContentAlignment.MiddleCenter);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료형태", "VisitTypeName", true, 40, DataGridViewContentAlignment.MiddleCenter);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료/\n입원일", "ClnDate", true, 80, DataGridViewContentAlignment.MiddleCenter);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서명", "ConsentName", true, 180);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태", "ConsentStateDisp", true, 60, DataGridViewContentAlignment.MiddleCenter);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자", "CreateUserName", true, 70, DataGridViewContentAlignment.MiddleCenter);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성일시", "CreateDateTime", true, 120, DataGridViewContentAlignment.MiddleCenter);
      //  dataGridViewConsentSelectResult.Columns["colCheck"].Visible = false;
      //}
      //// 환자별
      //else {
      //  // debug
      //  // dbs227, 일괄저장 기능
      //  // 이벤트 해재
      //  this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick -= dataGridViewConsentSelectResult_ColumnHeaderMouseClick;
      //  this.dataGridViewConsentSelectResult.CellMouseClick -= dataGridViewConsentSelectResult_CellClick;

      //  // 이벤트 추가
      //  this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewConsentSelectResult_ColumnHeaderMouseClick);
      //  dataGridViewConsentSelectResult.CellMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewConsentSelectResult_CellClick);
      //  // 체크박스 컬럼을 추가
      //  CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewConsentSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter);
      //  // 추후 삭제

      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서명", "ConsentName", true, 180);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태", "ConsentStateDisp", true, 60, DataGridViewContentAlignment.MiddleCenter);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자", "CreateUserName", true, 70, DataGridViewContentAlignment.MiddleCenter);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성일시", "CreateDateTime", true, 120, DataGridViewContentAlignment.MiddleCenter);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "등록번호", "PatientCode", false);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "성명", "PatientName", false);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료형태", "VisitTypeName", false);
      //  CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료/\n입원일", "ClnDate", false);
      //}

      //dataGridViewConsentSelectResult.Columns["colCheck"].Visible = false;

      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "기관코드", "HosType", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성번호", "Cretno", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료형태코드", "VisitType", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료과코드", "ClnDeptCd", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료과", "ClnDeptNm", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료의", "Doctor", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "병동", "Ward", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "병실", "RoomCd", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방번호", "OrderNo", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방코드", "OrderCd", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방", "OrderNm", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수술진단명", "OpDiagName", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수술명", "OpName", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수술예약번호", "OpRsrvNo", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서고유ID", "FormGuid", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서ID", "FormRid", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서코드", "FormCd", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서생성ID", "ConsentMstRid", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태코드", "ConsentState", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCR태그", "OcrNumber", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자ID", "CreateUserId", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "코사인의사ID", "CosignDcId", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "코사인의사", "CosignDcName", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "출력매수", "PrntCnt", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCR생성여부", "OcrTagYN", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "출력제목", "FormPrintName", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자변경여부", "UserDrFlag", false);
      //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "출력전용", "PrntOnly", false);
    }

    private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellMouseEventArgs e) {
      if (e.RowIndex < 0 || e.ColumnIndex < 0) {
        return;
      }
      if (e.ColumnIndex == 0) {
        DataGridViewRow curRow = dataGridViewConsentSelectResult.Rows[e.RowIndex];
        var value = curRow.Cells["colCheck"].Value;
        Boolean checkValue = false;

        if (value == null || !(Boolean) value) {
          checkValue = false;
        } else {
          checkValue = true;
        }
        curRow.Cells[e.ColumnIndex].Value = !checkValue;
      }
    }

    /// <summary>
    /// dbs227, 일괄저장 추가
    /// 체크박스 이벤트 처리
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void dataGridViewConsentSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
      if (e.ColumnIndex == 0 && e.RowIndex == -1) {
        bool chkStatus = false;

        if (dataGridViewConsentSelectResult.Columns[0].HeaderText.Equals("□")) {
          dataGridViewConsentSelectResult.Columns[0].HeaderText = "☑";
          chkStatus = true;
        } else {
          dataGridViewConsentSelectResult.Columns[0].HeaderText = "□";
        }

        foreach (DataGridViewRow r in dataGridViewConsentSelectResult.Rows) {
          r.Cells["colCheck"].Value = chkStatus;
        }

        dataGridViewConsentSelectResult.RefreshEdit();
      }
    }

    #region 검색 조건에 따른 환자의 동의서 조회        
    /// <summary>
    /// 동의서 목록 조회
    /// </summary>
    public void BindDataGridRows() {
      try {
        if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
        if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
        if (this.consentWebService == null) this.consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);

        string patientCode = string.Empty;
        if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.PatientCode)) {
          patientCode = commandControl.CurrentTargetPatient.PatientCode;
        }

        string userId = string.Empty;
        if (rdoUser.Checked) {
          userId = consentMain.ConsentExecuteInfo["loginUserNo"];
        }

        if (!patientCode.Equals(string.Empty) || !userId.Equals(string.Empty)) {

          // 프린터 모드가 아닐 경우 
          if (!consentMain.ConsentExecuteInfo["printYN"].Equals("Y")) {

            if (this.dateTimePickerStartDate.Value > this.dateTimePickerEndDate.Value) {
              this.dateTimePickerStartDate.Value = DateTime.Today - TimeSpan.FromDays(30);
              //                            this.dateTimePickerStartDate.Value = DateTime.Today - TimeSpan.FromDays(1);
              this.dateTimePickerEndDate.Value = DateTime.Today;
            }

            // 이전 진료일로 검색일자 설정
            if (string.IsNullOrEmpty(searchStartDate)) {
              if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.clnDate)) {
                //searchStartDate = string.Format("{0}-{1}-{2}", commandControl.CurrentTargetPatient.clnDate.Substring(0, 4), commandControl.CurrentTargetPatient.clnDate.Substring(4, 2), commandControl.CurrentTargetPatient.clnDate.Substring(6, 2));
              } else {
                //searchStartDate = consentMain.PluginExecuteInfo["ConsentSearchStartDate"];
              }
            }

            //this.dateTimePickerStartDate.Value = Convert.ToDateTime(searchStartDate);
            // dbs227, 발행리스트 시작일자를 한달전으로 설정
            //this.dateTimePickerStartDate.Value = DateTime.Now.AddMonths(-1);

            string sDate = this.dateTimePickerStartDate.Value.ToShortDateString().Replace("-", "");
            string eDate = this.dateTimePickerEndDate.Value.ToShortDateString().Replace("-", "");
            string consentState = GetCheckConsentState();

            ConsentFormListVO[] resultData = null;

            // 환자별 검색
            if (rdoUser.Checked == false) {
              resultData = consentWebService.GetConsentList(patientCode
                                                                  , sDate
                                                                  , eDate
                                                                  , consentState
                                                                  , consentMain.ConsentExecuteInfo["dutinstcd"]
                                                                  , userId);
            }
            // 사용자 별 검색
            else {
              var searchString = searchName.Text?.Trim();

              // 검색할 사용자 이름이 없다면 메시지박스를 보여준다
              if (searchString == null || searchString.Equals(String.Empty)) {
                MessageBox.Show("검색할 사용자 이름을 입력하세요", "경고", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
              }
              resultData = consentWebService.GetConsentList(patientCode
                                                    , sDate
                                                    , eDate
                                                    , consentState
                                                    , consentMain.ConsentExecuteInfo["dutinstcd"]
                                                    , searchString);    // 검색할 사용자 ID 를 넣는다

            }
            //ConsentVO[] resultData = consentWebService.GetConsentList(patientCode
            //                                                        , sDate
            //                                                        , eDate
            //                                                        , consentState
            //                                                        , string.Empty
            //                                                        , consentMain.ConsentExecuteInfo["dutinstcd"]
            //                                                        , userId);

            if (resultData == null) {
              return;
            }

            // 진료일 표시 형식 변경
            foreach (ConsentFormListVO v in resultData) {
              if (v.inDd.Length == 8) {
                v.inDd = v.inDd.Substring(0, 4) + "-" + v.inDd.Substring(4, 2) + "-" + v.inDd.Substring(6, 2);
              }
            }

            this.dataGridViewConsentSelectResult.DataSource = new SortableBindingList<ConsentFormListVO>(resultData);

            // 목록 조회 후 자동 선택 기능 제외
            consentMain.ClearPreviewConsent(true);

            /*
            ConsentFormListVO vo = GetCurrentConsentVO(0);

            if (vo != null) {
                ExecutePreviewWithSelectedConsent(vo);
            } else {
                consentMain.ClearPreviewConsent(true);
            }
            */
          }
        } else {
          //// dbs227, 발행리스트 시작일자를 한달전으로 설정
          //this.dateTimePickerStartDate.Value = DateTime.Now.AddMonths(-1);
        }
      } catch (Exception ex) {
        MessageBox.Show(this, ex.Message);
      }
    }

    /// <summary>
    /// 검색할 동의서 상태의 값을 반환한다
    /// </summary>
    /// <returns>현재 체크박스에 선택된 값을 String 타입으로 반환, ex) "ALL" or "'UNFINISHED','TEMP'"</returns>
    private string GetCheckConsentState() {
      string consentState = "";

      if (this.checkBoxAll.Checked) {
        consentState = "ALL";
      } else {
        if (this.checkBoxUnfinished.Checked)
          consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxUnfinished.Tag + "'";

        if (this.checkBoxTemp.Checked)
          //consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxTemp.Tag + "'";
          consentState += ((consentState.Length > 0) ? "," : "") + "'TEMP', 'UNFINISHED', 'ELECTR_CMP'";

        if (this.checkBoxElectronicCmp.Checked)
          consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxElectronicCmp.Tag + "'";

        if (this.checkBoxCertifyCmp.Checked)
          consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxCertifyCmp.Tag + "'";

        if (this.checkBoxPaperOut.Checked)
          consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxPaperOut.Tag + "'";

        if (this.checkBoxVerbal.Checked)
          consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxVerbal.Tag + "'";
      }

      return consentState;
    }
    #endregion

    #region ConsentState 확인
    private static bool IsConsentStateTempSave(ConsentFormListVO vo) {
      if (vo.consentStateEng.ToUpper().Equals("TEMP") || vo.consentStateEng.ToUpper().Equals("VERBAL")) {
        return true;
      }
      return false;
    }

    private static bool IsConsentStatePrintOut(ConsentFormListVO vo) {
      return vo.consentStateEng.ToUpper().Equals("PAPER_OUT");
    }

    private static bool IsConsentStateElectronicComplete(ConsentFormListVO vo) {
      return vo.consentStateEng.ToUpper().Equals("ELECTR_CMP");
    }

    private static bool IsConsentStateCertifyComplete(ConsentFormListVO vo) {
      return vo.consentStateEng.ToUpper().Equals("CERTIFY_CMP");
    }

    private static bool IsConsentStateUnfinished(ConsentFormListVO vo) {
      return vo.consentStateEng.ToUpper().Equals("UNFINISHED");
    }
    #endregion

    #region 체크박스 이벤트
    private void checkBoxAll_CheckedChanged(object sender, EventArgs e) {
      if (this.checkBoxAll.Checked == true) {
        this.checkBoxUnfinished.Checked = false;
        this.checkBoxTemp.Checked = false;
        this.checkBoxElectronicCmp.Checked = false;
        this.checkBoxCertifyCmp.Checked = false;
        this.checkBoxPaperOut.Checked = false;
      }
    }

    private void checkBoxUnfinished_CheckedChanged(object sender, EventArgs e) {
      if (this.checkBoxUnfinished.Checked == true && this.checkBoxAll.Checked == true) {
        this.checkBoxAll.Checked = false;
      }
    }

    private void checkBoxTemp_CheckedChanged(object sender, EventArgs e) {
      if (this.checkBoxTemp.Checked == true && this.checkBoxAll.Checked == true) {
        this.checkBoxAll.Checked = false;
      }
    }

    private void checkBoxElectronicCmp_CheckedChanged(object sender, EventArgs e) {
      if (this.checkBoxElectronicCmp.Checked == true && this.checkBoxAll.Checked == true) {
        this.checkBoxAll.Checked = false;
      }
    }

    private void checkBoxCertifyCmp_CheckedChanged(object sender, EventArgs e) {
      if (this.checkBoxCertifyCmp.Checked == true && this.checkBoxAll.Checked == true) {
        this.checkBoxAll.Checked = false;
      }
    }

    private void checkBoxPaperOut_CheckedChanged(object sender, EventArgs e) {
      if (this.checkBoxPaperOut.Checked == true && this.checkBoxAll.Checked == true) {
        this.checkBoxAll.Checked = false;
      }
    }
    #endregion

    #region 조회버튼 클릭 이벤트        
    /// <summary>
    /// 동의서 목록 조회
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
    private void buttonConsentSelect_Click(object sender, EventArgs e) {
      buttonConsentSelect.Enabled = false;
      Application.DoEvents();

      string checkState = GetCheckConsentState();

      if (checkState.Length > 0) {

        if (!string.IsNullOrEmpty(searchStartDate)) {
          searchStartDate = this.dateTimePickerStartDate.Value.ToShortDateString();
        }

        try {
          InitDataGrid();
          BindDataGridRows();
        } catch (Exception ex) {
          throw ex;
        }
      } else {
        MessageBox.Show(string.Format(Properties.Resources.msg_unfinished_check)
                        , string.Format(Properties.Resources.msg_caption_confirm),
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
      }

      buttonConsentSelect.Enabled = true;
    }
    #endregion

    #region 동의서 미리보기
    //선택된 Row의 ConsentFormListVO 객체를 반환한다.
    private ConsentFormListVO GetCurrentConsentVO(int rowIndex) {
      ConsentFormListVO vo = null;

      if (rowIndex < 0) {
        return vo;
      }

      if (dataGridViewConsentSelectResult != null && dataGridViewConsentSelectResult.Rows.Count > 0) {
        this.dataGridViewConsentSelectResult.Rows[rowIndex].Selected = true;
        //this.dataGridViewConsentSelectResult.CurrentCell = this.dataGridViewConsentSelectResult.Rows[rowIndex].Cells[0];

        vo = this.dataGridViewConsentSelectResult.Rows[rowIndex].DataBoundItem as ConsentFormListVO;
      }
      return vo;
    }

    //선택된 ConsentVO 객체를 미리보기 실행한다.
    private void ExecutePreviewWithSelectedConsent(ConsentFormListVO vo) {
      if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
      if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;

      Cursor currentCursor = this.Cursor;
      this.Cursor = Cursors.WaitCursor;

      if (rdoUser.Checked) {

        consentMain.ConsentExecuteInfo["patientNo"] = vo.pid;
        consentMain.ConsentExecuteInfo["clnDate"] = vo.inDd.Replace("-", "");
        consentMain.ConsentExecuteInfo["visitType"] = vo.ordType;
        consentMain.ConsentExecuteInfo["clnDept"] = vo.ordDeptCd;
        consentMain.ConsentExecuteInfo["cretno"] = vo.cretNo.ToString();
        consentMain.ConsentExecuteInfo["opRsrvNo"] = vo.opRsrvNo;

        consentMain.SetPatientInfo();
      }

      commandControl.CurrentPreviewConsent = new PreviewConsent {
        formRid = vo.formRid.ToString(),
        formGuid = vo.formGuid,
        formCd = vo.formCd.ToString(),
        FormName = vo.formName,
        formPrintName = vo.formPrntNm,
        prntCnt = vo.printCnt,
        consentMstRid = vo.consentMstRid.ToString(),
        consentState = vo.consentStateEng,
        consentStateEngnm = vo.consentStateEng,
        orderNo = 0,
        ocrCode = vo.ocrTag,
        inputId = vo.createUserId,
        inputNm = vo.createUserName,
        ReissueConsentMstRid = IsConsentStatePrintOut(vo) ? vo.consentMstRid : 0,
        RewriteConsentMstRid = !IsConsentStateUnfinished(vo) ? vo.consentMstRid : 0,
        ordType = vo.ordType,
        ocrtagPrntyn = vo.ocrTagPrntYn,
        userDrFlag = vo.userDrFlag,
        printOnly = vo.printOnly,
        opDiagName = vo.opDiagNm,
        drOnly = vo.DrOnly,
        opName = vo.opNm
      };

      try {
        consentMain.PatientInfoCtrl.SetConsentDocumentName(vo.formName);

        if (IsConsentStateTempSave(vo) || IsConsentStateElectronicComplete(vo)) { // 임시저장 or 작성완료

          commandControl.ShowTempSaveConsent(consentMain);

        } else if (IsConsentStatePrintOut(vo)) { // 출력

          if (this.dataGridViewConsentSelectResult.SelectedRows.Count > 0 &&
              this.dataGridViewConsentSelectResult.SelectedRows[0].Tag != null &&
              this.dataGridViewConsentSelectResult.SelectedRows[0].Tag.Equals("reissueTarget")) {

            //재출력 하는 경우 
            commandControl.CurrentPreviewConsent.ReissueConsentMstRid = vo.consentMstRid;
            commandControl.CurrentPreviewConsent.RewriteConsentMstRid = 0;

            //CheckClnDateInfo(vo);
            commandControl.PreviewConsent(consentMain);

          } else {

            //CheckClnDateInfo(vo);
            commandControl.PreviewConsent(consentMain);
          }

        } else if (IsConsentStateCertifyComplete(vo)) { // 인증저장

          commandControl.ShowCompleteConsent(consentMain);//이미지 호출하는 함수

        } else if (IsConsentStateUnfinished(vo)) { //미작성

          //CheckClnDateInfo(vo);
          commandControl.PreviewConsent(consentMain); // consent_data에 데이터가 없을때 사용하는 함수
        }
      } catch {

      } finally {
        this.Cursor = currentCursor;
      }
    }

    //동의서의 처방일자와 생성번호 등의 정보가 현재 정보와 일치하지 않은 경우, 미리보기를 위해서 데이터를 재조회한다.
    private void CheckClnDateInfo(ConsentVO vo) {
      bool bSame = true;

      if (!vo.ClnDate.Replace("-", "").Equals(commandControl.CurrentTargetPatient.clnDate.Replace("-", "")))
        bSame = false;

      if (!vo.Cretno.ToString().Equals(commandControl.CurrentTargetPatient.cretno))
        bSame = false;

      if (!vo.ClnDeptCd.Equals(commandControl.CurrentTargetPatient.clnDeptCode))
        bSame = false;

      if (!vo.VisitType.Equals(commandControl.CurrentTargetPatient.VisitType))
        bSame = false;

      if (bSame == false) {
        //동의서 맵핑 정보를 상단의 선택된 진료일과 작성자 정보로 한다.
        consentMain.PatientInfoCtrl.SetPatientByConsentInfo(vo.ClnDate.Replace("-", ""),
                                                            vo.VisitType,
                                                            vo.ClnDeptCd,
                                                            vo.Cretno.ToString());
      }
    }
    #endregion

    #region 그리드 이벤트
    /*
    private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        ConsentFormListVO vo = GetCurrentConsentVO(e.RowIndex);

        if (vo != null)
        {
            IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this);
            consentMain.preParamClean();

            ExecutePreviewWithSelectedConsent(vo);
        }
    }
    */

    /// <summary>
    /// dataGridViewConsentSelectResult 그리드 컨트롤의 셀 우클릭 메뉴 생성
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="DataGridViewCellContextMenuStripNeededEventArgs"/> instance containing the event data.</param>
    private void dataGridViewConsentSelectResult_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) {

      if (consentMain.ConsentExecuteInfo["readOnly"].Equals("Y")) {
        return;
      }

      if (e.RowIndex > -1 && this.dataGridViewConsentSelectResult.Rows[e.RowIndex].Selected == true) {

        ConsentFormListVO vo = GetCurrentConsentVO(e.RowIndex);

        if (vo.consentStateEng.Equals("TEMP") || vo.consentStateEng.Equals("PAPER_OUT")) {

          ContextMenuStrip strip = new ContextMenuStrip();
          // 임시, 확인 저장의 경우 삭제메뉴를 보여준다
          if (vo.consentStateEng.Equals("TEMP") || vo.consentStateEng.Equals("ELECTR_CMP")) {
            // 사용자와 생성자가 동일해야 삭제 가능
            if(commandControl.CurrentEndUser.UserNo.Equals(vo.createUserId)) {
              ToolStripMenuItem deleteRecord = new ToolStripMenuItem {
                Text = "삭제"
              };
              strip.Items.Add(deleteRecord);
              deleteRecord.Click += new EventHandler(deleteRecord_Click);
            }            
            // 출력의 경우 재출력 메뉴를 보여준다
          } else if (vo.consentStateEng.Equals("PAPER_OUT")) {

            ToolStripMenuItem reprintRecord = new ToolStripMenuItem {
              Text = "재출력"
            };
            strip.Items.Add(reprintRecord);
            reprintRecord.Click += new EventHandler(reprintRecord_Click);
          }

          e.ContextMenuStrip = strip;
        }
      }
    }

    /// <summary>
    /// dataGridViewConsentSelectResult 그리드 컨트롤의 CellMouseDoubleClick 이벤트 핸들러
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
    private void dataGridViewConsentSelectResult_CellMouseDoubleClick(object sender, DataGridViewCellEventArgs e) {
      if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
      if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;

      // dbs227, 셀 클릭 시 더블클릭 인식되어 작동되는 경우 오류
      if (e.RowIndex < 0) {
        return;
      }

      // 현재 선택된 동의서를 가져온다
      ConsentFormListVO vo = GetCurrentConsentVO(e.RowIndex);

      string electrVisble = ConsentMainControl.SETTING_DATA["ELECTR_CMP"];
      if (commandControl.CurrentTargetPatient.VisitType.Equals("O")) {
        if (electrVisble.Equals("Y")) {
          commandControl.setCompleteSaveButton(true);
        }
      } else {
        if (electrVisble.Equals("Y") && commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) {
          commandControl.setCompleteSaveButton(true);
        } else {
          commandControl.setCompleteSaveButton(false);
        }
      }

      //if (commandControl.CurrentTargetPatient.VisitType.Equals("O")) {
      //  commandControl.setCompleteSaveButton(true);
      //} else {
      //  if (ConsentMainControl.SETTING_DATA["ELECTR_CMP"].Equals("Y") && commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) {
      //    commandControl.setCompleteSaveButton(true);
      //  } else {
      //    commandControl.setCompleteSaveButton(false);
      //  }

      //}

      //의사가 아니면 확인저장 비활성화
      //if (!commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) {
      //  commandControl.setCompleteSaveButton(false);
      //}

      // dbs227, 출력된 동의서는 미리보기를 하지 않는다
      if (vo.consentStateEng.Equals("PAPER_OUT")) {
        MessageBox.Show(String.Format(Properties.Resources.msg_printed_consent),
            String.Format(Properties.Resources.title_printed_consent));
        return;
      }

      if (vo != null) {
        if (!consentMain.checkOperationDocument(vo.formCd)) {
          return;
        }
        // 선택된 동의서가 현재 보여지고 있는 동의서와 다른 경우, 임시 저장 여부 확인
        if (!consentMain.ConsentExecuteInfo["readOnly"].Equals("Y") &&
            !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.PatientCode) &&
            commandControl.CurrentPreviewConsent != null && !commandControl.CurrentPreviewConsent.formRid.Equals(vo.formRid.ToString()) &&
            (commandControl.CurrentPreviewConsent.consentState == string.Empty || commandControl.CurrentPreviewConsent.consentState == "TEMP")) {
          // dbs227, 임시저장 팝업 사용 안함
          //DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_confirm_tempsave)
          //                            , string.Format(Properties.Resources.msg_caption_confirm),
          //                            MessageBoxButtons.YesNo, MessageBoxIcon.Information);

          //if (result == DialogResult.Yes) {
          //    consentMain.TempSave();
          //}
        }
        // startFormCd 를 초기화 한다
        consentMain.preParamClean();
        // 동의서 미리보기
        ExecutePreviewWithSelectedConsent(vo);

        if (!vo.consentStateEng.Equals("PAPER_OUT") && !vo.consentStateEng.Equals("ELECTR_CMP") && !vo.consentStateEng.Equals("CERTIFY_CMP")) {
          // 동의서 뷰어에 동의서 로드
          RunConsentDualView();
        }
      }
      /*
      ConsentFormListVO vo = GetCurrentConsentVO(e.RowIndex);

      if (vo != null)
      {
          if (vo.ConsentState.ToLower().Equals("electr_cmp") || vo.ConsentState.ToLower().Equals("certify_cmp") || vo.ConsentState.ToLower().Equals("paper_out"))
          {

          }
          else
          {
              //미작성, 임서저장 상태일때 마우스 더블클릭을 하면 양면으로 동의서 보여줌
              RunConsentDualView();
          }
      }
      */
    }

    /// <summary>
    /// 동의서 뷰어에 동의서 로드
    /// </summary>
    private void RunConsentDualView() {
      if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
      if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;

      commandControl.RunConsentDualView();
    }

    /// <summary>
    /// 동의서 삭제 이벤트 핸들러
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
    private void deleteRecord_Click(object sender, EventArgs e) {
      if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
      if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;

      bool bDel = true;
      ReasonForUseN reasonForUseN = new ReasonForUseN(bDel);
      if (reasonForUseN.ShowDialog() == DialogResult.OK) {
        string reason = reasonForUseN.GetReasonForUseN();
        reasonForUseN.Close();

        if (this.dataGridViewConsentSelectResult.SelectedRows.Count != 0) {
          Cursor currentCursor = this.Cursor;
          try {
            this.Cursor = Cursors.WaitCursor;

            //동의서 삭제 처리를 위해서 재발행MstID에 값을 넣는다.
            ConsentFormListVO vo = GetCurrentConsentVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index);

            // TODO dbs227 삭제 오류
              if (commandControl.CurrentPreviewConsent == null) {
              commandControl.CurrentPreviewConsent = new PreviewConsent {
                formRid = vo.formRid.ToString(),
                formGuid = vo.formGuid,
                formCd = vo.formCd.ToString(),
                FormName = vo.formName,
                formPrintName = vo.formPrntNm,
                prntCnt = vo.printCnt,
                consentMstRid = vo.consentMstRid.ToString(),
                consentStateEngnm = vo.consentStateEng,
                orderNo = 0,
                ocrCode = vo.ocrTag,
                inputId = vo.createUserId,
                inputNm = vo.createUserName,
                ReissueConsentMstRid = IsConsentStatePrintOut(vo) ? vo.consentMstRid : 0,
                RewriteConsentMstRid = !IsConsentStateUnfinished(vo) ? vo.consentMstRid : 0,
                ordType = vo.ordType,
                ocrtagPrntyn = vo.ocrTagPrntYn,
                userDrFlag = vo.userDrFlag,
                printOnly = vo.printOnly,
                opDiagName = vo.opDiagNm,
                drOnly = vo.DrOnly,
                opName = vo.opNm
              };
            }

            commandControl.CurrentPreviewConsent.ReissueConsentMstRid = vo.consentMstRid;
            // 미작성 동의서 삭제
            consentMain.ConsentCommandCtrl.DeleteRecordOfDeleteConsent(reason);
            // 동의서 목록 재조회 (미작성 동의서 삭제, 임시저장용 재조회, 인쇄출력용 재조회, 저장용(저장후 닫힘이 아닌 경우))
            consentMain.ConsentListCtrl.InquiryConsentData(-1);
          } catch (Exception ex) {

            throw ex;
          } finally {
            this.Cursor = currentCursor;
          }
          MessageBox.Show(string.Format(Properties.Resources.msg_consent_record_deleted)
                      , string.Format(Properties.Resources.msg_caption_confirm),
                              MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
      }
    }

    /// <summary>
    /// 재출력 클릭
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
    private void reprintRecord_Click(object sender, EventArgs e) {
      ConsentFormListVO vo = GetCurrentConsentVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index);

      if (vo != null) {
        if (vo.consentState.Equals("반납확인")) {
          MessageBox.Show("반납확인 서식은 재출력이 불가능 합니다.");
          return;
        }

        this.dataGridViewConsentSelectResult.SelectedRows[0].Tag = "reissueTarget"; // 재출력 대상 마킹
        ExecutePreviewWithSelectedConsent(vo);
        this.dataGridViewConsentSelectResult.SelectedRows[0].Tag = null;

        //재출력을 하는 경우, 바로 출력이 되도록 한다.
        if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
        if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
        // 출력 로그 저장을 위한 버튼 클릭 설정
        this.consentMain.setPrintButton(true);

        // 재출력 시 OCRTAG 중복확인 제외
        commandControl.reprintStatus = true;
        commandControl.PrintConsentDocument();
        commandControl.reprintStatus = false;
      }
    }
    #endregion

    public void clearSearchStartDate() {
      searchStartDate = string.Empty;
    }

    private void dataGridViewConsentSelectResult_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) {
      foreach (DataGridViewRow row in dataGridViewConsentSelectResult.Rows) {
        if (!string.IsNullOrEmpty(row.Cells["consentStateEng"].Value.ToString())) {
          if (row.Cells["consentStateEng"].Value.ToString().ToUpper() == "UNFINISHED") {
            row.DefaultCellStyle.ForeColor = System.Drawing.Color.Red;
          }
        }
      }
    }

    private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellEventArgs e) {

    }

    /// <summary>
    /// 선택된 동의서를 가져온다
    /// </summary>
    /// <returns>선택된 동의서 목록</returns>
    public List<ConsentFormListVO> getConfirmedCheckedConsentList() {
      List<ConsentFormListVO> consents = new List<ConsentFormListVO>();

      foreach (DataGridViewRow row in dataGridViewConsentSelectResult.Rows) {
        if (Convert.ToBoolean(row.Cells["colCheck"].Value)) {
          ConsentFormListVO consent = row.DataBoundItem as ConsentFormListVO;
          if (!consent.consentStateEng.Equals("ELECTR_CMP")) {
            return null;
          }
          consents.Add(consent);
        }
      }
      return consents;
    }

    /// <summary>
    /// 선택 초기화
    /// </summary>
    private void ClearCheckBox() {
      bool chkStatus = false;
      dataGridViewConsentSelectResult.Columns[0].HeaderText = "□";

      foreach (DataGridViewRow r in dataGridViewConsentSelectResult.Rows) {
        r.Cells["colCheck"].Value = chkStatus;
      }

      dataGridViewConsentSelectResult.RefreshEdit();
    }

    /// <summary>
    /// dbs227, 일괄저장
    /// 선택된 환자들의 저장 상태를 일괄저장으로 변경한다.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void saveAllCertify_Click(object sender, EventArgs e) {
      // 선택된 동의서 목록을 가져온다.
      List<ConsentFormListVO> lists = getConfirmedCheckedConsentList();

      if (lists == null || lists.Count < 1) {
        MessageBox.Show("동의서를 선택하거나 확인 저장 동의서만 선택해 주세요.");
        //ClearCheckBox();
        return;
      }

      String mstRids = "";
      String ocrTags = "";
      int i = 0;

      foreach (ConsentFormListVO consent in lists) {
        if (i != 0) {
          mstRids += ",";
          ocrTags += ",";
        }
        mstRids += "'" + consent.consentMstRid + "'";
        ocrTags += "'" + consent.ocrTag + "'";
        i++;
      }

      // 선택된 동의서 상태값을 바꿔 준다.
      String result = consentWebService.updateCertifyComplete(mstRids, ocrTags, consentMain.ConsentExecuteInfo["dutinstcd"]);

      if (result.Equals("Y")) {
        MessageBox.Show("일괄저장 하였습니다.");
        ClearCheckBox();
        try {
          this.checkBoxAll.Checked = true;
          InitDataGrid();
          BindDataGridRows();
        } catch (Exception ex) {
          throw ex;
        }
      }

    }

    /// <summary>
    /// 사용자 라디오 버튼 클릭 시 일괄저장을 보여준다
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void rdoUser_CheckedChanged(object sender, EventArgs e) {
      if (!rdoUser.Checked) {
        //saveAllCertify.Visible = false;
        searchName.Visible = false;
      }
      // 현재 로그인 한 사용자가 의사라면 일괄저장 버튼을 활성화 하여 준다.
      else if (rdoUser.Checked/* && commandControl.CurrentEndUser.JobKindCd.Equals("0330")*/) {
        // saveAllCertify 버튼 보이도록
        //saveAllCertify.Visible = true;
        searchName.Visible = true;
      }

    }
  }
}
