コード例 #1
0
        private void FillCombo()
        {
            try
            {
                HPS.BLL.UserBLL.BLLUser_TFactory UserName_nvcFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
                DataTable UserName_nvcDataTable = new DataTable();
                UserName_nvcFactory.GetAll(ref UserName_nvcDataTable);
                this.UserName_nvcComboBox.DisplayMember = HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString();
                this.UserName_nvcComboBox.ValueMember   = HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString();
                this.UserName_nvcComboBox.DataSource    = UserName_nvcDataTable;
                this.UserName_nvcComboBox.SelectedIndex = -1;

                HPS.BLL.InfractionSurveyGroupBLL.BLLInfractionSurveyGroup_TFactory InfractionSurveyGroupID_intFactory = new HPS.BLL.InfractionSurveyGroupBLL.BLLInfractionSurveyGroup_TFactory();
                DataTable InfractionSurveyGroupID_intDataTable = new DataTable();
                InfractionSurveyGroupID_intFactory.GetAll(ref InfractionSurveyGroupID_intDataTable);
                this.InfractionSurveyGroupID_intComboBox.DisplayMember = HPS.BLL.InfractionSurveyGroupBLL.BLLInfractionSurveyGroup_T.InfractionSurveyGroup_TField.InfractionSurveyGroup_nvc.ToString();
                this.InfractionSurveyGroupID_intComboBox.ValueMember   = HPS.BLL.InfractionSurveyGroupBLL.BLLInfractionSurveyGroup_T.InfractionSurveyGroup_TField.InfractionSurveyGroupID_int.ToString();
                this.InfractionSurveyGroupID_intComboBox.DataSource    = InfractionSurveyGroupID_intDataTable;
                this.InfractionSurveyGroupID_intComboBox.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();

            try
            {
                if (Hepsa.Core.Common.MessageBox.ConfirmDeleteMessage() == false)
                {
                    return;
                }


                HPS.BLL.UserBLL.BLLUser_TFactory User_TFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
                HPS.BLL.UserBLL.BLLUser_TKeys    UserKey       = new HPS.BLL.UserBLL.BLLUser_TKeys();

                UserKey.UserName_nvc = (String)UserGridView.CurrentRow.Cells["colUserName_nvc"].Value;
                UserFactory.Delete(UserKey);

                DataRow[] dr = ((DataTable)this.UserGridView.DataSource).Select(HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString() + "='" + UserKey.UserName_nvc.ToString() + "'");
                if (dr.Length > 0)
                {
                    dr[0].Delete();
                }
                ((DataTable)this.UserGridView.DataSource).AcceptChanges();
            }

            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }
コード例 #3
0
        private void FillCombo()
        {
            try
            {
                HPS.BLL.UserBLL.BLLUser_TFactory RequestUserName_nvcFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
                DataTable RequestUserName_nvcDataTable = new DataTable();
                RequestUserName_nvcFactory.GetAll(ref RequestUserName_nvcDataTable);
                this.RequestUserName_nvcComboBox.DisplayMember = HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString();
                this.RequestUserName_nvcComboBox.ValueMember   = HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString();
                this.RequestUserName_nvcComboBox.DataSource    = RequestUserName_nvcDataTable;
                this.RequestUserName_nvcComboBox.SelectedIndex = -1;

                HPS.BLL.UserBLL.BLLUser_TFactory AcceptedUserName_nvcFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
                DataTable AcceptedUserName_nvcDataTable = new DataTable();
                AcceptedUserName_nvcFactory.GetAll(ref AcceptedUserName_nvcDataTable);
                this.AcceptedUserName_nvcComboBox.DisplayMember = HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString();
                this.AcceptedUserName_nvcComboBox.ValueMember   = HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString();
                this.AcceptedUserName_nvcComboBox.DataSource    = AcceptedUserName_nvcDataTable;
                this.AcceptedUserName_nvcComboBox.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        private void FillCombo()
        {
            try
            {
                HPS.BLL.UserGroupBLL.BLLUserGroup_TFactory UserGroupID_intFactory = new HPS.BLL.UserGroupBLL.BLLUserGroup_TFactory();
                DataTable UserGroupID_intDataTable = new DataTable();
                UserGroupID_intFactory.GetAll(ref UserGroupID_intDataTable);
                this.UserGroupID_intComboBox.DisplayMember = HPS.BLL.UserGroupBLL.BLLUserGroup_T.UserGroup_TField.UserGroup_nvc.ToString();
                this.UserGroupID_intComboBox.ValueMember   = HPS.BLL.UserGroupBLL.BLLUserGroup_T.UserGroup_TField.UserGroupID_int.ToString();
                this.UserGroupID_intComboBox.DataSource    = UserGroupID_intDataTable;
                this.UserGroupID_intComboBox.SelectedIndex = -1;

                HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
                DataTable UserDataTable = new DataTable();
                UserFactory.GetAll(ref UserDataTable);
                //UserDataTable.Columns.Add("select_bit").DefaultValue=false;

                UserNameGridView.DataSource = UserDataTable;
                //this.Computer_nvcComboBox.DisplayMember = HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString();
                //this.Computer_nvcComboBox.ValueMember = HPS.BLL.UserBLL.BLLUser_T.User_TField.UserName_nvc.ToString();
                //this.Computer_nvcComboBox.DataSource = UserDataTable;
                //this.Computer_nvcComboBox.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        protected override void Delete()
        {
            HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();

            try
            {
                UserFactory.BeginProc();
                UserFactory.Delete((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].Delete();
                    }
                    DataTable.AcceptChanges();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                UserFactory.RollBackProc();
                throw ex;
            }
        }
コード例 #6
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; }
 }
コード例 #7
0
 private void LoadUser()
 {
     try
     {
         HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
         DataTable UserDataTable = new DataTable();
         UserFactory.GetAll(ref UserDataTable);
         this.UserGridView.DataSource = UserDataTable;
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
コード例 #8
0
 private void UserGroupID_intComboBox_SelectionChangeCommitted(object sender, EventArgs e)
 {
     try
     {
         HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
         DataTable UserDataTable = new DataTable();
         UserFactory.GetAllBy(BLL.UserBLL.BLLUser_T.User_TField.UserGroupID_int, UserGroupID_intComboBox.SelectedValue, ref UserDataTable);
         UserNameGridView.DataSource = UserDataTable;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #9
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);
            }
        }
コード例 #10
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);
        }
コード例 #11
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;
            }
        }
