예제 #1
0
        public void Update(HPS.BLL.UserBLL.BLLUser_T businessObject, HPS.BLL.UserBLL.BLLUser_TKeys businessObjectKey)
        {
            try
            {
                if (businessObject.UserName_nvc == businessObjectKey.UserName_nvc)
                {
                    if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueUserName_nvc") == false)
                    {
                        throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString());
                    }
                }
                else
                {
                    if (businessObject.IsValid() == false)
                    {
                        throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString());
                    }
                }

                _dataObject.Update(businessObject, businessObjectKey);
            }
            catch (System.Exception ex)
            {
                throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this);
            }
        }
예제 #2
0
        public HPS.BLL.UserBLL.BLLUser_T SelectByPrimaryKey(HPS.BLL.UserBLL.BLLUser_TKeys businessObjectKey)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

            this.Command.CommandText = "[sp_User_T_SelectByPrimaryKey]";
            this.Command.CommandType = CommandType.StoredProcedure;

            try
            {
                this.Command.Parameters.Clear();

                SqlParameter UserName_nvc = new SqlParameter();
                UserName_nvc.ParameterName = "@UserName_nvc";
                UserName_nvc.SqlDbType     = SqlDbType.NVarChar;
                UserName_nvc.Direction     = ParameterDirection.Input;
                UserName_nvc.IsNullable    = false;
                UserName_nvc.Value         = businessObjectKey.UserName_nvc;
                this.Command.Parameters.Add(UserName_nvc);



                if (ControlConnection)
                {
                    this.BeginTransaction();
                }

                IDataReader dataReader = this.Command.ExecuteReader();
                HPS.BLL.UserBLL.BLLUser_T businessObject = new HPS.BLL.UserBLL.BLLUser_T();
                if (dataReader.Read())
                {
                    PopulateBusinessObjectFromReader(businessObject, dataReader);
                }
                else
                {
                    businessObject = null;
                }

                if (dataReader.IsClosed == false)
                {
                    dataReader.Close();
                }


                if (ControlConnection)
                {
                    this.Commit();
                }
                return(businessObject);
            }
            catch (System.Exception ex)
            {
                if (ControlConnection)
                {
                    this.RollBack();
                }
                throw ex;
            }
        }
