Example #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='13'");
             //right = dtRights.Rows.Count == 0 ? "00000000" : dtRights.Rows[0][0].ToString();
             try
             {
                 if (Request.QueryString[0].Equals("VIEW"))
                 {
                     BL_UnitMaster = new UnitMaster_BL();
                     mlCode        = Convert.ToInt32(Request.QueryString[1].ToString());
                     ViewRec("VIEW");
                 }
                 else if (Request.QueryString[0].Equals("MODIFY"))
                 {
                     BL_UnitMaster = new UnitMaster_BL();
                     mlCode        = Convert.ToInt32(Request.QueryString[1].ToString());
                     ViewRec("MOD");
                 }
                 txtUnitName.Focus();
             }
             catch (Exception ex)
             {
                 CommonClasses.SendError("Unit Master", "PageLoad", ex.Message);
             }
         }
     }
 }
    protected void dgUnitMaster_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            if (CommonClasses.ValidRights(int.Parse(right.Substring(4, 1)), this, "For Delete"))
            {
                if (!ModifyLog(((Label)(dgUnitMaster.Rows[e.RowIndex].FindControl("lblI_UOM_CODE"))).Text))
                {
                    BL_UnitMaster = new UnitMaster_BL();
                    string i_uom_code = ((Label)(dgUnitMaster.Rows[e.RowIndex].FindControl("lblI_UOM_CODE"))).Text;
                    string i_uom_name = ((Label)(dgUnitMaster.Rows[e.RowIndex].FindControl("lblI_UOM_NAME"))).Text;
                    string i_uom_desc = ((Label)(dgUnitMaster.Rows[e.RowIndex].FindControl("lblI_UOM_DESC"))).Text;
                    BL_UnitMaster.I_UOM_CODE = Convert.ToInt32(i_uom_code);
                    if (CommonClasses.CheckUsedInTran("ITEM_MASTER", "I_UOM_CODE", "AND ES_DELETE=0", i_uom_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_UnitMaster.Delete();
                        if (flag == true)
                        {
                            CommonClasses.WriteLog("Unit Master", "Delete", "Unit Master", i_uom_name, Convert.ToInt32(i_uom_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);
                        }

                        LoadUnit();
                    }
                }
            }
            else
            {
                PanelMsg.Visible = true;
                lblmsg.Text      = "You have No Rights To Delete";
                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);
            }
        }
        catch (Exception Ex)
        {
            CommonClasses.SendError("Unit Master - View", "GridView1_RowDeleting", Ex.Message);
        }
    }
 private void LoadUnit()
 {
     try
     {
         BL_UnitMaster = new UnitMaster_BL();
         BL_UnitMaster.I_UOM_CM_COMP_ID = Convert.ToInt32(Session["CompanyId"]);
         BL_UnitMaster.FillGrid(dgUnitMaster);
         if (dgUnitMaster.Rows.Count > 0)
         {
             dgUnitMaster.Enabled = true;
         }
     }
     catch (Exception Ex)
     {
         CommonClasses.SendError("Unit Master-View", "LoadUnit", Ex.Message);
     }
 }
Example #4
0
    //#region btnClose_Click
    //protected void btnClose_Click(object sender, EventArgs e)
    //{
    //    try
    //    {
    //        if (mlCode != 0 && mlCode != null)
    //        {
    //            CommonClasses.RemoveModifyLock("ITEM_UNIT_MASTER", "MODIFY", "I_UOM_CODE", mlCode);
    //        }
    //        Response.Redirect("~/Masters/VIEW/ViewUnitMaster.aspx", false);
    //    }
    //    catch (Exception Ex)
    //    {
    //        CommonClasses.SendError("Unit Master", "btnClose_Click", Ex.Message);
    //    }
    //}
    //#endregion btnClose_Click
    #endregion

    #region ViewRec
    private void ViewRec(string str)
    {
        try
        {
            BL_UnitMaster = new UnitMaster_BL(mlCode);
            DataTable dt = new DataTable();
            BL_UnitMaster.GetInfo();
            GetValues(str);
            if (str == "MOD")
            {
                CommonClasses.SetModifyLock("ITEM_UNIT_MASTER", "MODIFY", "I_UOM_CODE", mlCode);
            }
        }
        catch (Exception Ex)
        {
            CommonClasses.SendError("Unit Master", "ViewRec", Ex.Message);
        }
    }
Example #5
0
    bool SaveRec()
    {
        bool result = false;

        try
        {
            if (Request.QueryString[0].Equals("INSERT"))
            {
                BL_UnitMaster = new UnitMaster_BL();
                if (Setvalues())
                {
                    if (BL_UnitMaster.Save())
                    {
                        string Code = CommonClasses.GetMaxId("Select Max(I_UOM_CODE) from ITEM_UNIT_MASTER");
                        CommonClasses.WriteLog("Unit Master", "Save", "Unit Master", BL_UnitMaster.I_UOM_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/ViewUnitMaster.aspx", false);
                    }
                    else
                    {
                        if (BL_UnitMaster.Msg != "")
                        {
                            ShowMessage("#Avisos", BL_UnitMaster.Msg.ToString(), CommonClasses.MSG_Warning);
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                            //PanelMsg.Visible = true;
                            //lblmsg.Text = BL_UnitMaster.Msg;
                            BL_UnitMaster.Msg = "";
                        }
                        txtUnitName.Focus();
                    }
                }
            }
            else if (Request.QueryString[0].Equals("MODIFY"))
            {
                BL_UnitMaster = new UnitMaster_BL(mlCode);
                if (Setvalues())
                {
                    if (BL_UnitMaster.Update())
                    {
                        CommonClasses.RemoveModifyLock("ITEM_UNIT_MASTER", "MODIFY", "I_UOM_CODE", mlCode);
                        CommonClasses.WriteLog("Unit Master", "Update", "Unit Master", BL_UnitMaster.I_UOM_NAME, mlCode, Convert.ToInt32(Session["CompanyId"]), Convert.ToInt32(Session["CompanyCode"]), (Session["Username"].ToString()), Convert.ToInt32(Session["UserCode"]));
                        result = true;
                        Response.Redirect("~/Masters/VIEW/ViewUnitMaster.aspx", false);
                    }
                    else
                    {
                        if (BL_UnitMaster.Msg != "")
                        {
                            ShowMessage("#Avisos", BL_UnitMaster.Msg.ToString(), CommonClasses.MSG_Warning);
                            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

                            BL_UnitMaster.Msg = "";
                        }
                        txtUnitName.Focus();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            CommonClasses.SendError("Unit Master", "SaveRec", ex.Message);
        }
        return(result);
    }