Esempio n. 1
0
 private void UserName_nvcTextBox_Leave(object sender, EventArgs e)
 {
     try
     {
         UserName_nvcTextBox.Text = UserName_nvcTextBox.Text.Replace("ی", "ي").Replace("ک", "ك");
         if (YearComboBox.SelectedValue != null)
         {
             BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
             BLL.UserBLL.BLLUser_TKeys    UserKey     = new HPS.BLL.UserBLL.BLLUser_TKeys();
             UserKey.UserName_nvc = this.UserName_nvcTextBox.Text;
             BLL.UserBLL.BLLUser_T UserEntity = UserFactory.GetBy(UserKey);
             if (UserEntity != null)
             {
                 if (UserEntity.Picture_img != null)
                 {
                     System.IO.MemoryStream MemoryStream = new System.IO.MemoryStream();
                     MemoryStream.Write(UserEntity.Picture_img, 0, UserEntity.Picture_img.Length - 1);
                     UserPictureBox.Image = System.Drawing.Image.FromStream(MemoryStream);
                 }
             }
             else
             {
                 this.UserPictureBox.Image = Properties.Resources.Login;
             }
         }
     }
     catch (Exception ex)
     { throw ex; }
 }
Esempio n. 2
0
        protected override void ShowForm()
        {
            this.FillCombo();
            HPS.BLL.UserBLL.BLLUser_TFactory UserFactory  = new HPS.BLL.UserBLL.BLLUser_TFactory();
            HPS.BLL.UserBLL.BLLUser_T        UserEntity   = UserFactory.GetBy((HPS.BLL.UserBLL.BLLUser_TKeys)Key);
            System.IO.MemoryStream           memorystream = new System.IO.MemoryStream();
            if (UserEntity == null)
            {
                throw new HPS.Exceptions.UserNotFound();
            }
            if (UserEntity.Picture_img != null)
            {
                memorystream.Write(UserEntity.Picture_img, 0, UserEntity.Picture_img.Length);
                PictureBox.Image = System.Drawing.Image.FromStream(memorystream);
            }
            else
            {
                PictureBox.Image = HPS.Properties.Resources.user;
            }
            UserName_nvcTextBox.Text    = Hepsa.Core.Common.PersentationController.GetEntityValue(UserEntity.UserName_nvc, TypeCode.String).ToString();
            FullName_nvcTextBox.Text    = Hepsa.Core.Common.PersentationController.GetEntityValue(UserEntity.FullName_nvc, TypeCode.String).ToString();
            Password_nvcTextBox.Text    = Hepsa.Core.Common.PersentationController.GetEntityValue(UserEntity.Password_nvc, TypeCode.String).ToString();
            ConfirmPasswordTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(UserEntity.Password_nvc, TypeCode.String).ToString();
            StartDate_vcTextBox.Text    = Hepsa.Core.Common.PersentationController.GetEntityValue(UserEntity.StartDate_vc, TypeCode.String).ToString();
            ExpireDate_vcTextBox.Text   = Hepsa.Core.Common.PersentationController.GetEntityValue(UserEntity.ExpireDate_vc, TypeCode.String).ToString();
            Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref UserGroupID_intComboBox, UserEntity.UserGroupID_int, TypeCode.Int32);
            Active_bitCheckBox.Checked = (bool)Hepsa.Core.Common.PersentationController.GetEntityValue(UserEntity.Active_bit, TypeCode.Boolean);
            Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref InfractionGroupID_intComboBox, UserEntity.InfractionGroupID_int, TypeCode.Int32);
            this.Mobile_nvctextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(UserEntity.Mobile_nvc, TypeCode.String).ToString();

            if (UserEntity.CompanyID_int != null)
            {
                CompanyID_int = UserEntity.CompanyID_int;
                BLL.CompanyBLL.BLLCompany_TKeys key = new BLL.CompanyBLL.BLLCompany_TKeys();
                key.CompanyID_int = Convert.ToInt32(UserEntity.CompanyID_int);
                BLL.CompanyBLL.BLLCompany_TFactory CompanyFactory = new BLL.CompanyBLL.BLLCompany_TFactory();
                var Company = CompanyFactory.GetBy(key);
                Company_nvcTextBox.Text = Company.Company_nvc;
            }
            MultiAccess_bitCheckBox.Checked = (bool)Hepsa.Core.Common.PersentationController.GetEntityValue(UserEntity.MultiAccess_bit, TypeCode.Boolean);
        }