예제 #3
0
        public List <HPS.BLL.UserBLL.BLLUser_T> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <HPS.BLL.UserBLL.BLLUser_T> list = new List <HPS.BLL.UserBLL.BLLUser_T>();

            while (dataReader.Read())
            {
                HPS.BLL.UserBLL.BLLUser_T businessObject = new HPS.BLL.UserBLL.BLLUser_T();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
예제 #4
0
        private void AcceptButton_Click(object sender, EventArgs e)
        {
            try
            {
                HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
                Hepsa.Core.BLL.BLLUserLogin_T    UserLogin   = new Hepsa.Core.BLL.BLLUserLogin_T();
                UserLogin.UserName_nvc = this.UserName_nvcTextBox.Text;
                UserLogin.Password_nvc = Hepsa.Core.Common.Security.MD5(this.Password_nvcTextBox.Text);
                HPS.BLL.UserBLL.BLLUser_T UserEntity = UserFactory.Login(UserLogin);
                var OnlineUserEntity  = new HPS.BLL.OnlineUserBLL.BLLOnlineUser_T();
                var OnlineUserFactory = new HPS.BLL.OnlineUserBLL.BLLOnlineUser_TFactory();
                if (!CheckComputerRegistration(UserEntity))
                {
                    throw new ApplicationException("این کامپیوتر مجاز به استفاده از سیستم نمی باشد");
                }

                if (UserEntity != null)
                {
                    HPS.Common.CurrentUser.user = UserEntity;
                    if (Hepsa.Core.Common.ApplicationInfo.MainForm != null)
                    {
                        this.SaveSetting();
                        this.makeLog();
                        //--hp>

                        var onlineUsertable = new DataTable();
                        OnlineUserFactory.GetAllByCondition(string.Format("[OnlineUser_T].[UserName_nvc]='{0}' and LoginDate_vc='{1}' AND LogOutDate_vc IS NULL ", HPS.Common.CurrentUser.user.UserName_nvc, OnlineUserFactory.ServerJalaliDate), ref onlineUsertable);
                        if (onlineUsertable != null && onlineUsertable.Rows.Count > 1 && (UserEntity.MultiAccess_bit == false))
                        {
                            throw new ApplicationException("حساب کاربری شما در سیستم دیگر در حال استفاده می باشد ");
                        }
                        //--<hp
                        OnlineUserEntity.UserName_nvc   = UserEntity.UserName_nvc;
                        OnlineUserEntity.LoginDate_vc   = OnlineUserFactory.ServerJalaliDate;
                        OnlineUserEntity.LoginTime_vc   = OnlineUserFactory.ServerTime;
                        OnlineUserEntity.MacAddress_nvc = Hepsa.Core.Common.ApplicationInfo.MacAddress;
                        OnlineUserFactory.Insert(OnlineUserEntity);
                        HPS.Common.CurrentUser.user.OnlineUserID_int = OnlineUserEntity.OnlineUserID_int;

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }
예제 #5
0
        public void Insert(HPS.BLL.UserBLL.BLLUser_T businessObject)
        {
            try
            {
                if (businessObject.IsValid() == false)
                {
                    throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString());
                }

                _dataObject.Insert(businessObject);
            }
            catch (System.Exception ex)
            {
                throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this);
            }
        }
예제 #6
0
        private bool CheckComputerRegistration(HPS.BLL.UserBLL.BLLUser_T user)
        {
            if (!((new HPS.BLL.SettingsBLL.BLLSetting_TFactory()).GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
            {
                SettingID_int = 1028
            }).Value_nvc == "1"))
            {
                return(true);
            }
            HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory();
            //TODO: فیلد پاک شده بررسی نمیشد
            string ComputerCondition = "[Computer_T].[MacAddress_nvc]='" + Hepsa.Core.Common.ApplicationInfo.MacAddress + "' and [Computer_T].[Computer_nvc]='" + user.UserName_nvc + "' and [Computer_T].[active_bit]=1 and Deleted_bit=0";
            List <HPS.BLL.ComputerBLL.BLLComputer_T> ComputerList = ComputerFactory.GetAllByCondition(ComputerCondition);

            if (ComputerList != null && ComputerList.Count > 0)
            {
                return(true);
            }
            return(false);
        }
예제 #7
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);
        }
