protected void dgBillPassing_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete")) { if (!ModifyLog(((Label)(dgBillPassing.Rows[e.RowIndex].FindControl("lblBPM_CODE"))).Text)) { string cpom_code = ((Label)(dgBillPassing.Rows[e.RowIndex].FindControl("lblBPM_CODE"))).Text; billPassing_BL = new BillPassing_BL(); billPassing_BL.BPM_CODE = Convert.ToInt32(cpom_code); // Check Invoice in Payment Master And Validate if it is used. // DataTable dtAccount = CommonClasses.Execute("SELECT * FROM PAYMENT_MASTER where PAYMENT_MASTER .ES_DELETE=0 AND PAYM_P_CODE IN(SELECT distinct BPM_P_CODE FROM BILL_PASSING_MASTER WHERE BPM_CODE='" + cpom_code.ToString() + "' AND BILL_PASSING_MASTER.ES_DELETE=0) "); DataTable dtAccount = CommonClasses.Execute("SELECT distinct BPM_P_CODE FROM BILL_PASSING_MASTER WHERE BPM_CODE='" + cpom_code.ToString() + "' AND BILL_PASSING_MASTER.ES_DELETE=0 and BILL_PASSING_MASTER.BPM_PAID_AMT!=0"); if (dtAccount.Rows.Count == 0) { if (billPassing_BL.Delete()) { CommonClasses.WriteLog("Bill Passing", "Delete", "Bill Passing", "", Convert.ToInt32(cpom_code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); PanelMsg.Visible = true; lblmsg.Text = "Record Deleted Successfully"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); LoadBill(); } else { PanelMsg.Visible = true; lblmsg.Text = "Record Not Deleted.."; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } } else { PanelMsg.Visible = true; lblmsg.Text = "Record is used in Payment Entry.."; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } } } else { PanelMsg.Visible = true; lblmsg.Text = "You have no rights to delete"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); return; } } catch (Exception Ex) { CommonClasses.SendError("Bill Passing-View", "dgBillPassing_RowDeleting", Ex.Message); } }
protected void dgBillPassing_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete")) { if (!ModifyLog(((Label)(dgBillPassing.Rows[e.RowIndex].FindControl("lblEX_CODE"))).Text)) { string cpom_code = ((Label)(dgBillPassing.Rows[e.RowIndex].FindControl("lblEX_CODE"))).Text; billPassing_BL = new BillPassing_BL(); billPassing_BL.BPM_CODE = Convert.ToInt32(cpom_code); if (CommonClasses.Execute1("UPDATE EXICSE_ENTRY SET ES_DELETE=1 WHERE EX_CODE='" + cpom_code + "'")) { DataTable dtGetInws = CommonClasses.Execute("SELECT EXD_I_CODE,EXD_IWM_CODE FROM EXCISE_DETAIL WHERE EXD_EX_CODE='" + cpom_code + "'"); if (dtGetInws.Rows.Count > 0) { DataTable dtIsCustrej = CommonClasses.Execute("SELECT * from EXICSE_ENTRY WHERE EX_IS_CUSTREJ=1 AND EX_CODE='" + cpom_code + "'"); if (dtIsCustrej.Rows.Count > 0) { for (int i = 0; i < dtGetInws.Rows.Count; i++) { CommonClasses.Execute("UPDATE CUSTREJECTION_DETAIL SET CD_MODVAT_FLG=0 WHERE CD_I_CODE='" + dtGetInws.Rows[i]["EXD_I_CODE"].ToString() + "' AND CD_CR_CODE='" + dtGetInws.Rows[i]["EXD_IWM_CODE"].ToString() + "'"); } } else { for (int i = 0; i < dtGetInws.Rows.Count; i++) { CommonClasses.Execute("Update INWARD_DETAIL set IWD_MODVAT_FLG=0 WHERE IWD_I_CODE='" + dtGetInws.Rows[i]["EXD_I_CODE"].ToString() + "' AND IWD_IWM_CODE='" + dtGetInws.Rows[i]["EXD_IWM_CODE"].ToString() + "'"); } } } CommonClasses.WriteLog("Excise Entry", "Delete", "Excise Entry", "", Convert.ToInt32(cpom_code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); PanelMsg.Visible = true; lblmsg.Text = "Record Deleted Successfully"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); LoadBill(); } else { PanelMsg.Visible = true; lblmsg.Text = "Record Not Deleted.."; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } } } else { PanelMsg.Visible = true; lblmsg.Text = "You have no rights to delete"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); //ShowMessage("#Avisos", "You Have No Rights To Delete", CommonClasses.MSG_Erro); return; } } catch (Exception Ex) { CommonClasses.SendError("Excise Entry-View", "dgBillPassing_RowDeleting", Ex.Message); } }