예제 #1
0
 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='132'");
             right = dtRights.Rows.Count == 0 ? "0000000" : dtRights.Rows[0][0].ToString();
             try
             {
                 if (Request.QueryString[0].Equals("VIEW"))
                 {
                     BL_TransportMaster = new TransportMaster_BL();
                     mlCode             = Convert.ToInt32(Request.QueryString[1].ToString());
                     ViewRec("VIEW");
                 }
                 else if (Request.QueryString[0].Equals("MODIFY"))
                 {
                     BL_TransportMaster = new TransportMaster_BL();
                     mlCode             = Convert.ToInt32(Request.QueryString[1].ToString());
                     ViewRec("MOD");
                 }
                 txtTransportName.Focus();
             }
             catch (Exception ex)
             {
                 CommonClasses.SendError("Transport Master", "PageLoad", ex.Message);
             }
         }
     }
 }
    protected void dgTransportMaster_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete"))
            {
                if (!ModifyLog(((Label)(dgTransportMaster.Rows[e.RowIndex].FindControl("lblT_CODE"))).Text))
                {
                    BL_TransportMaster = new TransportMaster_BL();
                    string T_CODE = ((Label)(dgTransportMaster.Rows[e.RowIndex].FindControl("lblT_CODE"))).Text;
                    string T_NAME = ((Label)(dgTransportMaster.Rows[e.RowIndex].FindControl("lblT_NAME"))).Text;
                    BL_TransportMaster.T_CODE = Convert.ToInt32(T_CODE);
                    //if (CommonClasses.CheckUsedInTran("STATE_MASTER", "SM_T_CODE", "AND ES_DELETE=0", T_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_TransportMaster.Delete();
                    if (flag == true)
                    {
                        CommonClasses.WriteLog("Transport Master", "Delete", "Transport Master", T_NAME, Convert.ToInt32(T_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);
                    }
                    //}
                }
                LoadTransport();
            }



            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("Transport Master", "dgTransportMaster_RowDeleting", Ex.Message);
        }
    }
 private void LoadTransport()
 {
     try
     {
         BL_TransportMaster = new TransportMaster_BL();
         BL_TransportMaster.T_CM_COMP_ID = Convert.ToInt32(Session["CompanyId"]);
         BL_TransportMaster.FillGrid(dgTransportMaster);
     }
     catch (Exception Ex)
     {
         CommonClasses.SendError("Transport Master", "LoadTransport", Ex.Message);
     }
 }
예제 #4
0
 private void ViewRec(string str)
 {
     try
     {
         BL_TransportMaster = new TransportMaster_BL(mlCode);
         DataTable dt = new DataTable();
         BL_TransportMaster.GetInfo();
         GetValues(str);
         if (str == "MOD")
         {
             CommonClasses.SetModifyLock("TRANSAPORT_MASTER", "MODIFY", "T_CODE", mlCode);
         }
     }
     catch (Exception Ex)
     {
         CommonClasses.SendError("Transport Master", "ViewRec", Ex.Message);
     }
 }
예제 #5
0
    bool SaveRec()
    {
        bool result = false;

        try
        {
            string StrReplaceSctorName = txtTransportName.Text;


            StrReplaceSctorName = StrReplaceSctorName.Replace("'", "''");

            if (Request.QueryString[0].Equals("INSERT"))
            {
                BL_TransportMaster = new TransportMaster_BL();
                if (Setvalues())
                {
                    if (BL_TransportMaster.Save())
                    {
                        string Code = CommonClasses.GetMaxId("Select Max(T_CODE) from TRANSAPORT_MASTER");
                        CommonClasses.WriteLog("Transport Master", "Save", "Transport Master", BL_TransportMaster.T_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/ViewTransportMaster.aspx", false);
                    }
                    else
                    {
                        if (BL_TransportMaster.Msg != "")
                        {
                            //ShowMessage("#Avisos", BL_TransportMaster.Msg.ToString(), CommonClasses.MSG_Warning);
                            lblmsg.Text      = "Record Already Exists";
                            PanelMsg.Visible = true;
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert1();", true);

                            BL_TransportMaster.Msg = "";
                        }
                        txtTransportName.Focus();
                    }
                }
            }
            else if (Request.QueryString[0].Equals("MODIFY"))
            {
                BL_TransportMaster = new TransportMaster_BL(mlCode);
                if (Setvalues())
                {
                    if (BL_TransportMaster.Update())
                    {
                        CommonClasses.RemoveModifyLock("TRANSAPORT_MASTER", "MODIFY", "T_CODE", mlCode);
                        CommonClasses.WriteLog("Transport Master", "Update", "Transport Master", BL_TransportMaster.T_NAME, mlCode, Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                        result = true;
                        Response.Redirect("~/Admin/View/ViewTransportMaster.aspx", false);
                    }
                    else
                    {
                        if (BL_TransportMaster.Msg != "")
                        {
                            ShowMessage("#Avisos", BL_TransportMaster.Msg.ToString(), CommonClasses.MSG_Warning);
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                            BL_TransportMaster.Msg = "";
                        }
                        txtTransportName.Focus();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            CommonClasses.SendError("Transport Master", "SaveRec", ex.Message);
        }
        return(result);
    }