Пример #1
0
        protected void btnAddUserRole_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (PersonelAutoComplete.IDUser == "" || PersonelAutoComplete.IDUser == Guid.Empty.ToString())
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Succsess", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> لطفا کاربر مورد نظر را انتخاب کنید!</p>\",title: \"<p style='text-align:right;direction:rtl'>خطا</p>\"});", true);
                    return;
                }
                DataSet dsCheck = (DataSet)Session["dsUserRole"];
                int     Check   = dsCheck.Tables[0].Select("IDUser = '******' ").Count();
                if (Check == 0)
                {
                    ViewModel.tblUserRole newUserRole = new ViewModel.tblUserRole();
                    newUserRole.IDUser = PersonelAutoComplete.IDUser.StringToGuid();
                    newUserRole.IDRole = hfIdRole.Value.StringToGuid();
                    switch (hfMode.Value)
                    {
                    case "New":
                        try
                        {
                            newUserRole.IDUserRole = Guid.NewGuid();
                            bool ret = BisUserRole.AddUserRole(newUserRole);
                            if (ret)
                            {
                                fillGrdUserRole(hfIdRole.Value.StringToGuid());
                                NewFildsUserRole();
                                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Succsess", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> اطلاعات با موفقیت ثبت شد!</p>\",title: \"<p style='text-align:right;direction:rtl'>ثبت اطلاعات</p>\"});", true);
                            }
                            else
                            {
                                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Succsess", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> اشکال در ثبت اطلاعات!</p>\",title: \"<p style='text-align:right;direction:rtl'>خطا</p>\"});", true);
                            }
                        }
                        catch
                        {
                            ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Succsess", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> اشکال در برقراری ارتباط با دیتابیس!</p>\",title: \"<p style='text-align:right;direction:rtl'>خطا</p>\"});", true);
                        }

                        break;
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Succsess", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> این کاربر برای نقش " + lblRoleForUser.Text + " قبلا انتخاب شده است!</p>\",title: \"<p style='text-align:right;direction:rtl'>خطا</p>\"});", true);
                    NewFildsUserRole();
                }
            }
        }
Пример #2
0
        protected void grdUserRole_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Guid IDUserRole = e.CommandArgument.ToString().StringToGuid();

            switch (e.CommandName)
            {
            case "Del":
                try
                {
                    ViewModel.Search SearchUser = new ViewModel.Search();
                    SearchUser.Filter = " And tblUserRole.IDUserRole = '" + IDUserRole + "'";
                    DataSet dsUserRole = BisUserRole.GetUserRoleData(SearchUser);
                    if (dsUserRole.ReturnDataSetField("Developer") == "True" && dsUser.ReturnDataSetField("Developer") != "True")
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Succsess", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'>تیم برنامه نویس را نمی توانید حذف کنید!</p>\",title: \"<p style='text-align:right;direction:rtl'>خطا</p>\"});", true);
                        return;
                    }

                    ViewModel.tblUserRole DeleteUserRole = new ViewModel.tblUserRole();
                    DeleteUserRole.IDUserRole = IDUserRole;
                    DeleteUserRole.IDRole     = hfIdRole.Value.StringToGuid();
                    bool ret = BisUserRole.DeleteUserRole(DeleteUserRole);
                    if (ret)
                    {
                        fillGrdUserRole(hfIdRole.Value.StringToGuid());
                        NewFildsUserRole();
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Succsess", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> حذف با موفقیت انجام شد!</p>\",title: \"<p style='text-align:right;direction:rtl'>حذف اطلاعات</p>\"});", true);
                    }
                }
                catch
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Succsess", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> اشکال در برقراری ارتباط با دیتابیس!</p>\",title: \"<p style='text-align:right;direction:rtl'>خطا</p>\"});", true);
                }
                break;
            }
        }
Пример #3
0
 public bool AddUserRole(ViewModel.tblUserRole UserRole)
 {
     return(sqlHelper.RunProcedure("sp_tblUserRole_Insert", UserRole) > 0);
 }
Пример #4
0
 public bool DeleteUserRole(ViewModel.tblUserRole UserRole)
 {
     return(sqlHelper.RunProcedure("sp_tblUserRole_DeleteRow", UserRole, true) > 0);
 }
Пример #5
0
 public DataSet GetPersonelNameInUserRole(ViewModel.tblUserRole UserRole)
 {
     return(sqlHelper.returnDataSet("sp_tblUserRole_GetPersonelNameWithUnicRoleName", UserRole));
 }