Ejemplo n.º 1
0
        private void btnDelete_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                if (grdPBRegView.FocusedRowHandle >= 0)
                {
                    if (BsfGlobal.FindPermission("Progress Bill-Delete") == false)
                    {
                        MessageBox.Show("You don't have Rights to Progress Bill-Delete");
                        return;
                    }

                    int iProgRegId = Convert.ToInt32(grdPBRegView.GetRowCellValue(grdPBRegView.FocusedRowHandle, "ProgRegId"));
                    int iCCId      = Convert.ToInt32(grdPBRegView.GetRowCellValue(grdPBRegView.FocusedRowHandle, "CostCentreId"));

                    bool bAns = ProgBillBL.GetApprFound(iProgRegId, iCCId);
                    if (bAns == true)
                    {
                        MessageBox.Show("Bill Approved, Do not Delete");
                        return;
                    }

                    bAns = ProgBillBL.GetReceiptRaised(iProgRegId, iCCId);
                    if (bAns == true)
                    {
                        MessageBox.Show("Receipt Raised, Could not Delete");
                        return;
                    }

                    DialogResult Result;
                    Result = MessageBox.Show("Do you Want to Delete?", "CRM", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (Result == DialogResult.Yes)
                    {
                        if (m_sBussinessType == "B")
                        {
                            ProgBillBL.DeletePBillMaster(iProgRegId);
                            grdPBRegView.DeleteRow(grdPBRegView.FocusedRowHandle);
                            grdPBTransView.DeleteRow(grdPBTransView.FocusedRowHandle);
                            BsfGlobal.InsertLog(DateTime.Now, "Progress Bill-Delete", "D", "Progress Bill", iProgRegId, iCCId, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId, 0, 0);
                        }
                        else
                        {
                            ProgBillBL.DeletePlotPBillMaster(iProgRegId);
                            grdPBRegView.DeleteRow(grdPBRegView.FocusedRowHandle);
                            grdPBTransView.DeleteRow(grdPBTransView.FocusedRowHandle);
                            BsfGlobal.InsertLog(DateTime.Now, "Plot-Progress-Bill-Delete", "D", "Plot Progress Bill", iProgRegId, iCCId, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId, 0, 0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                BsfGlobal.CustomException(ex.Message, ex.StackTrace);
            }
        }