private void LoadSupplier() { try { BL_CustomerTypeMaster = new CustomerTypeMaster_BL(); BL_CustomerTypeMaster.CTM_CM_COMP_ID = Convert.ToInt32(Session["CompanyId"]); // BL_CustomerTypeMaster.FillGrid(dgCustomerTypeMaster); BL_CustomerTypeMaster.FillGrid(dgCustomerTypeMaster); if (dgCustomerTypeMaster.Rows.Count == 0) { dgCustomerTypeMaster.Enabled = false; dtFilter.Clear(); if (dtFilter.Columns.Count == 0) { dtFilter.Columns.Add(new System.Data.DataColumn("CTM_CODE", typeof(String))); dtFilter.Columns.Add(new System.Data.DataColumn("CTM_TYPE_CODE", typeof(String))); dtFilter.Columns.Add(new System.Data.DataColumn("CTM_TYPE_DESC", typeof(String))); dtFilter.Columns.Add(new System.Data.DataColumn("CTM_FIRST_LETTER", typeof(String))); dtFilter.Rows.Add(dtFilter.NewRow()); dgCustomerTypeMaster.DataSource = dtFilter; dgCustomerTypeMaster.DataBind(); } } else { dgCustomerTypeMaster.Enabled = true; } } catch (Exception Ex) { CommonClasses.SendError("Customer Type Master-View", "LoadSupplier", Ex.Message); } }
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_CustomerTypeMaster = new CustomerTypeMaster_BL(); mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); ViewRec("VIEW"); } else if (Request.QueryString[0].Equals("MODIFY")) { BL_CustomerTypeMaster = new CustomerTypeMaster_BL(); mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); ViewRec("MOD"); } txtCustomerTypeCode.Focus(); } catch (Exception ex) { CommonClasses.SendError("Customer Type Master", "PageLoad", ex.Message); } } } }
protected void dgCustomerTypeMaster_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { if (CommonClasses.ValidRights(int.Parse(right.Substring(5, 1)), this, "For Delete")) { if (!ModifyLog(((Label)(dgCustomerTypeMaster.Rows[e.RowIndex].FindControl("lblCTM_CODE"))).Text)) { BL_CustomerTypeMaster = new CustomerTypeMaster_BL(); string Supplier_Code = ((Label)(dgCustomerTypeMaster.Rows[e.RowIndex].FindControl("lblCTM_CODE"))).Text; string Supplier_Type_Code = ((Label)(dgCustomerTypeMaster.Rows[e.RowIndex].FindControl("lblCTM_TYPE_CODE"))).Text; string Supplier_Desc = ((Label)(dgCustomerTypeMaster.Rows[e.RowIndex].FindControl("lblCTM_TYPE_DESC"))).Text; string Supplier_First_Letter = ((Label)(dgCustomerTypeMaster.Rows[e.RowIndex].FindControl("lblCTM_FIRST_LETTER"))).Text; BL_CustomerTypeMaster.CTM_CODE = Convert.ToInt32(Supplier_Code); if (CommonClasses.CheckUsedInTran("PARTY_MASTER", "P_CUST_TYPE", "AND ES_DELETE=0 and P_TYPE=1", Supplier_Code)) { // ShowMessage("#Avisos", "You can't delete this record it has used in Supplier Master", CommonClasses.MSG_Warning); PanelMsg.Visible = true; lblmsg.Text = "You can't delete this record it has used in Customer Master"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } else { bool flag = BL_CustomerTypeMaster.Delete(); if (flag == true) { CommonClasses.WriteLog("Customer Type Master", "Delete", "Customer Type Master", Supplier_Code, Convert.ToInt32(Supplier_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); } LoadSupplier(); } } } else { PanelMsg.Visible = true; lblmsg.Text = "You Have No Rights To Delete"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } } catch (Exception Ex) { CommonClasses.SendError("Customer Type Master-View", "dgCustomerTypeMaster_RowDeleting", Ex.Message); } }
private void ViewRec(string str) { try { BL_CustomerTypeMaster = new CustomerTypeMaster_BL(mlCode); DataTable dt = new DataTable(); BL_CustomerTypeMaster.GetInfo(); GetValues(str); if (str == "MOD") { CommonClasses.SetModifyLock("CUSTOMER_TYPE_MASTER", "MODIFY", "CTM_CODE", mlCode); } } catch (Exception Ex) { CommonClasses.SendError("Customer Type Master", "ViewRec", Ex.Message); } }
bool SaveRec() { bool result = false; try { if (Request.QueryString[0].Equals("INSERT")) { BL_CustomerTypeMaster = new CustomerTypeMaster_BL(); if (Setvalues()) { if (BL_CustomerTypeMaster.Save()) { string Code = CommonClasses.GetMaxId("Select Max(CTM_CODE) from CUSTOMER_TYPE_MASTER"); CommonClasses.WriteLog("Customer Type Master", "Save", "Customer Type Master", BL_CustomerTypeMaster.CTM_TYPE_CODE, Convert.ToInt32(Code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Masters/VIEW/ViewCustomerTypeMaster.aspx", false); } else { if (BL_CustomerTypeMaster.Msg != "") { //ShowMessage("#Avisos", BL_CustomerTypeMaster.Msg.ToString(), CommonClasses.MSG_Warning); lblmsg.Text = BL_CustomerTypeMaster.Msg; PanelMsg.Visible = true; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert1();", true); BL_CustomerTypeMaster.Msg = ""; } txtCustomerTypeCode.Focus(); } } } else if (Request.QueryString[0].Equals("MODIFY")) { BL_CustomerTypeMaster = new CustomerTypeMaster_BL(mlCode); if (Setvalues()) { if (BL_CustomerTypeMaster.Update()) { CommonClasses.RemoveModifyLock("CUSTOMER_TYPE_MASTER", "MODIFY", "CTM_CODE", mlCode); CommonClasses.WriteLog("Customer Type Master", "Update", "Customer Type Master", BL_CustomerTypeMaster.CTM_TYPE_CODE, mlCode, Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Masters/VIEW/ViewCustomerTypeMaster.aspx", false); } else { if (BL_CustomerTypeMaster.Msg != "") { //ShowMessage("#Avisos", BL_CustomerTypeMaster.Msg.ToString(), CommonClasses.MSG_Warning); lblmsg.Text = BL_CustomerTypeMaster.Msg; PanelMsg.Visible = true; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert1();", true); BL_CustomerTypeMaster.Msg = ""; } txtCustomerTypeCode.Focus(); } } } } catch (Exception ex) { CommonClasses.SendError("Customer Type Master", "SaveRec", ex.Message); } return(result); }