public void LoadData() { try { ContractsBO aContractsBO = new ContractsBO(); aListAvailableContracts = aContractsBO.Select_ByIDAllowances(IDAllowances); dgvAvailableContracts.DataSource = aListAvailableContracts; } catch (Exception ex) { MessageBox.Show("frmIns_Contracts_Allowances.LoadData\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ReloadData() { try { SystemUsersBO aSystemUsersBO = new SystemUsersBO(); ContractsBO aContractsBO = new ContractsBO(); colContractDate.DisplayFormat.FormatType = FormatType.DateTime; colContractDate.DisplayFormat.FormatString = "{0:dd/MM/yyyy}"; colFrom.DisplayFormat.FormatType = FormatType.DateTime; colFrom.DisplayFormat.FormatString = "{0:dd/MM/yyyy}"; colTo.DisplayFormat.FormatType = FormatType.DateTime; colTo.DisplayFormat.FormatString = "{0:dd/MM/yyyy}"; colCoefficent.DisplayFormat.FormatType = FormatType.Numeric; colCoefficent.DisplayFormat.FormatString = "{0:0,0}"; colSalaryNet.DisplayFormat.FormatType = FormatType.Numeric; colSalaryNet.DisplayFormat.FormatString = "{0:0,0}"; colSalaryCross.DisplayFormat.FormatType = FormatType.Numeric; colSalaryCross.DisplayFormat.FormatString = "{0:0,0}"; // Load data cho gridview List<ContractsEN> aListContractsEN = new List<ContractsEN>(); List<Contracts> aListTemp = aContractsBO.Select_All(); ContractsEN aContractsEN; for (int i = 0; i < aListTemp.Count; i++) { aContractsEN = new ContractsEN(); aContractsEN.SetValue(aListTemp[i]); aContractsEN.Name = aSystemUsersBO.Select_ByID(aListTemp[i].IDSystemUser).Name; aListContractsEN.Add(aContractsEN); } dgvContracts.DataSource = aListContractsEN; dgvContracts.RefreshDataSource(); } catch (Exception ex) { MessageBox.Show("frmLst_Contracts.ReloadData\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ReloadGridView(int IDSystemUser) { ContractsBO aContractsBO = new ContractsBO(); SystemUsersBO aSystemUsersBO = new SystemUsersBO(); List<ContractsEN> aListContractsEN = new List<ContractsEN>(); List<Contracts> aListTemp = aContractsBO.Select_ByIDSystemUser(IDSystemUser); ContractsEN aContractsEN; if (aListTemp != null) { for (int i = 0; i < aListTemp.Count; i++) { aContractsEN = new ContractsEN(); aContractsEN.SetValue(aListTemp[i]); aContractsEN.Name = aSystemUsersBO.Select_ByID(aListTemp[i].IDSystemUser).Name; aListContractsEN.Add(aContractsEN); } } dgvContracts.DataSource = aListContractsEN; dgvContracts.RefreshDataSource(); }
private void btnAddNew_Click(object sender, EventArgs e) { try { if (this.CheckDataBeforInsert() == true) { ContractsBO aContractsBO = new ContractsBO(); //Disable hợp đồng cũ Contracts aContracts_Old = new Contracts(); List<Contracts> aLisTemp = aContractsBO.Select_ByIDSystemUser(Convert.ToInt16(lueSystemUser.EditValue)); if (aLisTemp!= null) { aContracts_Old = aLisTemp.Where(a => a.Disable == false).ToList()[0]; aContracts_Old.Disable = true; aContractsBO.Update(aContracts_Old); } // Tạo hợp đồng mới Contracts aContracts = new Contracts(); aContracts.CreatedDate = DateTime.Now; aContracts.ContractDate = dtpContractDate.DateTime; aContracts.NumberContract = txtNumberContract.Text; aContracts.NumberTemplateContract = txtNumberTemplateContract.Text; aContracts.IDSystemUser = Convert.ToInt32(lueSystemUser.EditValue); aContracts.Company = txtCompany.Text; aContracts.StatutoryRepresent = txtStatutoryRepresent.Text; aContracts.StatutoryRepresentGender = Convert.ToInt32(lueStatutoryRepresentGender.EditValue); aContracts.StatutoryRepresentIdentifier = txtStatutoryRepresentIdentifier.Text; aContracts.ContractType = Convert.ToInt32(lueContractType.EditValue); aContracts.FromDate =dtpFrom.DateTime; aContracts.ToDate = dtpTo.DateTime; int SkuTableSalary = txtSkuTableSalary.Text.Length == 0 ? 0 : Convert.ToInt32(txtSkuTableSalary.Text); double Coefficent = txtCoefficent.Text.Length == 0 ? 0 : Convert.ToDouble(txtCoefficent.Text); decimal SalaryNet = txtSalaryNet.Text.Length == 0 ? 0 : Convert.ToDecimal(txtSalaryNet.Text); decimal SalaryCross = txtSalaryCross.Text.Length == 0 ? 0 : Convert.ToDecimal(txtSalaryCross.Text); aContracts.SkuTableSalary = SkuTableSalary; aContracts.Coefficent = Coefficent; aContracts.SalaryNet = SalaryNet; aContracts.SalaryCross = SalaryCross; aContracts.Type = Convert.ToInt32(lueType.EditValue); aContracts.Status = cboStatus.SelectedIndex + 1; aContracts.Disable = Convert.ToBoolean(cboDisable.Text); aContractsBO.Insert(aContracts); MessageBox.Show("Thêm mới thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); if (this.afrmLst_Contracts != null) { this.afrmLst_Contracts.ReloadData(); this.Close(); } else if (this.afrmMain != null) { this.afrmMain.ReloadGridView(); this.Close(); } else { int IDSystemUser = Convert.ToInt32(lueSystemUser.EditValue); ReloadGridView(IDSystemUser); } } } catch (Exception ex) { MessageBox.Show("frmIns_Contracts.btnAddNew_Click\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { int ID = Convert.ToInt32(viewContracts.GetFocusedRowCellValue("ID")); DialogResult result = MessageBox.Show("Bạn có chắc chắn muốn xóa ???", "Câu hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (DialogResult.Yes == result) { try { ContractsBO aContractsBO = new ContractsBO(); aContractsBO.Delete(ID); MessageBox.Show("Bạn đã xóa dữ liệu thành công .", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("frmLst_Contracts.btnDelete_ButtonClick\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.ReloadData(); }
private void btnSearch_Click(object sender, EventArgs e) { try { DateTime From = dtpFrom.DateTime; DateTime To = dtpTo.DateTime; if (From >= To) { MessageBox.Show("Vui lòng chọn ngày bắt đầu tìm nhỏ hơn ngày kết thúc tìm.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ContractsBO aContractsBO = new ContractsBO(); List<Contracts> aListContracts = aContractsBO.Select_ByFromDate_ByToDate(From,To); if (aListContracts.Count > 0) { colContractDate.DisplayFormat.FormatType = FormatType.DateTime; colContractDate.DisplayFormat.FormatString = "{0:dd/MM/yyyy}"; colFrom.DisplayFormat.FormatType = FormatType.DateTime; colFrom.DisplayFormat.FormatString = "{0:dd/MM/yyyy}"; colTo.DisplayFormat.FormatType = FormatType.DateTime; colTo.DisplayFormat.FormatString = "{0:dd/MM/yyyy}"; colCoefficent.DisplayFormat.FormatType = FormatType.Numeric; colCoefficent.DisplayFormat.FormatString = "{0:0,0}"; colSalaryNet.DisplayFormat.FormatType = FormatType.Numeric; colSalaryNet.DisplayFormat.FormatString = "{0:0,0}"; colSalaryCross.DisplayFormat.FormatType = FormatType.Numeric; colSalaryCross.DisplayFormat.FormatString = "{0:0,0}"; dgvContracts.DataSource = aListContracts; } else { this.ReloadData(); } } } catch (Exception ex) { MessageBox.Show("frmLst_Contracts.btnSearch_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (this.CheckDataBeforUpdate() == true) { ContractsBO aContractsBO = new ContractsBO(); Contracts aContracts = aContractsBO.Select_ByID(ID); aContracts.ContractDate =dtpContractDate.DateTime; aContracts.NumberContract = txtNumberContract.Text; aContracts.NumberTemplateContract = txtNumberTemplateContract.Text; aContracts.Company = txtCompany.Text; aContracts.StatutoryRepresent = txtStatutoryRepresent.Text; aContracts.StatutoryRepresentGender = Convert.ToInt32(txtStatutoryRepresentGender.Text); aContracts.StatutoryRepresentIdentifier = txtStatutoryRepresentIdentifier.Text; aContracts.ContractType = Convert.ToInt32(txtContractType.Text); aContracts.FromDate =dtpFrom.DateTime; aContracts.ToDate =dtpTo.DateTime; aContracts.SkuTableSalary = Convert.ToInt32(txtSkuTableSalary.Text); aContracts.Coefficent = Convert.ToDouble(txtCoefficent.Text); aContracts.SalaryNet = Convert.ToDecimal(txtSalaryNet.Text); aContracts.SalaryCross = Convert.ToDecimal(txtSalaryCross.Text); aContracts.Type = cboType.SelectedIndex + 1; aContracts.Status = cboStatus.SelectedIndex + 1; aContracts.Disable = Convert.ToBoolean(cboDisable.Text); aContractsBO.Update(aContracts); if (this.afrmLst_Contracts != null) { this.afrmLst_Contracts.ReloadData(); } MessageBox.Show("Cập nhật dữ liệu thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { MessageBox.Show("frmUpd_Contracts.btnSave_Click\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmUpd_Contracts_Load(object sender, EventArgs e) { try { ContractsBO aContractsBO = new ContractsBO(); Contracts aContracts = aContractsBO.Select_ByID(ID); txtNumberContract.Text = aContracts.NumberContract.ToString(); txtNumberTemplateContract.Text = aContracts.NumberTemplateContract.ToString(); dtpContractDate.EditValue = aContracts.ContractDate; txtCompany.Text = aContracts.Company.ToString(); txtStatutoryRepresent.Text = aContracts.StatutoryRepresent.ToString(); txtStatutoryRepresentGender.Text = aContracts.StatutoryRepresentGender.ToString(); txtStatutoryRepresentIdentifier.Text = aContracts.StatutoryRepresentIdentifier.ToString(); txtContractType.Text = aContracts.ContractType.ToString(); dtpFrom.EditValue = aContracts.FromDate; dtpTo.EditValue = aContracts.ToDate; txtSkuTableSalary.Text = aContracts.SkuTableSalary.ToString(); txtCoefficent.Text = String.Format("{0:0,0}",aContracts.Coefficent); txtSalaryNet.Text = String.Format("{0:0,0}",aContracts.SalaryNet); txtSalaryCross.Text = String.Format("{0:0,0}",aContracts.SalaryCross); cboType.SelectedIndex = Convert.ToInt32(aContracts.Type - 1); cboStatus.SelectedIndex = Convert.ToInt32(aContracts.Status - 1); cboDisable.Text = aContracts.Disable.ToString(); } catch (Exception ex) { MessageBox.Show("frmUpd_Contracts.frmUpd_Contracts_Load\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }