private void VoucherGridView_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e) { DataRow currentrow = VoucherGridView.GetDataRow(VoucherGridView.FocusedRowHandle); if (VoucherGridView.FocusedColumn.FieldName == "AccCode") { VoucherGridView.SetRowCellValue(VoucherGridView.FocusedRowHandle, VoucherGridView.Columns["CRDR"], SetCrDrValue()); } }
private void HelpGrid_DoubleClick(object sender, EventArgs e) { HelpGridView.CloseEditor(); HelpGridView.UpdateCurrentRow(); DataRow row = HelpGridView.GetDataRow(HelpGridView.FocusedRowHandle); if (HelpGrid.Text == "txtVoucherTypeCode") { txtVoucherTypeCode.Text = row["VouCode"].ToString(); txtVoucherTypeDesc.Text = row["VouDesc"].ToString(); HelpGrid.Visible = false; panelControl2.Visible = false; txtCatgCode.Focus(); } if (HelpGrid.Text == "txtCatgCode") { txtCatgCode.Text = row["CatgCode"].ToString(); txtCatgDesc.Text = row["CatgDesc"].ToString(); HelpGrid.Visible = false; panelControl2.Visible = false; txtShortNarration.Focus(); } if (HelpGrid.Text == "CRDR") { DataRow dtNewRow = dt.NewRow(); dtNewRow["AccCode"] = string.Empty; dtNewRow["AccName"] = string.Empty; dtNewRow["Debit"] = Convert.ToDecimal("0.00"); dtNewRow["Credit"] = Convert.ToDecimal("0.00"); dtNewRow["Narration"] = string.Empty; dtNewRow["CRDR"] = row["ValueCode"].ToString(); dt.Rows.Add(dtNewRow); if (dt.Rows.Count > 0) { VoucherGrid.DataSource = dt; VoucherGridView.BestFitColumns(); } else { VoucherGrid.DataSource = null; VoucherGridView.BestFitColumns(); } VoucherGridView.FocusedColumn = VoucherGridView.Columns["AccCode"]; VoucherGridView.Focus(); HelpGrid.Visible = false; panelControl2.Visible = false; } if (HelpGrid.Text == "AccCode") { if (HelpGridView.RowCount > 0) { VoucherGridView.SetRowCellValue(RowIndex, VoucherGridView.Columns["AccCode"], row["AccCode"].ToString()); VoucherGridView.SetRowCellValue(RowIndex, VoucherGridView.Columns["AccName"], row["AccName"].ToString()); panelControl2.Visible = false; VoucherGridView.Focus(); VoucherGridView.FocusedRowHandle = RowIndex; DataRow CurrentRow = VoucherGridView.GetDataRow(RowIndex); if (CurrentRow["CRDR"].ToString().ToUpper() == "CR") { VoucherGridView.FocusedColumn = VoucherGridView.Columns["Credit"]; VoucherGridView.ShowEditor(); } if (CurrentRow["CRDR"].ToString().ToUpper() == "DR") { VoucherGridView.FocusedColumn = VoucherGridView.Columns["Debit"]; VoucherGridView.ShowEditor(); } txtSearchBox.Text = string.Empty; } } }