private void InititalizeForm(Company company) { txtName.Text = company.CompanyName; txtCode.Text = company.CompanyCode; txtAddress.Text = company.Address; txtTaxCode.Text = company.Taxcode; txtNoBrach.Text = company.Branch >= 0 ? company.Branch.ToString() : ""; txtNumberEmployee.Text = company.NumberOfEmployee >= 0 ? company.NumberOfEmployee.ToString() : ""; txtNumberEmployee.Text = company.NumberOfEmployee != null?company.NumberOfEmployee.ToString() : ""; txtNote.Text = company.Note; txtSwiffcode.Text = company.SwiftCode; txtWebsite.Text = company.Website; if (ValidationUtility.StringIsNull(company.PictureLogo) == false) { pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox2.Image = Image.FromFile(PictureUtility.appDataDir + "//" + company.PictureLogo); } if (ValidationUtility.StringIsNull(company.Photo) == false) { pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Image = Image.FromFile(PictureUtility.appDataDir + "//" + company.Photo); } LoadDeputy(company.MainDeputy); }
private void InitializeForm(Staff staff) { //txtFullName.Text = staff.StaffName; //txtEmail.Text = staff.Email; //txtCode.Text = staff.StaffCode; //txtUserName.Text = staff.User!=null?staff.User.UserName:string.Empty; //txtPhone.Text = staff.Phone; //dtpBirthday.DateTime = staff.Birthday != null ? staff.Birthday.Value : DateTime.Today; //dtpBeginDate.DateTime = staff.BeginDate!=null? staff.BeginDate.Value:DateTime.Today; //txtAddress.Text = staff.Address; //cbbDepartment.SelectedValue = m_Staff.DepartmentId; //cbbUserGroup.SelectedValue = staff.UserGroup != null ? staff.UserGroup.UserGroupId : 0; //cbbPosition.SelectedValue = m_Staff.StaffPosition != null ? staff.StaffPosition.StaffPositionId : 0; CoverObjectUtility.SetAutoBindingData(this, staff); if (staff.Sex) { rbtnMale.Checked = true; } else { rbtnFemale.Checked = true; } if (!ValidationUtility.StringIsNull(staff.Avatar)) { PictureUtility.BindImage(ptAvatar, staff.Avatar); } if (!ValidationUtility.StringIsNull(staff.SignaturePhoto)) { PictureUtility.BindImage(ptSignature, staff.SignaturePhoto); } }
public static int?getNumberIString(string strNumber) { if (ValidationUtility.StringIsNull(strNumber)) { return(0); } else { return(Convert.ToInt32(strNumber)); } }
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); }
public void LoadGrid() { IList <ProductPrice> lstProductPrice; if (ValidationUtility.StringIsNull(txtSearch.Text)) { m_Product = new Product(); } using (IUnitOfWork uow = new UnitOfWork()) { lstProductPrice = uow.ProductPriceRepository.FindByProduct(txtSearch.Text); uow.Commit(); } gridUtility.BindingData <ProductPrice>(lstProductPrice); }
private void linkAddDimension_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { OpenFileDialog op = new OpenFileDialog(); op.Filter = PictureUtility.filter; op.ShowDialog(); if (ValidationUtility.StringIsNull(op.FileName)) { return; } FileInfo finfo = new FileInfo(op.FileName); txtDimension.Text = finfo.Name; txtDimension.FileName = finfo.Name; txtDimension.FilePath = op.FileName; }
public static double getNumberDString(string strNumber) { return(!ValidationUtility.StringIsNull(strNumber) ? Convert.ToDouble(strNumber) : 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(); }
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(); } }
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); } }