예제 #8
0
        public void Update(HPS.BLL.UserBLL.BLLUser_T businessObject, HPS.BLL.UserBLL.BLLUser_TKeys businessObjectKey)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

            this.Command.CommandText = "[sp_User_T_Update]";
            this.Command.CommandType = CommandType.StoredProcedure;

            try
            {
                this.Command.Parameters.Clear();

                SqlParameter UserName_nvc = new SqlParameter();
                UserName_nvc.ParameterName = "@UserName_nvc";
                UserName_nvc.SqlDbType     = SqlDbType.NVarChar;
                UserName_nvc.Direction     = ParameterDirection.Input;
                UserName_nvc.IsNullable    = false;
                UserName_nvc.Value         = businessObject.UserName_nvc;
                this.Command.Parameters.Add(UserName_nvc);

                SqlParameter FullName_nvc = new SqlParameter();
                FullName_nvc.ParameterName = "@FullName_nvc";
                FullName_nvc.SqlDbType     = SqlDbType.NVarChar;
                FullName_nvc.Direction     = ParameterDirection.Input;
                FullName_nvc.IsNullable    = true;
                if (String.IsNullOrEmpty(businessObject.FullName_nvc))
                {
                    FullName_nvc.Value = DBNull.Value;
                }
                else
                {
                    FullName_nvc.Value = businessObject.FullName_nvc;
                }
                this.Command.Parameters.Add(FullName_nvc);

                SqlParameter Password_nvc = new SqlParameter();
                Password_nvc.ParameterName = "@Password_nvc";
                Password_nvc.SqlDbType     = SqlDbType.NVarChar;
                Password_nvc.Direction     = ParameterDirection.Input;
                Password_nvc.IsNullable    = false;
                Password_nvc.Value         = businessObject.Password_nvc;
                this.Command.Parameters.Add(Password_nvc);

                SqlParameter StartDate_vc = new SqlParameter();
                StartDate_vc.ParameterName = "@StartDate_vc";
                StartDate_vc.SqlDbType     = SqlDbType.VarChar;
                StartDate_vc.Direction     = ParameterDirection.Input;
                StartDate_vc.IsNullable    = true;
                if (String.IsNullOrEmpty(businessObject.StartDate_vc))
                {
                    StartDate_vc.Value = DBNull.Value;
                }
                else
                {
                    StartDate_vc.Value = businessObject.StartDate_vc;
                }
                this.Command.Parameters.Add(StartDate_vc);

                SqlParameter ExpireDate_vc = new SqlParameter();
                ExpireDate_vc.ParameterName = "@ExpireDate_vc";
                ExpireDate_vc.SqlDbType     = SqlDbType.VarChar;
                ExpireDate_vc.Direction     = ParameterDirection.Input;
                ExpireDate_vc.IsNullable    = true;
                if (String.IsNullOrEmpty(businessObject.ExpireDate_vc))
                {
                    ExpireDate_vc.Value = DBNull.Value;
                }
                else
                {
                    ExpireDate_vc.Value = businessObject.ExpireDate_vc;
                }
                this.Command.Parameters.Add(ExpireDate_vc);

                SqlParameter UserGroupID_int = new SqlParameter();
                UserGroupID_int.ParameterName = "@UserGroupID_int";
                UserGroupID_int.SqlDbType     = SqlDbType.Int;
                UserGroupID_int.Direction     = ParameterDirection.Input;
                UserGroupID_int.IsNullable    = true;
                if (businessObject.UserGroupID_int.HasValue == false)
                {
                    UserGroupID_int.Value = DBNull.Value;
                }
                else
                {
                    UserGroupID_int.Value = businessObject.UserGroupID_int;
                }
                this.Command.Parameters.Add(UserGroupID_int);

                SqlParameter Picture_img = new SqlParameter();
                Picture_img.ParameterName = "@Picture_img";
                Picture_img.SqlDbType     = SqlDbType.Image;
                Picture_img.Direction     = ParameterDirection.Input;
                Picture_img.IsNullable    = true;
                if (businessObject.Picture_img == null || businessObject.Picture_img.Length == 0)
                {
                    Picture_img.Value = DBNull.Value;
                }
                else
                {
                    Picture_img.Value = businessObject.Picture_img;
                }
                this.Command.Parameters.Add(Picture_img);

                SqlParameter Active_bit = new SqlParameter();
                Active_bit.ParameterName = "@Active_bit";
                Active_bit.SqlDbType     = SqlDbType.Bit;
                Active_bit.Direction     = ParameterDirection.Input;
                Active_bit.IsNullable    = false;
                Active_bit.Value         = businessObject.Active_bit;
                this.Command.Parameters.Add(Active_bit);

                SqlParameter CreateDate_nvc = new SqlParameter();
                CreateDate_nvc.ParameterName = "@CreateDate_nvc";
                CreateDate_nvc.SqlDbType     = SqlDbType.NVarChar;
                CreateDate_nvc.Direction     = ParameterDirection.Input;
                CreateDate_nvc.IsNullable    = false;
                CreateDate_nvc.Value         = businessObject.CreateDate_nvc;
                this.Command.Parameters.Add(CreateDate_nvc);

                SqlParameter CreateTime_nvc = new SqlParameter();
                CreateTime_nvc.ParameterName = "@CreateTime_nvc";
                CreateTime_nvc.SqlDbType     = SqlDbType.NVarChar;
                CreateTime_nvc.Direction     = ParameterDirection.Input;
                CreateTime_nvc.IsNullable    = false;
                CreateTime_nvc.Value         = businessObject.CreateTime_nvc;
                this.Command.Parameters.Add(CreateTime_nvc);

                SqlParameter InfractionGroupID_int = new SqlParameter();
                InfractionGroupID_int.ParameterName = "@InfractionGroupID_int";
                InfractionGroupID_int.SqlDbType     = SqlDbType.Int;
                InfractionGroupID_int.Direction     = ParameterDirection.Input;
                InfractionGroupID_int.IsNullable    = true;
                if (businessObject.InfractionGroupID_int.HasValue == false)
                {
                    InfractionGroupID_int.Value = DBNull.Value;
                }
                else
                {
                    InfractionGroupID_int.Value = businessObject.InfractionGroupID_int;
                }
                this.Command.Parameters.Add(InfractionGroupID_int);


                SqlParameter CompanyID_int = new SqlParameter();
                CompanyID_int.ParameterName = "@CompanyID_int";
                CompanyID_int.SqlDbType     = SqlDbType.Int;
                CompanyID_int.Direction     = ParameterDirection.Input;
                CompanyID_int.IsNullable    = true;
                if (businessObject.CompanyID_int.HasValue == false)
                {
                    CompanyID_int.Value = DBNull.Value;
                }
                else
                {
                    CompanyID_int.Value = businessObject.CompanyID_int;
                }
                this.Command.Parameters.Add(CompanyID_int);


                SqlParameter pk_UserName_nvc = new SqlParameter();
                pk_UserName_nvc.ParameterName = "@pk_UserName_nvc";
                pk_UserName_nvc.SqlDbType     = SqlDbType.NVarChar;
                pk_UserName_nvc.Direction     = ParameterDirection.Input;
                pk_UserName_nvc.IsNullable    = false;
                pk_UserName_nvc.Value         = businessObjectKey.UserName_nvc;
                this.Command.Parameters.Add(pk_UserName_nvc);

                SqlParameter Mobile_nvc = new SqlParameter();
                Mobile_nvc.ParameterName = "Mobile_nvc";
                Mobile_nvc.Direction     = ParameterDirection.Input;
                Mobile_nvc.SqlDbType     = SqlDbType.NVarChar;
                Mobile_nvc.IsNullable    = true;
                if (string.IsNullOrEmpty(businessObject.Mobile_nvc))
                {
                    Mobile_nvc.Value = DBNull.Value;
                }
                else
                {
                    Mobile_nvc.Value = businessObject.Mobile_nvc;
                }
                this.Command.Parameters.Add(Mobile_nvc);

                //--hp>
                //MultiAccess_bit
                SqlParameter MultiAccess_bit = new SqlParameter();
                MultiAccess_bit.ParameterName = "@MultiAccess_bit";
                MultiAccess_bit.SqlDbType     = SqlDbType.Bit;
                MultiAccess_bit.Direction     = ParameterDirection.Input;
                MultiAccess_bit.IsNullable    = false;
                MultiAccess_bit.Value         = businessObject.MultiAccess_bit;
                this.Command.Parameters.Add(MultiAccess_bit);
                //--<hp


                if (ControlConnection)
                {
                    this.BeginTransaction();
                }

                this.Command.ExecuteNonQuery();

                if (ControlConnection)
                {
                    this.Commit();
                }
            }
            catch (System.Exception ex)
            {
                if (ControlConnection)
                {
                    this.RollBack();
                }
                throw ex;
            }
        }
