Exemplo n.º 1
0
        private void btnDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (gvBilling.FocusedRowHandle < 0)
            {
                return;
            }
            if (XtraMessageBox.Show($"Are you sure want to delete {gvBilling.GetFocusedRowCellValue("ITEMNAME")} ?"
                                    , "Confirmation!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                txtItemCode.Focus();
                return;
            }

            object billDetailID = gvBilling.GetFocusedRowCellValue("BILLDETAILID");

            SNo = Convert.ToInt32(gvBilling.GetFocusedRowCellValue("SNO"));
            DataTable dtSNos = new DataTable();

            dtSNos.Columns.Add("BILLDETAILID", typeof(int));
            dtSNos.Columns.Add("SNO", typeof(int));

            for (int curRowHandle = gvBilling.FocusedRowHandle - 1; curRowHandle >= 0; curRowHandle--)
            {
                gvBilling.SetRowCellValue(curRowHandle, "SNO", SNo);
                dtSNos.Rows.Add(gvBilling.GetRowCellValue(curRowHandle, "BILLDETAILID"), SNo);
                SNo++;
            }

            DataTable dtBillingDetails = billingRepository.DeleteBillDetail(billDetailID, Utility.logininfo.UserID, dtSNos);

            gvBilling.DeleteRow(gvBilling.FocusedRowHandle);
            UpdateBillDetails(dtBillingDetails, 0);
            txtItemCode.Focus();
        }