private void btnEdit_Click(object sender, EventArgs e) { try { if (ValidateData() == true) { Allowances aAllowances = new Allowances(); aAllowances.ID = ID_Old; aAllowances.SalaryPlus = Convert.ToDecimal(txtSalaryPlus.EditValue); aAllowances.CreatedDate = dtpCreateDate.DateTime; aAllowances.ContractType = Convert.ToInt32(lueContractType.EditValue); //tqtrung aAllowances.Type =Convert.ToInt32(cbbType.Text); //end aAllowances.Disable = bool.Parse(cbbDisable.Text); aAllowances.Status = int.Parse(cbbStatus.Text); aAllowancesBO.Update(aAllowances); if (this.afrmLst_Allowances_Old != null) { this.afrmLst_Allowances_Old.Reload(); } MessageBox.Show("Sửa thành công !", "Success ", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { MessageBox.Show("frmUpd_Allowances.btnEdit \n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Author : LinhTing //Function : Insert Allowances public int Insert(Allowances aAllowances) { try { aDatabaseDA.Allowances.Add(aAllowances); return aDatabaseDA.SaveChanges(); } catch (Exception ex) { throw new Exception(string.Format("AllowancesBO.Insert :"+ ex.Message.ToString())); } }