コード例 #1
0
ファイル: FrmSourcing.cs プロジェクト: quangphat/TmTech
        private void bootstrapButton1_Click(object sender, EventArgs e)
        {
            if (isInsert == false && isUpdate == false)
            {
                lblNotify1.SetText("không có thao tác", LabelNotify.EnumStatus.Failed);
                return;
            }

            if (isInsert)
            {
                if (ValidationUtility.FieldNotAllowNull(this) == false)
                {
                    return;
                }
                if (isCreateNew.SeriesPartID < 0)
                {
                    lblNotify1.SetText("thiếu thông tin về series ID", LabelNotify.EnumStatus.Failed);
                    return;
                }


                if (txtPricePart.Text == string.Empty)
                {
                }

                try
                {
                    decimal.Parse(txtPricePart.Text);
                }
                catch (Exception)
                {
                    lblNotify1.SetText("Chưa nhập giá hoặc giá không chính x", LabelNotify.EnumStatus.Failed);
                    txtPricePart.Focus();
                    return;
                }


                if (cboSupplier.SelectedValue == null)
                {
                    lblNotify1.SetText("Chưa nhập thông tin nhà cung cấp", LabelNotify.EnumStatus.Failed);
                }

                if (PictureImage.Tag != null)
                {
                    isCreateNew.ImagePath = PictureUtility.SaveImg(PictureImage.Tag.ToString());
                }



                SaveSourcing(isCreateNew);
            }
            else if (isUpdate)
            {
                Update();
            }
        }
コード例 #2
0
 private void SaveProduct()
 {
     if (!string.IsNullOrWhiteSpace(pictureBox2.PictureOriginPath))
     {
         PictureUtility.SaveImg(pictureBox2.PictureOriginPath);
     }
     if (!string.IsNullOrWhiteSpace(txtInstallGuide.FilePath))
     {
         FileUtility.SaveToServer(txtInstallGuide.FileName, txtInstallGuide.FilePath);
     }
     if (!string.IsNullOrWhiteSpace(txtDatasheet.Text))
     {
         FileUtility.SaveToServer(txtDatasheet.FileName, txtDatasheet.FilePath);
     }
     if (!string.IsNullOrWhiteSpace(txtCard3D.FilePath))
     {
         FileUtility.SaveToServer(txtCard3D.FileName, txtCard3D.FilePath);
     }
     if (!string.IsNullOrWhiteSpace(txtDimension.FilePath))
     {
         PictureUtility.SaveImg(txtDimension.FilePath);
     }
     using (IUnitOfWork uow = new UnitOfWork())
     {
         if (m_Product.ProductId == Guid.Empty)
         {
             uow.ProductRepository.Add(m_Product);
             gridUtility.AddNewRow <Product>(m_Product);
         }
         else
         {
             uow.ProductRepository.Update(m_Product);
             gridUtility.UpdateRow <Product>(m_Product);
         }
         if (displayMultiplePicture1.ImgList != null)
         {
             for (int i = 0; i < displayMultiplePicture1.ImgList.Length; i++)
             {
                 if (!string.IsNullOrWhiteSpace(displayMultiplePicture1.ImgList[i]))
                 {
                     ProductPicture picture = new ProductPicture();
                     picture.ProductId = m_Product.ProductId;
                     picture.Picture   = displayMultiplePicture1.ImgList[i];
                     uow.ProductPictureRepository.Add(picture);
                 }
             }
         }
         uow.Commit();
     }
 }
コード例 #3
0
        private void itemAdd_Click(object sender, EventArgs e)
        {
            OpenFileDialog op = new OpenFileDialog();

            op.Filter = PictureUtility.filter;
            op.ShowDialog();
            if (ValidationUtility.StringIsNull(op.FileName))
            {
                return;
            }
            string name = PictureUtility.SaveImg(op.FileName);

            Add(name);
        }
コード例 #4
0
 private void btnSaveDeputy_Click(object sender, EventArgs e)
 {
     if (ValidationUtility.FieldNotAllowNull(groupBox1) == false)
     {
         lblNotify1.SetText(UI.hasnoinfomation, LabelNotify.EnumStatus.Failed);
         return;
     }
     if (m_User == null)
     {
         return;
     }
     CoverObjectUtility.GetAutoBindingData(groupBox1, m_User);
     if (m_User == null)
     {
         return;
     }
     try
     {
         if (SaveAccount(m_User) == null)
         {
             return;
         }
         if (!string.IsNullOrWhiteSpace(ptbSignature.PictureOriginPath))
         {
             PictureUtility.SaveImg(ptbSignature.PictureOriginPath);
         }
         if (!string.IsNullOrWhiteSpace(ptbAvatar.PictureOriginPath))
         {
             PictureUtility.SaveImg(ptbAvatar.PictureOriginPath);
         }
         gridUtility1.UpdateRow <Deputy>(m_Deputy);
         lblNotify1.SetText(UI.success, LabelNotify.EnumStatus.Success);
     }
     catch
     {
         lblNotify1.SetText(UI.failed, LabelNotify.EnumStatus.Failed);
     }
 }
