Ejemplo n.º 1
0
    protected void BtnUpdate_Click(object sender, EventArgs e)
    {
        int UpdateRow = 0, InsertDetail = 0, InsertChkDetail = 0;

        try
        {
            if (Check() == true)
            {
                if (ViewState["EditID"] != null)
                {
                    Entity_UserMaster.UserID = Convert.ToInt32(ViewState["EditID"]);
                }
                Entity_UserMaster.UserName = TxtUserName.Text.Trim();
                // Entity_UserMaster.EmpID = Convert.ToInt32(ddlEmployee.SelectedValue);
                Entity_UserMaster.LoginName = txtUser.Text.Trim();
                Entity_UserMaster.EmailId   = TxtEmailid.Text.Trim();
                Entity_UserMaster.Password  = txtpassword.Text.Trim();

                if (RadioIsAdmin.Text.Equals("T"))
                {
                    Entity_UserMaster.IsAdmin  = true;
                    Entity_UserMaster.UserType = "Admin";
                }
                if (RadioIsAdmin.Text.Equals("F"))
                {
                    Entity_UserMaster.IsAdmin  = false;
                    Entity_UserMaster.UserType = "User";
                }
                Entity_UserMaster.UpdatedBy   = Convert.ToInt32(Session["UserID"]);
                Entity_UserMaster.UpdatedDate = Convert.ToDateTime(DateTime.Today.ToString());

                UpdateRow = obj_DMUserMaster.UpdateUserDetails(ref Entity_UserMaster, out StrError);

                if (UpdateRow > 0)
                {
                    for (int i = 0; i < GridUserRight.Rows.Count; i++)
                    {
                        Label    LblFormName   = (Label)GridUserRight.Rows[i].Cells[3].FindControl("LblFormName");
                        CheckBox GrdAddRight   = (CheckBox)GridUserRight.Rows[i].Cells[4].FindControl("GrdAddRight");
                        CheckBox GrdViewRight  = (CheckBox)GridUserRight.Rows[i].Cells[5].FindControl("GrdViewRight");
                        CheckBox GrdEditRight  = (CheckBox)GridUserRight.Rows[i].Cells[6].FindControl("GrdEditRight");
                        CheckBox GrdDelRight   = (CheckBox)GridUserRight.Rows[i].Cells[7].FindControl("GrdDelRight");
                        CheckBox GrdPrintRight = (CheckBox)GridUserRight.Rows[i].Cells[8].FindControl("GrdPrintRight");

                        Entity_UserMaster.FkUserId = Convert.ToInt32(ViewState["EditID"]);
                        Entity_UserMaster.FormName = LblFormName.Text;
                        Entity_UserMaster.AddAuth  = GrdAddRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                        Entity_UserMaster.ViewAuth = GrdViewRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                        Entity_UserMaster.EditAuth = GrdEditRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                        Entity_UserMaster.DelAuth = GrdDelRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                        Entity_UserMaster.PrintAuth = GrdPrintRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                        InsertDetail = obj_DMUserMaster.InsertUserAuthDetails(ref Entity_UserMaster, out StrError);
                    }

                    if (UpdateRow > 0)
                    {
                        obj_Comman.ShowPopUpMsg("Record Updated Successfully..!", this.Page);
                        MakeEmptyform();
                        Entity_UserMaster = null;
                        obj_Comman        = null;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
Ejemplo n.º 2
0
    protected void BtnUpdate_Click(object sender, EventArgs e)
    {
        int UpdateRow = 0, InsertDetail = 0, InsertChkDetail = 0;

        try
        {
            if (ViewState["EditID"] != null)
            {
                Entity_UserMaster.UserID = Convert.ToInt32(ViewState["EditID"]);
            }
            Entity_UserMaster.UserName  = TxtUserName.Text.Trim();
            Entity_UserMaster.LoginName = TxtUserId.Text.Trim();
            Entity_UserMaster.EmailId   = TxtMailId.Text.Trim();
            Entity_UserMaster.Password  = TxtPasswrod.Text.Trim();
            //  Entity_UserMaster.CafeteriaId = Convert.ToInt32(DDLCafe.SelectedValue);
            UpdateRow = Obj_UserMaster.UpdateUserDetails(ref Entity_UserMaster, out StrError);

            if (RadioIsAdmin.Text.Equals("T"))
            {
                Entity_UserMaster.IsAdmin  = true;
                Entity_UserMaster.UserType = "Admin";
            }
            if (RadioIsAdmin.Text.Equals("F"))
            {
                Entity_UserMaster.IsAdmin  = false;
                Entity_UserMaster.UserType = "User";
            }
            Entity_UserMaster.LUserID   = Convert.ToInt32(Session["UserId"]);
            Entity_UserMaster.LoginDate = DateTime.Now;

            UpdateRow = Obj_UserMaster.UpdateUserDetails(ref Entity_UserMaster, out StrError);
            if (UpdateRow != 0)
            {
                for (int i = 0; i < GridUserRight.Rows.Count; i++)
                {
                    Label    LblFormName   = (Label)GridUserRight.Rows[i].FindControl("LblFormName");
                    CheckBox GrdAddRight   = (CheckBox)GridUserRight.Rows[i].FindControl("GrdAddRight");
                    CheckBox GrdViewRight  = (CheckBox)GridUserRight.Rows[i].FindControl("GrdViewRight");
                    CheckBox GrdEditRight  = (CheckBox)GridUserRight.Rows[i].FindControl("GrdEditRight");
                    CheckBox GrdDelRight   = (CheckBox)GridUserRight.Rows[i].FindControl("GrdDelRight");
                    CheckBox GrdPrintRight = (CheckBox)GridUserRight.Rows[i].FindControl("GrdPrintRight");

                    Entity_UserMaster.FkUserId    = Convert.ToInt32(ViewState["EditID"]);
                    Entity_UserMaster.FormCaption = LblFormName.Text.Trim();
                    Entity_UserMaster.ViewAuth    = GrdViewRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                    Entity_UserMaster.AddAuth = GrdAddRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                    Entity_UserMaster.DelAuth = GrdDelRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                    Entity_UserMaster.EditAuth = GrdEditRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                    Entity_UserMaster.PrintAuth = GrdPrintRight.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                    UpdateRow = Obj_UserMaster.InsertUserAuthDetails(ref Entity_UserMaster, out StrError);
                }

                for (int i = 0; i < GridUser.Rows.Count; i++)
                {
                    Label    LblFormName         = (Label)GridUser.Rows[i].Cells[3].FindControl("LblFormName");
                    CheckBox GrdUserAllHeaderAll = (CheckBox)GridUser.Rows[i].Cells[1].FindControl("GrdUserAllHeaderAll");

                    Entity_UserMaster.FkUserId    = Convert.ToInt32(ViewState["EditID"]);
                    Entity_UserMaster.FormCaption = LblFormName.Text.Trim();
                    Entity_UserMaster.Email       = GrdUserAllHeaderAll.Checked == true?Convert.ToBoolean(1) : Convert.ToBoolean(0);

                    InsertDetail = Obj_UserMaster.InsertUserEmailDetail(ref Entity_UserMaster, out StrError);
                }
                for (int i = 0; i < ChkSite.Items.Count; i++)
                {
                    Entity_UserMaster.FkUserId    = Convert.ToInt32(ViewState["EditID"]);
                    Entity_UserMaster.CafeteriaId = Convert.ToInt32(ChkSite.Items[i].Value);
                    if (ChkSite.Items[i].Selected)
                    {
                        Entity_UserMaster.Cheked = true;
                    }
                    else
                    {
                        Entity_UserMaster.Cheked = false;
                    }
                    InsertChkDetail = Obj_UserMaster.InsertUserSiteDetail(ref Entity_UserMaster, out StrError);
                }
                #region [FOR SETTING ]---------------
                if (CHKYESEDITPO.Checked == true)
                {
                    InsertChkDetail = Obj_UserMaster.InsertUserPermissionForEditPO(Convert.ToInt32(ViewState["EditID"]), "Edit Authorised Purchase Order", 1, TXTPASSEDITPO.Text.Trim(), out StrError);
                }
                if (CHKYESUNITCONVERSION.Checked == true)
                {
                    InsertChkDetail = Obj_UserMaster.InsertUserPermissionForEditPO(Convert.ToInt32(ViewState["EditID"]), "Unit Conversion In Item Master", 1, TXTPASSEDITPO.Text.Trim(), out StrError);
                }
                if (CHKESCESSREPORT.Checked == true)
                {
                    InsertChkDetail = Obj_UserMaster.InsertUserPermissionForEditPO(Convert.ToInt32(ViewState["EditID"]), "Purchase Order Shortage/Excess Report", 1, TXTEXCESSREPORT.Text.Trim(), out StrError);
                }
                #endregion ---------------------------
                if (UpdateRow != 0)
                {
                    Obj_Comm.ShowPopUpMsg("Record Updated Successfully!!", this.Page);
                    MakeEmptyForm();
                    Entity_UserMaster = null;
                    Obj_Comm          = null;
                }
            }
        }
        catch (Exception ex)
        {
            StrError = ex.Message;
        }
    }