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='5'"); right = dtRights.Rows.Count == 0 ? "0000000" : dtRights.Rows[0][0].ToString(); try { if (Request.QueryString[0].Equals("VIEW")) { BL_CountryMaster = new CountryMaster_BL(); mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); ViewRec("VIEW"); } else if (Request.QueryString[0].Equals("MODIFY")) { BL_CountryMaster = new CountryMaster_BL(); mlCode = Convert.ToInt32(Request.QueryString[1].ToString()); ViewRec("MOD"); } txtCountryName.Focus(); } catch (Exception ex) { CommonClasses.SendError("Country Master", "PageLoad", ex.Message); } } } }
protected void dgCountryMaster_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete")) { if (!ModifyLog(((Label)(dgCountryMaster.Rows[e.RowIndex].FindControl("lblCOUNTRY_CODE"))).Text)) { BL_CountryMaster = new CountryMaster_BL(); string COUNTRY_CODE = ((Label)(dgCountryMaster.Rows[e.RowIndex].FindControl("lblCOUNTRY_CODE"))).Text; string COUNTRY_NAME = ((Label)(dgCountryMaster.Rows[e.RowIndex].FindControl("lblCOUNTRY_NAME"))).Text; BL_CountryMaster.COUNTRY_CODE = Convert.ToInt32(COUNTRY_CODE); if (CommonClasses.CheckUsedInTran("STATE_MASTER", "SM_COUNTRY_CODE", "AND ES_DELETE=0", COUNTRY_CODE)) { //ShowMessage("#Avisos", "You cant delete this record it has used in State Master", CommonClasses.MSG_Warning); PanelMsg.Visible = true; lblmsg.Text = "You cant delete this record it has used in State Master"; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); } else { bool flag = BL_CountryMaster.Delete(); if (flag == true) { CommonClasses.WriteLog("Country Master", "Delete", "Country Master", COUNTRY_NAME, Convert.ToInt32(COUNTRY_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); } } } LoadCountry(); } 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("Country Master", "dgCountryMaster_RowDeleting", Ex.Message); } }
private void LoadCountry() { try { BL_CountryMaster = new CountryMaster_BL(); BL_CountryMaster.COUNTRY_CM_COMP_ID = Convert.ToInt32(Session["CompanyId"]); BL_CountryMaster.FillGrid(dgCountryMaster); } catch (Exception Ex) { CommonClasses.SendError("Country Master", "LoadCountry", Ex.Message); } }
private void ViewRec(string str) { try { BL_CountryMaster = new CountryMaster_BL(mlCode); DataTable dt = new DataTable(); BL_CountryMaster.GetInfo(); GetValues(str); if (str == "MOD") { CommonClasses.SetModifyLock("COUNTRY_MASTER", "MODIFY", "COUNTRY_CODE", mlCode); } } catch (Exception Ex) { CommonClasses.SendError("Country Master", "ViewRec", Ex.Message); } }
bool SaveRec() { bool result = false; try { string StrReplaceSctorName = txtCountryName.Text; StrReplaceSctorName = StrReplaceSctorName.Replace("'", "''"); if (Request.QueryString[0].Equals("INSERT")) { BL_CountryMaster = new CountryMaster_BL(); if (Setvalues()) { if (BL_CountryMaster.Save()) { string Code = CommonClasses.GetMaxId("Select Max(COUNTRY_CODE) from COUNTRY_MASTER"); CommonClasses.WriteLog("Country Master", "Save", "Country Master", BL_CountryMaster.COUNTRY_NAME, Convert.ToInt32(Code), Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Admin/View/ViewCountryMaster.aspx", false); } else { if (BL_CountryMaster.Msg != "") { //ShowMessage("#Avisos", BL_CountryMaster.Msg.ToString(), CommonClasses.MSG_Warning); lblmsg.Text = "Record Already Exists"; PanelMsg.Visible = true; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert1();", true); BL_CountryMaster.Msg = ""; } txtCountryName.Focus(); } } } else if (Request.QueryString[0].Equals("MODIFY")) { BL_CountryMaster = new CountryMaster_BL(mlCode); if (Setvalues()) { if (BL_CountryMaster.Update()) { CommonClasses.RemoveModifyLock("COUNTRY_MASTER", "MODIFY", "COUNTRY_CODE", mlCode); CommonClasses.WriteLog("Country Master", "Update", "Country Master", BL_CountryMaster.COUNTRY_NAME, mlCode, Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"])); result = true; Response.Redirect("~/Admin/View/ViewCountryMaster.aspx", false); } else { if (BL_CountryMaster.Msg != "") { ShowMessage("#Avisos", BL_CountryMaster.Msg.ToString(), CommonClasses.MSG_Warning); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); BL_CountryMaster.Msg = ""; } txtCountryName.Focus(); } } } } catch (Exception ex) { CommonClasses.SendError("Country Master", "SaveRec", ex.Message); } return(result); }