コード例 #5
0
        private void AssignData(Company company)
        {
            company.CompanyCode      = txtCompanyCode.Text;
            company.CompanyName      = txtCompanyName.Text;
            company.TypeId           = (int)cboTypeOfCompany.SelectedValue;
            company.Address          = txtAddress.Text;
            company.Accountant       = txtAccountant.Text;
            company.AccountantPhone  = txtPhoneAccountant.Text;
            company.SwiftCode        = txtSwich.Text;
            company.Taxcode          = txtTaxCode.Text;
            company.Branch           = txtNoBrach.Text.ConvertToInt();
            company.NumberOfEmployee = txtStaft.Text.ConvertToInt();
            company.Note             = txtNote.Text;
            var itemBank = cbSelectBank.SelectedItem as Bank;

            if (PictureLogo.Tag != null)
            {
                company.PictureLogo = PictureUtility.SaveImg(PictureLogo.Tag.ToString());
            }
            if (PictureSgnature.Tag != null)
            {
                company.Photo = PictureUtility.SaveImg(PictureSgnature.Tag.ToString());
            }
            if (company.MainDeputy != null)
            {
                company.MainDeputy.DeputyName = txtNameContact.Text;
                company.MainDeputy.Phone      = txtPhone.Text;
                company.MainDeputy.Email      = txtEmail.Text;
                company.MainDeputy.Sex        = cbSex.SelectedIndex > 0;
            }
            if (company.Class != null)
            {
                var companyClass = cbClassCustormer.SelectedValue as CompanyClass;
                company.ClassId = companyClass.CompanyClassId;
                company.Class   = company.Class;
            }
        }
コード例 #6
0
ファイル: FrmSourcing.cs プロジェクト: quangphat/TmTech
        private new void Update()
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }

            if (isUpdatePart.SeriesPartID < 0)
            {
                lblNotify1.SetText("thiếu thông tin về series ID", LabelNotify.EnumStatus.Failed);
                return;
            }


            if (txtPricePart.Text == string.Empty)
            {
                lblNotify1.SetText("Chưa nhập giá", LabelNotify.EnumStatus.Failed);
                txtPricePart.Focus();
                return;
            }

            try
            {
                decimal.Parse(txtPricePart.Text);
            }
            catch (Exception)
            {
                lblNotify1.SetText("Chưa nhập giá hoặc giá không chính x", LabelNotify.EnumStatus.Failed);
                txtPricePart.Focus();
                return;
            }
            if (cboSupplier.SelectedValue == null)
            {
                lblNotify1.SetText("Chưa nhập thông tin nhà cung cấp", LabelNotify.EnumStatus.Failed);
            }

            if (PictureImage.Tag != null)
            {
                isUpdatePart.ImagePath = PictureUtility.SaveImg(PictureImage.Tag.ToString());
            }


            isSourcing.SupplierID    = (cboSupplier.SelectedItem as TmTech_v1.Model.Supplier).SupplierId;
            isSourcing.ModifyBy      = UserManagement.UserSession.UserName;
            isSourcing.ModifyDate    = DateTime.Now;
            isUpdatePart.ModifyBy    = UserManagement.UserSession.UserName;
            isUpdatePart.ModifyDate  = DateTime.Now;
            isUpdatePart.Pricespart  = decimal.Parse(txtPricePart.Text);
            isUpdatePart.PartName    = txtNamePart.Text;
            isUpdatePart.Description = txtDescription.Text;
            isSourcing.Note          = txtDescription.Text;

            try
            {
                using (UnitOfWork uow = new UnitOfWork())
                {
                    uow.PartBaseRepository.Update(isUpdatePart);

                    uow.SourcingBaseRepository.Update(isSourcing);
                    uow.Commit();


                    TreeTagPart treeTag = new TreeTagPart();
                    treeTag.NodeTye         = TreeTagPart.Types.Part;
                    treeTag.SeriesPartIDTag = isUpdatePart.SeriesPartID;
                    treeTag.PartIDTag       = isUpdatePart.PartID;
                    treeTag.GroupPartIDTag  = mainUpdate.GroupPartIDTag;
                    treeTag.TypePartIDTag   = mainUpdate.TypePartIDTag;

                    TreeNode node = new TreeNode(txtNamePart.Text);
                    node.Name = txtNamePart.Text;
                    node.Tag  = treeTag;
                    updateNode(node);
                }

                lblNotify1.SetText(UI.updatesuccess, LabelNotify.EnumStatus.Success);
                DisplayInformation(treeView1.SelectedNode);
                txtDescription.ReadOnly = true;
                isUpdate = false;
                FormUtility.ReadOnlySpecial(pnlContent);
                cboSupplier.Enabled = false;
            }
            catch (Exception)
            {
                lblNotify1.SetText(UI.updatefailed, LabelNotify.EnumStatus.Failed);
            }
        }
