예제 #1
0
 private void cbMain_Click(object sender, EventArgs e)
 {
     if (disableMain == true)
     {
         UtilityMessageBox.ShowText("không được disable tài khoản chính, vì chỉ còn một tài khoản chính");
     }
 }
예제 #2
0
        private void BtnUpdateSubAccout_Click(object sender, EventArgs e)
        {
            DialogResult btnSeclect = UtilityMessageBox.WarningOpeartor(NotificationMessage.MsgIsupdateQuestion);

            if (btnSeclect == DialogResult.No)
            {
                return;
            }


            Deputy objDeputy = _companySelect.MainDeputy;

            if (objDeputy == null)
            {
                UtilityMessageBox.ShowText("không có thông tin cập nhật");
                return;
            }



            var objFrmDeputyEdit = new frmEditDeputy(objDeputy)
            {
                _XuLySauKhiUpdate = XuLySauKhiUpdate
            };

            objFrmDeputyEdit.ShowDialog();
        }
예제 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            var deputy = objEdit;

            deputy.Skype      = txtSkype.Text;
            deputy.Address    = txtDiaChi.Text;
            deputy.Email      = txtEmail.Text;
            deputy.DeputyName = txtNameContact.Text;
            deputy.Phone      = txtPhone.Text;
            deputy.CompanyId  = objEdit.CompanyId;
            deputy.IsActive   = checkIsActive.Checked;
            deputy.ModifyBy   = UserManagement.UserSession.UserName;
            deputy.ModifyDate = DateTime.Now;
            deputy.Note       = txtNote.Text;
            deputy.Sex        = (cbSex.SelectedIndex < 1);
            deputy.IsMain     = cbMain.Checked;

            if (userEdit != null)
            {
                userEdit.UserName   = txtAccount.Text;
                userEdit.FullName   = txtNameContact.Text;
                userEdit.ModifyBy   = UserManagement.UserSession.UserName;
                userEdit.ModifyDate = DateTime.Now;
            }
            using (IUnitOfWork uow = new UnitOfWork())
            {
                uow.DeputyRepository.Update(deputy);
                uow.UsersRepository.Update(userEdit);
                uow.Commit();
            }
            UtilityMessageBox.ShowText("cập nhật thành công");

            if (_XuLySauKhiUpdate != null)
            {
                _XuLySauKhiUpdate(deputy);
            }

            Close();
        }
예제 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }

            Deputy deputy = new Deputy
            {
                Skype      = txtSkype.Text,
                Address    = txtDiaChi.Text,
                Email      = txtEmail.Text,
                DeputyName = txtNameContact.Text,
                Phone      = txtPhone.Text,
                CompanyId  = _companyID,
                IsActive   = true,
                IsMain     = false,
                Sex        = (cbSex.SelectedIndex) < 1 ? false : true,
                CreateBy   = UserManagement.UserSession.UserName,
                CreateDate = DateTime.Now
            };


            Users userNew = new Users
            {
                UserName    = txtAccount.Text,
                Password    = UtilityFunction.GetSHA256Hash(txtPassword.Text),
                Email       = txtEmail.Text,
                FullName    = txtNameContact.Text,
                CreateBy    = deputy.CreateBy,
                CreateDate  = deputy.CreateDate,
                UserGroupId = 2
            };


            Users userCheck = null;

            using (IUnitOfWork uow = new UnitOfWork())
            {
                userCheck = uow.UsersRepository.IsExist(userNew.UserName);
            }
            if (userCheck != null)
            {
                UtilityMessageBox.ShowText("UserName is exit, not valid");
                return;
            }


            using (IUnitOfWork uow = new UnitOfWork())
            {
                //int k = uow.UsersRepository.Add(userNew);
                //deputy.UserId = k;
                //uow.DeputyRepository.Add(deputy);


                uow.Commit();
            }

            UtilityMessageBox.ShowText("Thêm mới thành công");

            if (_xulyThemMoiDeputy != null)
            {
                _xulyThemMoiDeputy(deputy);
            }
            Close();
        }
