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

        try
        {
            if (Check() == true)
            {
                //DS = Obj_UserMaster.ChkDuplicate(TxtUserName.Text.Trim(), out StrError);
                //if (DS.Tables[0].Rows.Count > 0)
                //{
                //    Obj_Comm.ShowPopUpMsg("Please Enter Another Name !!!", this.Page);
                //    TxtUserName.Focus();
                //}
                //else
                //{
                Entity_UserMaster.UserName  = TxtUserName.Text;
                Entity_UserMaster.LoginName = txtUser.Text;
                Entity_UserMaster.EmailId   = TxtEmailid.Text;
                Entity_UserMaster.Password  = txtpassword.Text;

                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.Today;
                Entity_UserMaster.IsDeleted = false;

                InsertRow = obj_DMUserMaster.InsertUserDetails(ref Entity_UserMaster, out StrError);

                if (InsertRow > 0)
                {
                    int ID = InsertRow;
                    for (int i = 0; i < GridUserRight.Rows.Count; i++)
                    {
                        Label    LblFromName   = (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 = ID;
                        Entity_UserMaster.FormName = LblFromName.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.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 (InsertRow > 0)
                    {
                        obj_Comman.ShowPopUpMsg("Record Saved Successfully..!", this.Page);
                        MakeEmptyform();
                        Entity_UserMaster = null;
                        obj_Comman        = null;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
Ejemplo n.º 2
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        int InsertRow = 0, InsertDetail = 0, InsertChkDetail = 0;

        try
        {
            if (CHECKVALIDATION() == true)
            {
                DS = Obj_UserMaster.ChkDuplicate(TxtUserName.Text.Trim(), out StrError);
                if (DS.Tables[0].Rows.Count > 0)
                {
                    Obj_Comm.ShowPopUpMsg("Please Enter Another Name !!!", this.Page);
                    TxtUserName.Focus();
                }
                else
                {
                    Entity_UserMaster.UserName  = TxtUserName.Text;
                    Entity_UserMaster.EmailId   = TxtMailId.Text;
                    Entity_UserMaster.LoginName = TxtUserId.Text;
                    // Entity_UserMaster.CafeteriaId=Convert.ToInt32(DDLCafe.SelectedValue);
                    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;
                    Entity_UserMaster.IsDeleted = false;

                    Entity_UserMaster.Password = TxtPasswrod.Text;
                    InsertRow = Obj_UserMaster.InsertUserDetails(ref Entity_UserMaster, out StrError);
                    if (InsertRow != 0)
                    {
                        int ID = InsertRow;
                        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].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    = ID;
                            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);

                            InsertRow = 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    = ID;
                            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    = ID;
                            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(ID, "Edit Authorised Purchase Order", 1, TXTPASSEDITPO.Text.Trim(), out StrError);
                        }
                        if (CHKYESUNITCONVERSION.Checked == true)
                        {
                            InsertChkDetail = Obj_UserMaster.InsertUserPermissionForEditPO(ID, "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 (InsertRow != 0)
                        {
                            Obj_Comm.ShowPopUpMsg("Record Saved Successfully!!", this.Page);
                            MakeEmptyForm();
                            Entity_UserMaster = null;
                            Obj_Comm          = null;
                        }
                    }
                }
            }
            else
            {
                Obj_Comm.ShowPopUpMsg("Please Fill Data For Save Record....Site Must Be Select..", this.Page);
            }
        }
        catch (Exception ex)
        {
            StrError = ex.Message;
        }
    }