コード例 #7
0
ファイル: frmEditStaff.cs プロジェクト: quangphat/TmTech
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (ValidationUtility.FieldNotAllowNull(this) == false)
     {
         lblNotify1.SetText(UI.hasnoinfomation, ToolBoxCS.LabelNotify.EnumStatus.Failed);
         return;
     }
     //m_Staff.StaffName = txtFullName.Text;
     //m_Staff.Email = txtEmail.Text;
     //m_Staff.StaffCode = txtCode.Text;
     //m_Staff.Phone = txtPhone.Text;
     //m_Staff.Birthday = dtpBirthday.DateTime;
     //m_Staff.BeginDate = dtpBeginDate.DateTime;
     //m_Staff.Address = txtAddress.Text;
     if (ptAvatar.Tag != null)
     {
         m_Staff.Avatar = PictureUtility.SaveImg(ptAvatar.Tag.ToString());
     }
     if (ptSignature.Tag != null)
     {
         m_Staff.SignaturePhoto = PictureUtility.SaveImg(ptSignature.Tag.ToString());
     }
     //m_Staff.DepartmentId = Convert.ToInt32(cbbDepartment.SelectedValue);
     //m_Staff.ModifyBy = UserManagement.UserSession.UserName;
     //m_Staff.ModifyDate = DateTime.Now;
     //m_Staff.PositionId = Convert.ToInt32(cbbPosition.SelectedValue);
     CoverObjectUtility.GetAutoBindingData(this, m_Staff);
     m_Staff.Sex = (rbtnFemale.Checked) ? false : true;
     m_Staff.SetModify();
     try
     {
         using (IUnitOfWork uow = new UnitOfWork())
         {
             IList <Users> lstUser = uow.UsersRepository.All();
             if (lstUser == null)
             {
                 lstUser = new List <Users>();
             }
             Users exist = lstUser.Where(p => p.UserName == m_Staff.User.UserName && p.UserId != m_Staff.User.UserId).FirstOrDefault();
             if (exist != null)
             {
                 lblNotify1.SetText(UI.userhasexist, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                 uow.Commit();
                 return;
             }
             uow.StaffRepository.Update(m_Staff);
             if (m_Staff.User != null)
             {
                 uow.UsersRepository.Update(m_Staff.User);
             }
             uow.Commit();
         }
         Close();
     }
     catch
     {
         lblNotify1.SetText(UI.updatefailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
     }
     //}
     //catch
     //{
     //    MessageBox.Show(ex.Message);
     //    lblNotify1.SetText(MesgBox.updatefailed, ToolBoxCS.LabelNotify.enumStatus.failed);
     //}
 }
コード例 #8
0
ファイル: frmCreateCompany.cs プロジェクト: quangphat/TmTech
        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();
        }
コード例 #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            if (_objEditCompany == null)
            {
                return;
            }
            _objEditCompany.CompanyName      = txtCompanyName.Text;
            _objEditCompany.CompanyCode      = txtCompanyCode.Text;
            _objEditCompany.Taxcode          = txtTaxCode.Text;
            _objEditCompany.Address          = txtAddree.Text;
            _objEditCompany.SwiftCode        = txtSwich.Text;
            _objEditCompany.NumberOfEmployee = ValidationUtility.StringIsNull(txtStaft.Text) == false?int.Parse(txtStaft.Text) : 0;

            _objEditCompany.Branch = ValidationUtility.StringIsNull(txtNoBrach.Text) == false?int.Parse(txtNoBrach.Text) : 0;

            _objEditCompany.TagetValue = ValidationUtility.StringIsNull(txtTargertValue.Text) == false?int.Parse(txtTargertValue.Text) : 0;

            _objEditCompany.Website         = txtWebsite.Text;
            _objEditCompany.CreateDate      = DateTime.Now;
            _objEditCompany.CreateBy        = UserManagement.UserSession.UserName;
            _objEditCompany.Note            = txtNote.Text;
            _objEditCompany.isActive        = true;
            _objEditCompany.Accountant      = txtAccount.Text;
            _objEditCompany.AccountantPhone = txtAccount.Text;
            var companyClass = cbClassCustormer.SelectedItem as CompanyClass;

            if (companyClass != null)
            {
                _objEditCompany.ClassId = cbClassCustormer.SelectedValue != null ? companyClass.CompanyClassId : 0;
            }


            if (PictureLogo.Tag != null)
            {
                _objEditCompany.PictureLogo = PictureUtility.SaveImg(PictureLogo.Tag.ToString());
            }
            if (PictureSgnature.Tag != null)
            {
                _objEditCompany.Photo = PictureUtility.SaveImg(PictureSgnature.Tag.ToString());
            }

            _objMain.DeputyName = txtNameContact.Text;
            _objMain.Address    = txtAddree.Text;
            _objMain.Phone      = txtPhone.Text;
            _objMain.IsMain     = true;
            _objMain.IsActive   = true;
            _objMain.Sex        = (cbSex.SelectedIndex) < 0;
            _objMain.Email      = txtEmail.Text;
            _objMain.ModifyBy   = UserManagement.UserSession.UserName;
            _objMain.ModifyDate = DateTime.Now;


            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.CompanyRepository.Update(_objEditCompany);
                uow.DeputyRepository.Update(_objMain);
                uow.UsersRepository.Update(userEdit);
                uow.Commit();
            }
            if (XulysaukhiCapNhat != null)
            {
                XulysaukhiCapNhat(_objEditCompany, _objMain);
                Close();
            }
        }
コード例 #10
0
ファイル: frmCreateProduct.cs プロジェクト: quangphat/TmTech
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            if (cbbCategory.SelectedValue == null || cbbSubCate.SelectedValue == null || cbbSerie.SelectedValue == null)
            {
                lblNotify1.SetText(UI.hasnoinfomation, LabelNotify.EnumStatus.Failed);
                return;
            }
            Product product = new Product();

            FormUtility.BindTextBoxToObj <Product>(this, product);
            product.SeriesId    = int.Parse(cbbSerie.SelectedValue.ToString());
            product.ProductCode = txtCode.Text;
            product.ProductName = txtName.Text;
            //product.BranchOfLed = txtLed.Text;
            //product.IPRate = txtIPRate.Text;
            product.DataSheet  = ValidationUtility.StringIsNull(txtDatasheet.Text) == false ? txtDatasheet.Text : "";
            product.Note       = txtNote.Text;
            product.CreateBy   = UserManagement.UserSession.UserName;
            product.CreateDate = DateTime.Now;
            ProductPrice productPrice = new ProductPrice();

            productPrice.Price      = CurrencyUtility.ToDecimal(txtPrice.Text);
            productPrice.ActiveDate = DateTime.Today;
            productPrice.CreateBy   = UserManagement.UserSession.UserName;
            productPrice.CreateDate = DateTime.Now;
            if (ptPicture.Tag != null)
            {
                product.PhotoPath = PictureUtility.SaveImg(ptPicture.Tag.ToString());
            }
            if (ptPhotometer.Tag != null)
            {
                product.PhotoMeter = PictureUtility.SaveImg(ptPhotometer.Tag.ToString());
            }
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    Product exists = uow.ProductRepository.FindByCode(product.ProductCode);
                    if (exists != null)
                    {
                        lblNotify1.SetText(UI.codehasexist, LabelNotify.EnumStatus.Failed);
                        uow.Commit();
                        return;
                    }
                    if (product.Barcode != null)
                    {
                        exists = uow.ProductRepository.FindByBarcode(product.Barcode);
                        if (exists != null)
                        {
                            lblNotify1.SetText(UI.barcodehasexists, LabelNotify.EnumStatus.Failed);
                            uow.Commit();
                            return;
                        }
                    }

                    //Guid id = uow.ProductRepository.Add(product);
                    //product.ProductId = id;
                    ////product.Barcode = BarcodeUtility.generateBarcode(id);
                    //productPrice.ProductId = id;
                    //uow.ProductPriceRepository.Update(productPrice);
                    //uow.ProductRepository.Update(product);
                    //uow.Commit();
                }
                lblNotify1.SetText(UI.createsuccess, LabelNotify.EnumStatus.Success);
            }
            catch
            {
                lblNotify1.SetText(UI.createfailed, LabelNotify.EnumStatus.Failed);
            }
        }