Esempio n. 1
0
        protected void btnChangePassword_Click(object sender, EventArgs e)
        {
            try
            {
                divMessageChangePass.Visible = false;
                DataSet dsUser = new DataSet();
                dsUser = (DataSet)Session["User"];

                if (dsUser.ReturnDataSetField("Password").DecryptString() == txtOldpass.Text)
                {
                    ViewModel.tblPersonel updatePersonel = new ViewModel.tblPersonel();
                    updatePersonel.Password = txtNewPass.Text.EncryptData();
                    updatePersonel.IDUser   = dsUser.ReturnDataSetField("IDUser").StringToGuid();
                    bool ret = BisPersonel.UpdatePersonelChangePass(updatePersonel);
                    if (ret)
                    {
                        divMessageChangePass.Visible = true;
                        lblMessageChangePass.Text    = " کلمه عبور ویرایش شد. ";
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ErrorMessage", "alert('اشکال درتغییر کلمه عبور!');", true);
                    }
                }
                else
                {
                    divMessageChangePass.Visible = true;
                    lblMessageChangePass.Text    = " کلمه عبور فعلی اشتباه است. ";
                }
            }
            catch
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ErrorMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true);
            }
        }
Esempio n. 2
0
        protected void btLogin_Click(object sender, EventArgs e)
        {
            try
            {
                ViewModel.tblPersonel newPersonel = new ViewModel.tblPersonel();
                newPersonel.UserName = txtUserName.Text.FixFarsi();
                newPersonel.Password = txtPassword.Text.FixFarsi().EncryptData();
                DataSet dsLogin = BisPersonel.Login(newPersonel);
                if (dsLogin.Null_Ds())
                {
                    lblMessage.Text = "نام کاربری یا کلمه عبور صحیح نیست. ";
                }
                else
                {
                    Session["User"] = dsLogin;
                    Response.Cookies["UserName"].Value = dsLogin.ReturnDataSetField("UserName");
                    ViewModel.tblLogUser NewlogUser = new ViewModel.tblLogUser();
                    NewlogUser.IDLogUser   = Guid.NewGuid();
                    NewlogUser.IDRet       = Guid.Empty;
                    NewlogUser.UserAction  = "login";
                    NewlogUser.IDUser      = dsLogin.ReturnDataSetField("IDUser").StringToGuid();
                    NewlogUser.IDTableName = Guid.Empty;
                    bool ret = BislogUser.AddLogUser(NewlogUser);

                    Response.Cookies["IDLogUser"].Value = NewlogUser.IDLogUser.ToString();
                    Response.Redirect("Default.aspx");
                }
            }
            catch { }
        }
Esempio n. 3
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                ViewModel.tblPersonel newPersonel = new ViewModel.tblPersonel();
                //tblUser
                newPersonel.IDCity       = Guid.Empty;
                newPersonel.UserName     = txtUserName.Text.FixFarsi();
                newPersonel.Password     = txtPassword.Text.FixFarsi().EncryptData();
                newPersonel.Email        = txtEmail.Text.FixFarsi();
                newPersonel.Address      = "";
                newPersonel.WebSite      = "";
                newPersonel.PersonelType = true;
                newPersonel.Status       = 1;
                //tblPersonel
                newPersonel.FName = txtFName.Text.FixFarsi();
                newPersonel.LName = txtLName.Text.FixFarsi();
                newPersonel.IDOrganizationPosition = Guid.Empty;
                newPersonel.Active         = chkActive.Checked;
                newPersonel.PowerUser      = chkPowerUser.Checked;
                newPersonel.IdentifyNumber = txtIdentifyNumber.Text.FixFarsi();
                newPersonel.NationalCode   = txtNationalCode.Text.FixFarsi();

                switch (hfMode.Value)
                {
                case "New":
                    try
                    {
                        if (fulPicUrl.FileName != "")
                        {
                            string url = UploadImage(Server.MapPath("../Picture/User/"), "Picture/User/", fulPicUrl);
                            if (url != "")
                            {
                                newPersonel.PicUrl = url;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            newPersonel.PicUrl = "";
                        }
                        DataSet dsCheckUserName = (DataSet)Session["User"];
                        int     ChekUserCount   = dsCheckUserName.Tables[0].Select("UserName = '******'").Count();
                        if (ChekUserCount == 0)
                        {
                            newPersonel.IDUser = Guid.NewGuid();
                            bool ret = BisPersonel.AddPersonel(newPersonel);
                            if (ret)
                            {
                                newFields();
                                hfMode.Value   = "New";
                                hfIdUser.Value = newPersonel.IDUser.ToString();
                                ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اطلاعات ثبت شد!');", true);
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در ثبت اطلاعات!');", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('نام کاربری وارد شده تکراری است');", true);
                        }
                    }
                    catch
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true);
                    }

                    break;

                case "Edit":
                    try
                    {
                        if (fulPicUrl.FileName != "")
                        {
                            string url = UploadImage(Server.MapPath("../Picture/User/"), "Picture/User/", fulPicUrl);
                            if (url != "")
                            {
                                newPersonel.PicUrl = url;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            newPersonel.PicUrl = Session["OldUrlRegister"].ToString();
                        }

                        newPersonel.IDUser = hfIdUser.Value.StringToGuid();
                        bool result = BisPersonel.UpdatePersonel(newPersonel);
                        if (result)
                        {
                            hfMode.Value = "New";
                            newFields();
                            if (Session["OldUrlRegister"] != "" && fulPicUrl.FileName != "")
                            {
                                File.Delete(Server.MapPath("../" + Session["OldUrlRegister"].ToString()));
                            }
                            Session.Remove("OldUrlRegister");
                            imgUser.Visible = false;
                            ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اطلاعات ویرایش شد!');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در ویرایش اطلاعات!');", true);
                        }
                    }
                    catch
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true);
                    }

                    break;
                }
            }
        }
Esempio n. 4
0
 public bool DeletePersonel(ViewModel.tblPersonel personel)
 {
     return(sqlHelper.RunProcedure("sp_tblPersonel_DeleteRow", personel) > 0);
 }
Esempio n. 5
0
 public bool UpdatePersonelChangePass(ViewModel.tblPersonel personel)
 {
     return(sqlHelper.RunProcedure("sp_tblPersonelChangePass_Update", personel) > 0);
 }
Esempio n. 6
0
 public bool AddPersonel(ViewModel.tblPersonel personel)
 {
     return(sqlHelper.RunProcedure("sp_tblPersonel_Insert", personel) > 0);
 }
Esempio n. 7
0
 public DataSet Login(ViewModel.tblPersonel personel)
 {
     return(sqlHelper.returnDataSet("sp_tblPersonel_Login", personel));
 }