using System; using System.Text; using System.Data; using System.Drawing; using System.Windows.Forms; using System.Collections; using Cosmos.Win; using Cosmos.BaseFrame; using Cosmos.UserFrame; using Cosmos.ServiceProvider; using Cosmos.Common; using Cosmos.CommonManager; using Cosmos.UI; /*-----------------------------------------------------------------------------------------------*/ // 설 명 : 외화 // 작 성 자 : // 변경 이력 : /*-----------------------------------------------------------------------------------------------*/ namespace Cosmos.Win { public partial class frmExchageRate : Form { #region 변수 선언 private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) private PosStatus m_cPosStatus = new PosStatus(); // 기본정보 참조 private TranStatus m_cTrnStatus = new TranStatus(); // 거래정보 참조 private DeviceStatus m_cDevStatus = new DeviceStatus(); // 디바이스 관리 private IDataCommonUs m_cDataCommon = null; // POS 공통함수 인터페이스 private IDataProcessUs m_cDataService = null; private IPaymentUs m_cForeign = null; private string m_sPosMenuKeyIn; public string PosMenuKeyIn { set { m_sPosMenuKeyIn = value; } get { return m_sPosMenuKeyIn; } } private string m_sPosMenuKeyOut; public string PosMenuKeyOut { set { m_sPosMenuKeyOut = value; } get { return m_sPosMenuKeyOut; } } private bool bNotDoubleClik = false; // 더블 클릭 방지용 private string m_sPosMenuKey; // 입력코드 /// /// 구분 /// public string SetPosMenuKey { set { this.m_sPosMenuKey = value; } } /// /// 입력구분 /// private string m_sInPutType = ""; /// /// 입력데이터 /// private string m_sInPutData = ""; /// /// 카드데이터 /// private string m_sInEncData = ""; /// /// 결제구분 /// private string m_sPay_DC_Grp_Type = ""; /// /// 결제상세구분 /// private string m_sPay_DC_CD = ""; #endregion 변수 선언 #region 생성자 & 소멸자 & 폼초기화 public frmExchageRate() { InitializeComponent(); base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); //this.UpdateStyles(); m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE); m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); m_cForeign = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.FOREIGN); } private void frmForeign_Load(object sender, EventArgs e) { UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ""); InitControl(); } private void frmForeign_Activated(object sender, EventArgs e) { } private void frmForeign_Deactivate(object sender, EventArgs e) { PosOLEDevice.SetEventHandle(null); } private void frmForeign_FormClosing(object sender, FormClosingEventArgs e) { ICustDisplayUs cCustDisp = (ICustDisplayUs)sManager.InitServiceInstance(ServiceLists.ASV_CUSTDISPLAY.DLL, ServiceLists.ASV_CUSTDISPLAY.CUST_DISPLAY); cCustDisp.DisplaySaleItemList(false, true, 0); // 고객화면 표시 UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text); } /// /// 폼 컨트롤 초기화 /// private void InitControl() { try { // 이미지 로딩 처리 picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S); FormManager.SetFormAllControlFont(this, m_cPosStatus.Base.FONT); FormManager.SetTextBoxGlobalInfo(this, m_cPosStatus.Global.m_stCultureMaster.nGroupingDigits, m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol , m_cPosStatus.Global.m_stCultureMaster.nDecimalDigits, m_cPosStatus.Global.m_stCultureMaster.strDecimalSymbol); FormManager.MovePopUpForm(this, false, m_cPosStatus.Sale.ScreenSizeUser); lblInfo.Font = new Font(m_cPosStatus.Base.FONT, 11); btnExit.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.BTN_CLOSE); if (btnExit.Image != null) btnExit.Text = ""; btnDate.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.ICON_DATE_BASIC); if (btnDate.Image != null) btnDate.Text = ""; btnAllUp.DefaultImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_210X48_UP1_BASIC); btnAllUp.ClickImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_210X48_UP1_PRESS); btnAllUp.BorderStyle = BorderStyle.None; btnAllDw.DefaultImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_210X48_DOWN1_BASIC); btnAllDw.ClickImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_210X48_DOWN1_PRESS); btnAllDw.BorderStyle = BorderStyle.None; //테마색상 적용! btnEnter.BackColor = CmUtil.GetColorToString(m_cPosStatus.ScnMst.ThemeColor); padInPut.ThemeColor = m_cPosStatus.ScnMst.ThemeColor; padInPut.ClearBtnText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0817); padInPut.SearchBtnText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1018); // 타이틀 if (m_sPosMenuKey == PosKey.MENU_KEY.REG_EXCHG_RATE) lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0335); m_sPay_DC_Grp_Type = ItemConst.TR_ITEM_ID.FOREIGNEX_ITEM; m_sPay_DC_CD = ItemConst.TR_ITEM_ID.FOREIGNEX.USD; lblSaleDate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0354); // 조회일자 lblInfo.Text = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0376); // 안내문구 //btnSelect.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0004); // 조회 btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0225); // 저장 m_sInPutType = ""; // 입력구분 m_sInPutData = ""; // 입력데이터 m_sInEncData = ""; // 카드데이터 txtDate.InputTypeFormat = m_cPosStatus.Global.m_stCultureMaster.strDatePattern; txtDate.Text = m_cPosStatus.Global.DateToCulture(DateTime.ParseExact(m_cPosStatus.Base.SaleDate, "yyyyMMdd", null).AddDays(-1).ToString("yyyyMMdd")); bNotDoubleClik = false; SearchTxtInPut(); // 환율 조회 표시 } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } #endregion #region 버튼 입력 처리 /// /// 버튼 입력 처리 /// /// /// private void btnProc_Click(object sender, EventArgs e) { string sRet = UserCom.RST_ERR; try { if (bNotDoubleClik) return; bNotDoubleClik = true; if ((UI.CsmButton)sender == btnAllUp) // 상단 그리드 Up { if (dgvData.Rows.Count == 0) { bNotDoubleClik = false; return; } if (dgvData.CurrentRow.Index > 0) { for (int iLoop = dgvData.CurrentRow.Index - 1; iLoop >= 0; iLoop--) { if (dgvData.Rows[iLoop].Visible == false) continue; dgvData.Rows[iLoop].Selected = true; dgvData.Rows[iLoop].Cells[dgvData.CurrentCell.ColumnIndex].Selected = true; break; } } } else if ((UI.CsmButton)sender == btnAllDw) // 상단 그리드 Down { if (dgvData.Rows.Count == 0) { bNotDoubleClik = false; return; } if (dgvData.CurrentRow.Index < dgvData.Rows.Count - 1) { for (int iLoop = dgvData.CurrentRow.Index + 1; iLoop <= dgvData.Rows.Count - 1; iLoop++) { if (dgvData.Rows[iLoop].Visible == false) { bNotDoubleClik = false; continue; } dgvData.Rows[iLoop].Selected = true; dgvData.Rows[iLoop].Cells[dgvData.CurrentCell.ColumnIndex].Selected = true; break; } } } //else if (((Cosmos.UI.CsmButton)sender) == btnSelect) // 조회 //{ // SearchTxtInPut(); // bNotDoubleClik = false; // return; //} else if (((Cosmos.UI.CsmButton)sender) == btnEnter) // 저장 { // 저장 sRet = CompleteTxtInPut(); bNotDoubleClik = false; if (sRet != UserCom.RST_OK) return; WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0340); this.DialogResult = DialogResult.OK; this.Close(); //txtDate.Text = m_cPosStatus.Global.DateToCulture(DateTime.ParseExact(m_cPosStatus.Base.SaleDate, "yyyyMMdd", null).AddDays(-1).ToString("yyyyMMdd")); //SearchTxtInPut(); return; } padInPut.SetActiveFocus(); } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); bNotDoubleClik = false; } bNotDoubleClik = false; } /// /// 닫기 /// /// /// private void btnExit_Click(object sender, EventArgs e) { try { txtEditBox_EditBoxKeyDownEvent(null, PosKey.MENU_KEY.ESC_PREVIOUS); } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } #endregion #region 텍스트박스 키 입력 이벤트 처리 /// /// 텍스트박스 키 입력 이벤트 처리 /// /// /// private void txtEditBox_EditBoxKeyDownEvent(object sender, string sFuncValue) { try { if (sFuncValue == PosKey.MENU_KEY.ENTER) { } else if (sFuncValue == PosKey.MENU_KEY.CLEAR) { } else if (sFuncValue == PosKey.MENU_KEY.ESC_PREVIOUS) { this.DialogResult = DialogResult.Cancel; this.Close(); } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 텍스트박스 활성화 처리 /// /// /// private void txtEditBox_EnterEvent(object sender, EventArgs e) { try { padInPut.SetActiveControl = (Control)sender; } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 코드 변경시 초기화 /// /// /// private void txtCardNo_EditBoxTextChangedEvnet(object sender, EventArgs e) { m_sInPutType = ""; // 입력구분 m_sInPutData = ""; // 입력데이터 m_sInEncData = ""; // 카드데이터 } #endregion #region 텍스트박스 입력 유효성 체크 /// /// 텍스트박스 입력 유효성 체크 /// /// /// private bool CheckTxtInPut(object sender, bool bSearchMode) { try { // 결제금액 체크 //if (m_cDataService.DoubleParse(txtPayAmt.Text) <= 0) //{ // WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0034); // dgvData.Select(); // return false; //} } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); return false; } return true; } #endregion #region 환율 조회 및 저장 처리 /// /// 환율 조회 표시 /// /// 성공/실패 public bool SearchTxtInPut() { try { // 그리드 초기화 DataGridSetting(); // List 조회 (마스터 조정후 쿼리 수정 필요) DataTable dtMemu = m_cDataCommon.SelectExchangeRate(m_cPosStatus.Global.CultureToDate(txtDate.Text)); if (dtMemu == null) return false; if (dtMemu.Rows.Count <= 0) return false; // 메뉴정보 설정 foreach (DataRow dr in dtMemu.Rows) { int iRow = dgvData.Rows.Add(); dgvData.Rows[iRow].Visible = true; dgvData.Rows[iRow].Cells[0].ReadOnly = false; dgvData.Rows[iRow].HeaderCell.Value = (iRow + 1).ToString(); dgvData.Rows[iRow].Cells[0].Value = CmUtil.GetDataRowStr(dr, PosMst.MST_FOREIGN_RATE_KEY.DATA.EXCHG_RATE_CD); // 외화 코드 dgvData.Rows[iRow].Cells[1].Value = CmUtil.GetDataRowStr(dr, PosMst.MST_FOREIGN_RATE_KEY.DATA.EXCHG_RATE_NM); // 외화 명 dgvData.Rows[iRow].Cells[2].Value = m_cPosStatus.Global.NumericTOCurrency(CmUtil.GetDataRowDouble(dr, PosMst.MST_FOREIGN_RATE_KEY.DATA.EXCHG_RATE_AMT)); // 환율 dgvData.Rows[iRow].Cells[3].Value = m_cPosStatus.Global.NumericTOCurrency(CmUtil.GetDataRowDouble(dr, PosMst.MST_FOREIGN_RATE_KEY.DATA.EXCHG_RATE_UNIT)); // 환전 단위 dgvData.Rows[iRow].Cells[2].Style.BackColor = Color.White; dgvData.Rows[iRow].Cells[0].Style.BackColor = Color.FromArgb(222, 222, 222); dgvData.Rows[iRow].Cells[1].Style.BackColor = Color.FromArgb(222, 222, 222); dgvData.Rows[iRow].Cells[3].Style.BackColor = Color.FromArgb(222, 222, 222); } dgvData.Refresh(); dgvData.CurrentCell = dgvData.Rows[0].Cells[2]; dgvData.Focus(); return true; } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); return false; } } /// /// 환율 저장 처리 /// /// /// private string CompleteTxtInPut() { string sRet = UserCom.RST_ERR; DataTable dtMemu = null; string sMaxChasu = ""; try { // 승인 if (CheckTxtInPut(null, false) != true) return sRet; // 환율 차수 조회 dtMemu = m_cDataCommon.SelectExchangeRateChasu(m_cPosStatus.Base.SaleDate); if (dtMemu != null) { if (dtMemu.Rows.Count > 0) { foreach (DataRow dr in dtMemu.Rows) { sMaxChasu = CmUtil.GetDataRowStr(dr, "MAX_CHASU"); } } } // 입력한 위치 찾기 for (int iLoop = 0; iLoop < dgvData.RowCount; iLoop++) { string[] aRet = new string[6]; aRet[0] = m_cPosStatus.Base.SaleDate; aRet[1] = dgvData.Rows[iLoop].Cells[0].Value.ToString(); aRet[2] = dgvData.Rows[iLoop].Cells[1].Value.ToString(); aRet[3] = m_cDataService.DoubleParse(dgvData.Rows[iLoop].Cells[2].EditedFormattedValue.ToString()).ToString(); aRet[4] = m_cDataService.DoubleParse(dgvData.Rows[iLoop].Cells[3].Value.ToString()).ToString(); aRet[5] = sMaxChasu; dtMemu = m_cDataCommon.SaveExchangeRate(aRet); sRet = UserCom.RST_ERR; if (dtMemu == null) continue; if (dtMemu.Rows.Count <= 0) continue; sRet = UserCom.RST_OK; } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } return sRet; } #endregion #region DeviceEvent 관련 /// /// DeviceEvent 관련 /// /// /// /// /// public void OnDeviceEvent(string sDevice, string sData1, string sData2, string sData3) { try { switch (sDevice) { case PosConst.OPOS_DEVICE.MSR: this.Invoke(new EventHandler(OnMSREvent)); break; case PosConst.OPOS_DEVICE.SCANNER: this.Invoke(new EventHandler(OnScannerEvent)); break; } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// MSR Event /// /// /// private void OnMSREvent(object source, EventArgs e) { } /// /// 스캐너 이벤트 처리 /// /// /// private void OnScannerEvent(object source, EventArgs e) { string sScanData = m_cDevStatus.Scanner.DataLabel; try { //if (sScanData.Length > 0 && m_sInPutData == "") //{ // m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_BARCODE_GIFT; // m_sInPutData = sScanData; // txtCardNo.Text = m_sInPutData; // /// if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.NORMAL) SearchTxtInPut(); //} } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } /// /// 카드 번호 암호화 /// /// /// /// /// private string EncryptedCardNo(string sInData, ref string sCardData, ref string sCardNo) { string sEncData = sInData; try { } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } return sEncData; } /// /// IC 카드 정보 입력 처리 /// /// private bool GetIcCardData() { try { } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } return false; } #endregion #region 그리드 설정 및 사용 private double DataGridSetting() { try { // 초기화 dgvData.Rows.Clear(); dgvData.AllowUserToAddRows = false; dgvData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgvData.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing; dgvData.Font = this.Font; dgvData.DefaultCellStyle.Font = new Font(m_cPosStatus.Base.FONT, 14); dgvData.Font = new Font(m_cPosStatus.Base.FONT, 12); dgvData.RowHeadersDefaultCellStyle.Font = new Font(m_cPosStatus.Base.FONT, 12); // 타이틀 설정 dgvData.Columns[1].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0296); dgvData.Columns[2].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0301); dgvData.Columns[2].DefaultCellStyle.BackColor = Color.FromArgb(255, 224, 192); dgvData.Columns[3].HeaderText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0594); dgvData.Refresh(); return 0; } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } return 0; } #endregion #region 조회일자 변경 private void dtDateFrom_ValueChanged(object sender, EventArgs e) { try { SearchTxtInPut(); } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } #endregion private void btnDate_Click(object sender, EventArgs e) { try { string sDate = WinBasic.ShowForm(new string[] { FormManager.FORM_CALENDAR }); if (sDate != "") txtDate.Text = m_cPosStatus.Global.DateToCulture(sDate); } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } } private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e) { try { dgvData.Rows[e.RowIndex].Cells[2].Selected = true; dgvData.EditMode = DataGridViewEditMode.EditProgrammatically; dgvData.BeginEdit(true); } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.ToString()); } } private void dgvData_CurrentCellChanged(object sender, EventArgs e) { try { dgvData.Rows[dgvData.CurrentRow.Index].Cells[2].Selected = true; dgvData.EditMode = DataGridViewEditMode.EditProgrammatically; dgvData.BeginEdit(true); } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.ToString()); } } private void dgvData_SelectionChanged(object sender, EventArgs e) { try { //dgvData.Rows[dgvData.CurrentRow.Index].Cells[2].Selected = true; dgvData.EditMode = DataGridViewEditMode.EditProgrammatically; dgvData.BeginEdit(true); } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.ToString()); } } } }