private void btnAdd_Click(object sender, EventArgs e) { try { if (ValidateData() == true) { DateTime? NullDatetime = null; IFormatProvider culture = new System.Globalization.CultureInfo("fr-FR", true); //Disable tính lương cũ CalculatorSalaries aCalculatorSalaries_Old = new CalculatorSalaries(); List<CalculatorSalaries> aLisTemp = aCalculatorSalariesBO.Select_ByIDSystemUser(Convert.ToInt16(lueIDSystemUser.EditValue)); if (aLisTemp!= null) { aCalculatorSalaries_Old = aLisTemp.Where(a => a.Disable == false).ToList()[0]; aCalculatorSalaries_Old.Disable = true; aCalculatorSalariesBO.Update(aCalculatorSalaries_Old); } // Tạo tính lương mới CalculatorSalaries aCalculatorSalaries = new CalculatorSalaries(); aCalculatorSalaries.IDSystemUser = Convert.ToInt16(lueIDSystemUser.EditValue); aCalculatorSalaries.SkuTableSalary = Convert.ToString(lueSku.EditValue); aCalculatorSalaries.Coefficent = Convert.ToDouble(lueCoefficent.EditValue); aCalculatorSalaries.StartDate = dtpStartDate.EditValue == null ? NullDatetime : dtpStartDate.DateTime; aCalculatorSalaries.EndDate = dtpEndDate.EditValue == null ? NullDatetime : dtpEndDate.DateTime; aCalculatorSalaries.Type = cbbType.SelectedIndex; aCalculatorSalaries.Status = cbbStatus.SelectedIndex; aCalculatorSalaries.Disable = false; aCalculatorSalariesBO.Insert(aCalculatorSalaries); MessageBox.Show("Thêm mới thành công !", "Success ", MessageBoxButtons.OK, MessageBoxIcon.Information); if (this.afrmLst_CalculatorSalaries_Old != null) { this.afrmLst_CalculatorSalaries_Old.Reload(); this.Close(); } else if (this.afrmMain != null) { this.afrmMain.ReloadGridView(); this.Close(); } else { int IDSystemUser = Convert.ToInt32(lueIDSystemUser.EditValue); ReloadGridView(IDSystemUser); } } } catch (Exception ex) { MessageBox.Show("frmIns_CalculatorSalaries.btnAdd_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Author : LinhTing //Function : Insert CalculatorSalaries public int Insert(CalculatorSalaries aCalculatorSalaries) { try { aDatabaseDA.CalculatorSalaries.Add(aCalculatorSalaries); return aDatabaseDA.SaveChanges(); } catch (Exception ex) { throw new Exception(string.Format("CalculatorSalariesBO.Insert :"+ ex.Message.ToString())); } }
public void SetValue(CalculatorSalaries aCalculatorSalaries) { this.ID = aCalculatorSalaries.ID; this.SkuTableSalary = aCalculatorSalaries.SkuTableSalary; this.Coefficent = aCalculatorSalaries.Coefficent; this.StartDate = aCalculatorSalaries.StartDate; this.EndDate = aCalculatorSalaries.EndDate; this.Status = aCalculatorSalaries.Status; this.Type = aCalculatorSalaries.Type; this.Disable = aCalculatorSalaries.Disable; this.IDSystemUser = aCalculatorSalaries.IDSystemUser; }
private void btnEdit_Click(object sender, EventArgs e) { try { if (this.ValidateData() == true) { CalculatorSalaries aCalculatorSalaries = new CalculatorSalaries(); DateTime? NullDatetime = null; aCalculatorSalaries.ID = ID_Old; aCalculatorSalaries.IDSystemUser = Convert.ToInt32(lueIDSystemUser.EditValue); aCalculatorSalaries.SkuTableSalary = Convert.ToString(lueSku.EditValue); aCalculatorSalaries.Coefficent = Convert.ToDouble(lueCoefficent.EditValue); aCalculatorSalaries.StartDate = dtpStartDate.EditValue == null ? NullDatetime : dtpStartDate.DateTime; aCalculatorSalaries.EndDate = dtpEndDate.EditValue == null ? NullDatetime : dtpEndDate.DateTime; aCalculatorSalaries.Type =cbbType.SelectedIndex; aCalculatorSalaries.Status =cbbStatus.SelectedIndex; aCalculatorSalaries.Disable = bool.Parse(cbbDisable.Text); aCalculatorSalariesBO.Update(aCalculatorSalaries); if (this.afrmLst_CalculatorSalaries_Old != null) { this.afrmLst_CalculatorSalaries_Old.Reload(); } MessageBox.Show("Sửa thành công !", "Success ", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { MessageBox.Show("frmUpd_CalculatorSalaries.btnEdit_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }