private void toolStripDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (TransView.RowCount > 0) { if (TransView.FocusedRowHandle >= 0) { if (TransView.GetRowCellValue(TransView.FocusedRowHandle, "Status").ToString() == "Register") { MessageBox.Show("Registration Not Delete"); return; } int Id = Convert.ToInt32(TransView.GetRowCellValue(TransView.FocusedRowHandle, "RegTransID")); int lVendorId = Convert.ToInt32(TransView.GetRowCellValue(TransView.FocusedRowHandle, "VendorId")); if (Id != m_oRegister.GetMaxRegTransId(lVendorId)) { MessageBox.Show("Do Not Delete!"); return; } DialogResult reply = MessageBox.Show("Do you want Delete?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (reply == DialogResult.Yes) { m_oRegister.DeleteRegTrans(Id); TransView.DeleteRow(TransView.FocusedRowHandle); //grdTrans.Rows.RemoveAt(grdTrans.CurrentRow.Index); m_oRegUpdate.UpdateRegistration(lVendorId); } } } }
private void PopulateData() { DataTable dt; dt = new DataTable(); dt = m_oRegister.GetRegTrans(m_lVendorId); DataView dv = new DataView(dt); dv.RowFilter = "RegTransId = " + m_lRegTransId; DataTable dtt = new DataTable(); dtt = dv.ToTable(); if (dtt.Rows.Count > 0) { int lRegId = Convert.ToInt32(dtt.Rows[0]["RegId"].ToString()); if (lRegId != 0) { for (int lCount = 0; lCount < dtReg.Rows.Count; lCount++) { cboReg.ItemIndex = lCount; if (Convert.ToInt32(cboReg.EditValue) == lRegId) { break; } } } cboReg.Enabled = false; txtRefNo.Text = dtt.Rows[0]["RefNo"].ToString(); dtpDate.EditValue = Convert.ToDateTime(dtt.Rows[0]["RDate"].ToString()); m_dOldDate = Convert.ToDateTime(dtt.Rows[0]["RDate"].ToString()); if (dtt.Rows[0]["StatusType"].ToString() == "R") { optStatusType.SelectedIndex = 0; } else if (dtt.Rows[0]["StatusType"].ToString() == "S") { optStatusType.SelectedIndex = 1; } else if (dtt.Rows[0]["StatusType"].ToString() == "B") { optStatusType.SelectedIndex = 2; } grdpStatusType.Enabled = false; if (Convert.ToBoolean(dtt.Rows[0]["Supply"].ToString()) == true) { chkSupply.Checked = true; dtpSFDate.EditValue = Convert.ToDateTime(dtt.Rows[0]["SFDate"].ToString()); dtpSTDate.EditValue = Convert.ToDateTime(dtt.Rows[0]["STDate"].ToString()); if (Convert.ToBoolean(dtt.Rows[0]["SLifeTime"].ToString()) == true) { chkSLife.Checked = true; } txtSGradeName.Text = dtt.Rows[0]["SGrade"].ToString(); txtSGradeName.Tag = dtt.Rows[0]["SGradeID"].ToString(); } if (Convert.ToBoolean(dtt.Rows[0]["Contract"].ToString()) == true) { chkContract.Checked = true; dtpCFDate.EditValue = Convert.ToDateTime(dtt.Rows[0]["CFDate"].ToString()); dtpCTDate.EditValue = Convert.ToDateTime(dtt.Rows[0]["CTDate"].ToString()); if (Convert.ToBoolean(dtt.Rows[0]["CLifeTime"].ToString()) == true) { chkCLife.Checked = true; } txtCGradeName.Text = dtt.Rows[0]["CGrade"].ToString(); txtCGradeName.Tag = dtt.Rows[0]["CGradeID"].ToString(); } if (Convert.ToBoolean(dtt.Rows[0]["Service"].ToString()) == true) { chkService.Checked = true; dtpHFDate.EditValue = Convert.ToDateTime(dtt.Rows[0]["HFDate"].ToString()); dtpHTDate.EditValue = Convert.ToDateTime(dtt.Rows[0]["HTDate"].ToString()); if (Convert.ToBoolean(dtt.Rows[0]["HLifeTime"].ToString()) == true) { chkHLife.Checked = true; } txtHGradeName.Text = dtt.Rows[0]["HGrade"].ToString(); txtHGradeName.Tag = dtt.Rows[0]["HGradeID"].ToString(); } txtRemarks.Text = dtt.Rows[0]["Remarks"].ToString(); } if (m_lRegTransId != 0) { if (m_lRegTransId != m_oRegister.GetMaxRegTransId(m_lVendorId)) { cmdOK.Enabled = false; } else { cmdOK.Enabled = true; } } UpdateRegNo(); txtVendorName.Text = m_sRegNo; txtVendorName.Tag = m_lVendorId; txtVendorName.Enabled = false; }