protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty((string)Session["CompanyId"]) && string.IsNullOrEmpty((string)Session["Username"])) { Response.Redirect("~/Default.aspx", false); } else { if (!IsPostBack) { //DataTable dtRights = CommonClasses.Execute("select UR_RIGHTS from USER_RIGHT where UR_IS_DELETE=0 AND UR_UM_CODE='" + Convert.ToInt32(Session["UserCode"]) + "' and UR_SM_CODE='13'"); //right = dtRights.Rows.Count == 0 ? "0000000" : dtRights.Rows[0][0].ToString(); try { if (Request.QueryString[0].Equals("VIEW")) { BL_AreaMaster = new AreaMaster_BL(); mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); ViewRec("VIEW"); } else if (Request.QueryString[0].Equals("MODIFY")) { BL_AreaMaster = new AreaMaster_BL(); mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); ViewRec("MOD"); } txtAreaCode.Focus(); } catch (Exception ex) { CommonClasses.SendError("Area Master", "PageLoad", ex.Message); } } } }
protected void dgAreaMaster_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete")) { if (!ModifyLog(((Label)(dgAreaMaster.Rows[e.RowIndex].FindControl("lblA_Code"))).Text)) { BL_AreaMaster = new AreaMaster_BL(); string Area_Code = ((Label)(dgAreaMaster.Rows[e.RowIndex].FindControl("lblA_Code"))).Text; string Area_No = ((Label)(dgAreaMaster.Rows[e.RowIndex].FindControl("lblA_NO"))).Text; string Area_Desc = ((Label)(dgAreaMaster.Rows[e.RowIndex].FindControl("lblA_DESC"))).Text; BL_AreaMaster.A_CODE = Convert.ToInt32(Area_Code); if (CommonClasses.CheckUsedInTran("PARTY_MASTER", "P_A_CODE", "AND ES_DELETE=0", Area_Code)) { // ShowMessage("#Avisos", "You cant delete this record it has used in Party Master", CommonClasses.MSG_Warning); PanelMsg.Visible = true; lblmsg.Text = "You cant delete this record it has used in Party Master"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } else { bool flag = BL_AreaMaster.Delete(); if (flag == true) { CommonClasses.WriteLog("Area Master", "Delete", "Area Master", Area_Code, Convert.ToInt32(Area_Code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); //ShowMessage("#Avisos", CommonClasses.strRegDelSucesso, CommonClasses.MSG_Erro); PanelMsg.Visible = true; lblmsg.Text = "Record Deleted Successfully"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } LoadArea(); } } } else { PanelMsg.Visible = true; lblmsg.Text = "You have no rights to Delete"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } } catch (Exception Ex) { CommonClasses.SendError("Area Master-View", "dgAreaMaster_RowDeleting", Ex.Message); } }
private void LoadArea() { try { BL_AreaMaster = new AreaMaster_BL(); BL_AreaMaster.A_CM_COMP_ID = Convert.ToInt32(Session["CompanyId"]); BL_AreaMaster.FillGrid(dgAreaMaster); if (dgAreaMaster.Rows.Count > 0) { dgAreaMaster.Enabled = true; } } catch (Exception Ex) { CommonClasses.SendError("Area Master-View", "LoadArea", Ex.Message); } }
private void ViewRec(string str) { try { BL_AreaMaster = new AreaMaster_BL(mlCode); DataTable dt = new DataTable(); BL_AreaMaster.GetInfo(); GetValues(str); if (str == "MOD") { CommonClasses.SetModifyLock("AREA_MASTER", "MODIFY", "A_CODE", mlCode); } } catch (Exception Ex) { CommonClasses.SendError("Area Master", "ViewRec", Ex.Message); } }
bool SaveRec() { bool result = false; try { if (Request.QueryString[0].Equals("INSERT")) { BL_AreaMaster = new AreaMaster_BL(); if (Setvalues()) { if (BL_AreaMaster.Save()) { string Code = CommonClasses.GetMaxId("Select Max(A_CODE) from AREA_MASTER"); CommonClasses.WriteLog("Area Master", "Save", "Area Master", BL_AreaMaster.A_NO, Convert.ToInt32(Code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Masters/VIEW/ViewAreaMaster.aspx", false); } else { if (BL_AreaMaster.Msg != "") { ShowMessage("#Avisos", BL_AreaMaster.Msg.ToString(), CommonClasses.MSG_Warning); //lblmsg.Text = BL_AreaMaster.Msg; //PanelMsg.Visible = true; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); BL_AreaMaster.Msg = ""; } txtAreaCode.Focus(); } } } else if (Request.QueryString[0].Equals("MODIFY")) { BL_AreaMaster = new AreaMaster_BL(mlCode); if (Setvalues()) { if (BL_AreaMaster.Update()) { CommonClasses.RemoveModifyLock("AREA_MASTER", "MODIFY", "A_CODE", mlCode); CommonClasses.WriteLog("Area Master", "Update", "Area Master", BL_AreaMaster.A_NO, mlCode, Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Masters/VIEW/ViewAreaMaster.aspx", false); } else { if (BL_AreaMaster.Msg != "") { ShowMessage("#Avisos", BL_AreaMaster.Msg.ToString(), CommonClasses.MSG_Warning); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); BL_AreaMaster.Msg = ""; } txtAreaCode.Focus(); } } } } catch (Exception ex) { CommonClasses.SendError("Area Master", "SaveRec", ex.Message); } return(result); }