예제 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            var company = new Company
            {
                CompanyName      = txtCompanyName.Text,
                CompanyCode      = txtCompanyCode.Text,
                Taxcode          = txtTaxCode.Text,
                Address          = txtAddree.Text,
                SwiftCode        = txtSwich.Text,
                NumberOfEmployee = ValidationUtility.StringIsNull(txtStaft.Text) == false?int.Parse(txtStaft.Text) : 0,
                                       Branch = ValidationUtility.StringIsNull(txtNoBrach.Text) == false?int.Parse(txtNoBrach.Text) : 0,
                                                    TagetValue =
                                                        ValidationUtility.StringIsNull(txtTargertValue.Text) == false?int.Parse(txtTargertValue.Text) : 0,
                                                            Website         = txtWebsite.Text,
                                                            CreateDate      = DateTime.Now,
                                                            CreateBy        = UserManagement.UserSession.UserName,
                                                            Note            = txtNote.Text,
                                                            isActive        = true,
                                                            Accountant      = txtAccount.Text,
                                                            AccountantPhone = txtPhoneAccountant.Text,
            };
            var companyClass = cbClassCustormer.SelectedItem as CompanyClass;

            if (companyClass != null)
            {
                company.ClassId = cbClassCustormer.SelectedValue != null ? companyClass.CompanyClassId : 0;
            }
            var accountBank = (cbSelectBank.SelectedValue != null) ? cbSelectBank.SelectedValue.ToString() : string.Empty;

            switch (cboTypeOfCompany.SelectedIndex)
            {
            case 1:
                company.TypeId = 1;
                break;

            default:
                company.TypeId = 0;
                break;
            }
            if (PictureLogo.Tag != null)
            {
                company.PictureLogo = PictureUtility.SaveImg(PictureLogo.Tag.ToString());
            }
            if (PictureSgnature.Tag != null)
            {
                company.Photo = PictureUtility.SaveImg(PictureSgnature.Tag.ToString());
            }
            var deputy = new Deputy
            {
                DeputyName = txtNameContact.Text,
                Address    = txtAddree.Text,
                Phone      = txtPhone.Text,
                IsMain     = true,
                IsActive   = true,
                Email      = txtEmail.Text,
                Sex        = (cbSex.SelectedIndex <= 0),
                CreateBy   = UserManagement.UserSession.UserName,
                CreateDate = DateTime.Now
            };
            var userNew = new Users
            {
                UserName    = txtAccount.Text,
                Password    = UtilityFunction.GetSHA256Hash(txtPassword.Text),
                Email       = txtEmail.Text,
                FullName    = txtNameContact.Text,
                CreateBy    = deputy.CreateBy,
                CreateDate  = deputy.CreateDate,
                UserGroupId = 2
            };
            Users userCheck;

            using (IUnitOfWork uow = new UnitOfWork())
            {
                userCheck = uow.UsersRepository.IsExist(userNew.UserName);
            }
            if (userCheck != null)
            {
                UtilityMessageBox.ShowText("UserName is exist, not valid");
                return;
            }
            if (PictureSgnature.Tag != null)
            {
                company.Photo = PictureUtility.SaveImg(PictureSgnature.Tag.ToString());
            }
            if (PictureLogo.Tag != null)
            {
                company.PictureLogo = PictureUtility.SaveImg(PictureLogo.Tag.ToString());
            }
            var companyId = _companyBussiness.Insert(company);

            company.CompanyId = companyId;
            deputy.CompanyId  = companyId;
            using (IUnitOfWork uow = new UnitOfWork())
            {
                //var useridnew = uow.UsersRepository.Add(userNew);
                //deputy.UserId = useridnew;
                //uow.DeputyRepository.Add(deputy);
                //uow.Commit();
            }
            if (Xulysaukhithemmoi == null)
            {
                return;
            }
            Xulysaukhithemmoi(company, deputy);
            Close();
        }