コード例 #12
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;
            }
        }
コード例 #13
0
        private void Login_Load(object sender, EventArgs e)
        {
            string s = Hepsa.Core.Common.ApplicationInfo.MacAddress;

            if (string.IsNullOrEmpty(Hepsa.Core.Common.ConnectionString.ConnectionString))
            {
                HPS.Present.SQL.SQLConnectionManager sqlManager = new HPS.Present.SQL.SQLConnectionManager(HPS.Present.SQL.SQLConnectionManager.enumCloseMode.EndProgram);
                sqlManager.ShowDialog();
            }
            HPS.BLL.BLLYear_T year = null;
            Hepsa.Core.Common.ConnectionString.DataBase = Properties.Settings.Default.DataBaseName;
            try
            {
                LoadFiscalYearCombo();
            }
            catch (Exception ex)
            {
                HPS.Present.SQL.SQLConnectionManager sqlManager = new HPS.Present.SQL.SQLConnectionManager(HPS.Present.SQL.SQLConnectionManager.enumCloseMode.EndProgram);
                sqlManager.ShowDialog();
                LoadFiscalYearCombo();
            }

            if (HPS.Common.CurrentUser.Year != null)
            {
                YearEntity = HPS.Common.CurrentUser.Year;
                HPS.Common.CurrentUser.Year = null;
            }


            //while (true)
            //{
            HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory();
            try
            {
                HPS.BLL.VersionBLL.BLLVersion_TFactory VersionFactory = new HPS.BLL.VersionBLL.BLLVersion_TFactory();
                string DBVersion_nvc = string.Empty;
                VersionFactory.SelectLastOldVersion(out DBVersion_nvc);

                string APPVersion = Assembly.GetEntryAssembly().GetName().Version.ToString();
                APPVersion = APPVersion.Substring(0, APPVersion.Length - 2);
                string[] splitedVersion = APPVersion.Split('.');
                if (splitedVersion[1].Length == 1)
                {
                    splitedVersion[1] = "0" + splitedVersion[1];
                }
                if (splitedVersion[2].Length == 1)
                {
                    splitedVersion[2] = "0" + splitedVersion[2];
                }
                APPVersion = splitedVersion[0] + "/" + splitedVersion[1] + "/" + splitedVersion[2];
                if (string.IsNullOrEmpty(DBVersion_nvc))
                {
                    HPS.BLL.VersionBLL.BLLVersion_T VersionEntity = new HPS.BLL.VersionBLL.BLLVersion_T();
                    VersionEntity.Version_nvc = APPVersion;
                    VersionEntity.Date_nvc    = VersionFactory.ServerJalaliDate;
                    VersionEntity.Time_nvc    = VersionFactory.ServerTime;
                    VersionFactory.Insert(VersionEntity);
                }
                else
                {
                    // \\172.24.129.5\exe\
                    // \\192.168.200.50\exe\
                    //
                    if (DBVersion_nvc.CompareTo(APPVersion) > 0)
                    {
                        throw new ApplicationException("نسخه اجرایی شما قدیمی است لطفاً به روز رسانی نمایید");
                    }
                    else if (DBVersion_nvc.CompareTo(APPVersion) < 0)
                    {
                        HPS.BLL.VersionBLL.BLLVersion_T VersionEntity = new HPS.BLL.VersionBLL.BLLVersion_T();
                        VersionEntity.Version_nvc = APPVersion;
                        VersionEntity.Date_nvc    = VersionFactory.ServerJalaliDate;
                        VersionEntity.Time_nvc    = VersionFactory.ServerTime;
                        VersionFactory.Insert(VersionEntity);
                    }
                }
                if (YearEntity != null)
                {
                    HPS.Common.CurrentUser.Year = YearEntity;
                }
                //              If FiscalYearEntity IsNot Nothing Then
                //    HPS.Common.CurrentUser.FiscalYear = FiscalYearEntity
                //End If
            }
            catch (Exception ex)
            {
                if (ex.Message == "The ConnectionString property has not been initialized.")
                {
                    HPS.Present.SQL.SQLConnectionManager sqlManager = new HPS.Present.SQL.SQLConnectionManager(HPS.Present.SQL.SQLConnectionManager.enumCloseMode.EndProgram);
                    sqlManager.ShowDialog();
                }
                else
                {
                    Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
                    Environment.Exit(0);
                }
            }
            finally
            {
            }
            //}
            try
            {
                //TINYLib.Tiny tinylock = new TINYLib.Tiny();
                ////tinylock.ServerIP = Hepsa.Core.Common.ConnectionString.Server;
                //tinylock.Initialize = true;
                //if (tinylock.TinyErrCode != 0)
                //{
                //    throw new ApplicationException("خطا در اتصال به قفل");
                //}
                //tinylock.UserPassWord = "******";
                //tinylock.ShowTinyInfo = true;
                //if (tinylock.TinyErrCode != 0)
                //    throw new ApplicationException("خطا در اتصال به قفل");
                //if (tinylock.SerialNumber != "2039-8806-1473")
                //    throw new ApplicationException("قفل مورد استفاده نامعتبر می باشد");
            }

            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
                Environment.Exit(0);
            }
        }