Esempio n. 3
0
        protected override void Edit()
        {
            HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();

            try
            {
                HPS.BLL.UserBLL.BLLUser_T UserEntity = UserFactory.GetBy((HPS.BLL.UserBLL.BLLUser_TKeys) this.Key);
                UserEntity.UserName_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(UserName_nvcTextBox.Text, TypeCode.String).ToString();
                if (Password_nvcTextBox.Text == UserEntity.Password_nvc)
                {
                    UserEntity.Password_nvc = Password_nvcTextBox.Text;
                }
                else
                {
                    UserEntity.Password_nvc = Hepsa.Core.Common.Security.MD5(Password_nvcTextBox.Text);
                }
                if (ConfirmPasswordTextBox.Text == UserEntity.Password_nvc)
                {
                    UserEntity.ConfirmPassword_nvc = ConfirmPasswordTextBox.Text;
                }
                else
                {
                    UserEntity.ConfirmPassword_nvc = Hepsa.Core.Common.Security.MD5(ConfirmPasswordTextBox.Text);
                }
                UserEntity.FullName_nvc          = Hepsa.Core.Common.PersentationController.GetEntityValue(FullName_nvcTextBox.Text, TypeCode.String).ToString();
                UserEntity.StartDate_vc          = Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(StartDate_vcTextBox).ToString();
                UserEntity.ExpireDate_vc         = Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(ExpireDate_vcTextBox).ToString();
                UserEntity.UserGroupID_int       = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(UserGroupID_intComboBox.SelectedValue, TypeCode.Int32);
                UserEntity.Active_bit            = Active_bitCheckBox.Checked;
                UserEntity.CreateDate_nvc        = UserFactory.ServerJalaliDate;
                UserEntity.CreateTime_nvc        = UserFactory.ServerTime;
                UserEntity.InfractionGroupID_int = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(InfractionGroupID_intComboBox.SelectedValue, TypeCode.Int32);
                UserEntity.Mobile_nvc            = Hepsa.Core.Common.PersentationController.GetEntityValue(this.Mobile_nvctextBox.Text, TypeCode.String).ToString();


                UserEntity.MultiAccess_bit = MultiAccess_bitCheckBox.Checked;
                UserEntity.CompanyID_int   = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(CompanyEntity.CompanyID_int, TypeCode.Int32);
                if (CompanyID_int != 0)
                {
                    UserEntity.CompanyID_int = CompanyID_int;
                }
                else
                {
                    if (UserEntity.UserGroupID_int.Value == 14)
                    {
                        throw new ApplicationException("شرکت انتخاب نشده است");
                    }
                    UserEntity.CompanyID_int = null;
                }

                System.IO.MemoryStream Memorystream = new System.IO.MemoryStream();
                byte[] array;
                PictureBox.Image.Save(Memorystream, PictureBox.Image.RawFormat);
                array = Memorystream.ToArray();
                UserEntity.Picture_img = array;


                if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true)
                {
                    UserFactory.BeginProc();
                    UserFactory.Update(UserEntity, (HPS.BLL.UserBLL.BLLUser_TKeys)Key);
                    UserFactory.CommitProc();
                    if (DataTable != null)
                    {
                        DataRow[] dr = DataTable.Select(HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString() + "='" + ((HPS.BLL.UserBLL.BLLUser_TKeys)Key).UserName_nvc.ToString() + "'");
                        if (dr.Length > 0)
                        {
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString()]          = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.UserName_nvc, TypeCode.String);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.FullName_nvc.ToString()]          = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.FullName_nvc, TypeCode.String);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.Password_nvc.ToString()]          = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.Password_nvc, TypeCode.String);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.StartDate_vc.ToString()]          = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.StartDate_vc, TypeCode.String);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.ExpireDate_vc.ToString()]         = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.ExpireDate_vc, TypeCode.String);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.UserGroupID_int.ToString()]       = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.UserGroupID_int, TypeCode.Int32);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.Active_bit.ToString()]            = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.Active_bit, TypeCode.Boolean);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.CreateDate_nvc.ToString()]        = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.CreateDate_nvc, TypeCode.String);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.CreateTime_nvc.ToString()]        = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.CreateTime_nvc, TypeCode.String);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.InfractionGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.InfractionGroupID_int, TypeCode.Int32);
                            dr[0][HPS.BLL.UserBLL.BLLUser_T.User_TField.CompanyID_int.ToString()]         = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.CompanyID_int, TypeCode.Int32);
                        }
                        DataTable.AcceptChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                UserFactory.RollBackProc();
                throw ex;
            }
        }