예제 #9
0
        public void PopulateBusinessObjectFromReader(HPS.BLL.UserBLL.BLLUser_T businessObject, IDataReader dataReader)
        {
            businessObject.UserName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString()));
            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.FullName_nvc.ToString())) == false)
            {
                businessObject.FullName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.FullName_nvc.ToString()));
            }
            else
            {
                businessObject.FullName_nvc = String.Empty;
            }

            businessObject.Password_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.Password_nvc.ToString()));
            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.StartDate_vc.ToString())) == false)
            {
                businessObject.StartDate_vc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.StartDate_vc.ToString()));
            }
            else
            {
                businessObject.StartDate_vc = String.Empty;
            }

            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.ExpireDate_vc.ToString())) == false)
            {
                businessObject.ExpireDate_vc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.ExpireDate_vc.ToString()));
            }
            else
            {
                businessObject.ExpireDate_vc = String.Empty;
            }

            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.UserGroupID_int.ToString())) == false)
            {
                businessObject.UserGroupID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.UserGroupID_int.ToString()));
            }
            else
            {
                businessObject.UserGroupID_int = null;
            }

            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.Picture_img.ToString())) == false)
            {
                businessObject.Picture_img = (Byte[])dataReader.GetValue(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.Picture_img.ToString()));
            }
            else
            {
                businessObject.Picture_img = null;
            }

            businessObject.Active_bit     = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.Active_bit.ToString()));
            businessObject.CreateDate_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.CreateDate_nvc.ToString()));
            businessObject.CreateTime_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.CreateTime_nvc.ToString()));
            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.InfractionGroupID_int.ToString())) == false)
            {
                businessObject.InfractionGroupID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.InfractionGroupID_int.ToString()));
            }
            else
            {
                businessObject.InfractionGroupID_int = null;
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.CompanyID_int.ToString())) == false)
            {
                businessObject.CompanyID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.CompanyID_int.ToString()));
            }
            else
            {
                businessObject.CompanyID_int = null;
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.Mobile_nvc.ToString())) == false)
            {
                businessObject.Mobile_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.Mobile_nvc.ToString()));
            }
            else
            {
                businessObject.Mobile_nvc = string.Empty;
            }
            businessObject.MultiAccess_bit = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.UserBLL.BLLUser_T.User_TField.MultiAccess_bit.ToString()));
        }
예제 #10
0
        protected override void Insert()
        {
            HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
            if (String.IsNullOrEmpty(UserGroupID_intComboBox.Text))
            {
                throw new ApplicationException("لطفا گروه کاربری را انتخاب نمایید");
            }
            try
            {
                HPS.BLL.UserBLL.BLLUser_T UserEntity = new HPS.BLL.UserBLL.BLLUser_T();
                UserEntity.UserName_nvc          = Hepsa.Core.Common.PersentationController.GetEntityValue(UserName_nvcTextBox.Text, TypeCode.String).ToString();
                UserEntity.FullName_nvc          = Hepsa.Core.Common.PersentationController.GetEntityValue(FullName_nvcTextBox.Text, TypeCode.String).ToString();
                UserEntity.Password_nvc          = Hepsa.Core.Common.Security.MD5(Password_nvcTextBox.Text);
                UserEntity.ConfirmPassword_nvc   = Hepsa.Core.Common.Security.MD5(ConfirmPasswordTextBox.Text);
                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.CompanyID_int         = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(CompanyID_int, TypeCode.Int32) == 0 ? null : (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(CompanyID_int, TypeCode.Int32);
                UserEntity.Mobile_nvc            = Hepsa.Core.Common.PersentationController.GetEntityValue(this.Mobile_nvctextBox.Text, TypeCode.String).ToString();
                UserEntity.MultiAccess_bit       = MultiAccess_bitCheckBox.Checked;
                System.IO.MemoryStream Memorystream = new System.IO.MemoryStream();
                byte[] array;
                if (PictureBox.Image != null)
                {
                    PictureBox.Image.Save(Memorystream, PictureBox.Image.RawFormat);
                    array = Memorystream.ToArray();
                    UserEntity.Picture_img = array;
                }


                UserFactory.BeginProc();
                UserFactory.Insert(UserEntity);
                UserFactory.CommitProc();
                if (DataTable != null)
                {
                    DataRow dr = this.DataTable.NewRow();
                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString()]    = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.UserName_nvc, TypeCode.String);
                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.FullName_nvc.ToString()]    = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.FullName_nvc, TypeCode.String);
                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.Password_nvc.ToString()]    = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.Password_nvc, TypeCode.String);
                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.StartDate_vc.ToString()]    = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.StartDate_vc, TypeCode.String);
                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.ExpireDate_vc.ToString()]   = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.ExpireDate_vc, TypeCode.String);
                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.UserGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.UserGroupID_int, TypeCode.Int32);
                    dr["UserGroupID_intUserGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(UserGroupID_intComboBox);
                    if (UserEntity.Picture_img != null)
                    {
                        dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.Picture_img.ToString()] = (byte[])Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.Picture_img, TypeCode.Object);
                    }

                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.Active_bit.ToString()]            = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.Active_bit, TypeCode.Boolean);
                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.CreateDate_nvc.ToString()]        = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.CreateDate_nvc, TypeCode.String);
                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.CreateTime_nvc.ToString()]        = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.CreateTime_nvc, TypeCode.String);
                    dr[HPS.BLL.UserBLL.BLLUser_T.User_TField.InfractionGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UserEntity.InfractionGroupID_int, TypeCode.Int32);
                    dr["InfractionGroupID_intInfractionGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(InfractionGroupID_intComboBox);
                    dr["CompanyID_intCompany_nvc"] = Hepsa.Core.Common.PersentationController.GetEntityValue(Company_nvcTextBox.Text, TypeCode.String);
                    DataTable.Rows.Add(dr);
                    DataTable.AcceptChanges();
                }
                this.ClearForm(this);
            }
            catch (Exception ex)
            {
                UserFactory.RollBackProc();
                throw ex;
            }
        }
예제 #11
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;
            }
        }