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 ? "00000000" : dtRights.Rows[0][0].ToString(); try { if (Request.QueryString[0].Equals("VIEW")) { BL_ItemCategoryMaster = new ItemCategoryMaster_BL(); mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); ViewRec("VIEW"); } else if (Request.QueryString[0].Equals("MODIFY")) { BL_ItemCategoryMaster = new ItemCategoryMaster_BL(); mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); ViewRec("MOD"); } txtItemCategoryName.Focus(); } catch (Exception ex) { CommonClasses.SendError("Item Category Master", "PageLoad", ex.Message); } } } }
protected void dgItemCategory_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete")) { if (!ModifyLog(((Label)(dgItemCategory.Rows[e.RowIndex].FindControl("lblI_CAT_CODE"))).Text)) { BL_ItemCategoryMaster = new ItemCategoryMaster_BL(); string i_cat_code = ((Label)(dgItemCategory.Rows[e.RowIndex].FindControl("lblI_CAT_CODE"))).Text; string i_cat_name = ((Label)(dgItemCategory.Rows[e.RowIndex].FindControl("lblI_CAT_NAME"))).Text; BL_ItemCategoryMaster.I_CAT_CODE = Convert.ToInt32(i_cat_code); if (CommonClasses.CheckUsedInTran("ITEM_MASTER", "I_CAT_CODE", "AND ES_DELETE=0", i_cat_code)) { PanelMsg.Visible = true; lblmsg.Text = "You cant delete this record it has used in Item Master"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); //ShowMessage("#Avisos", "You cant delete this record it has used in Components", CommonClasses.MSG_Warning); } else { bool flag = BL_ItemCategoryMaster.Delete(); if (flag == true) { CommonClasses.WriteLog("Item Category Master", "Delete", "Item Category Master", i_cat_code, Convert.ToInt32(i_cat_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); } } //} LoadCategory(); } } else { PanelMsg.Visible = true; lblmsg.Text = "You Have No Rights To Delete"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } } catch (Exception Ex) { CommonClasses.SendError("Item Category Master-View", "GridView1_RowDeleting", Ex.Message); } }
private void LoadCategory() { try { BL_ItemCategoryMaster = new ItemCategoryMaster_BL(); BL_ItemCategoryMaster.I_CAT_CM_COMP_ID = Convert.ToInt32(Session["CompanyId"]); BL_ItemCategoryMaster.FillGrid(dgItemCategory); if (dgItemCategory.Rows.Count > 0) { dgItemCategory.Enabled = true; } } catch (Exception Ex) { CommonClasses.SendError("Item Category Master - View", "LoadItemCategory", Ex.Message); } }
private void ViewRec(string str) { try { BL_ItemCategoryMaster = new ItemCategoryMaster_BL(mlCode); DataTable dt = new DataTable(); BL_ItemCategoryMaster.GetInfo(); GetValues(str); if (str == "MOD") { CommonClasses.SetModifyLock("ITEM_CATEGORY_MASTER", "MODIFY", "I_CAT_CODE", mlCode); } } catch (Exception Ex) { CommonClasses.SendError("Item Category Master", "ViewRec", Ex.Message); } }
bool SaveRec() { bool result = false; try { if (Request.QueryString[0].Equals("INSERT")) { BL_ItemCategoryMaster = new ItemCategoryMaster_BL(); if (Setvalues()) { if (BL_ItemCategoryMaster.Save()) { string Code = CommonClasses.GetMaxId("Select Max(I_CAT_CODE) from ITEM_CATEGORY_MASTER"); CommonClasses.WriteLog("Item Category Master", "Save", "Item Category Master", BL_ItemCategoryMaster.I_CAT_NAME, Convert.ToInt32(Code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Masters/VIEW/ViewItemCategoryMaster.aspx", false); } else { if (BL_ItemCategoryMaster.Msg != "") { ShowMessage("#Avisos", BL_ItemCategoryMaster.Msg.ToString(), CommonClasses.MSG_Warning); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); //lblmsg.Text = BL_ItemCategoryMaster.Msg; //PanelMsg.Visible = true; BL_ItemCategoryMaster.Msg = ""; } txtItemCategoryName.Focus(); } } } else if (Request.QueryString[0].Equals("MODIFY")) { BL_ItemCategoryMaster = new ItemCategoryMaster_BL(mlCode); if (Setvalues()) { if (BL_ItemCategoryMaster.Update()) { CommonClasses.RemoveModifyLock("ITEM_CATEGORY_MASTER", "MODIFY", "I_CAT_CODE", mlCode); CommonClasses.WriteLog("ITEM CATEGORY MASTER", "Update", "ITEM CATEGORY MASTER", BL_ItemCategoryMaster.I_CAT_NAME, mlCode, Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Masters/VIEW/ViewItemCategoryMaster.aspx", false); } else { if (BL_ItemCategoryMaster.Msg != "") { ShowMessage("#Avisos", BL_ItemCategoryMaster.Msg.ToString(), CommonClasses.MSG_Warning); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); BL_ItemCategoryMaster.Msg = ""; } txtItemCategoryName.Focus(); } } } } catch (Exception ex) { CommonClasses.SendError("Item Category Master", "SaveRec", ex.Message); } return(result); }