private List<double> ConvertCoe(TableSalaries aTableSalaries)
        {
            try
            {
                List<double> ret = new List<double>();
                ret.Insert(0, aTableSalaries.Coe1.GetValueOrDefault(0));
                ret.Insert(1, aTableSalaries.Coe2.GetValueOrDefault(0));
                ret.Insert(2, aTableSalaries.Coe3.GetValueOrDefault(0));
                ret.Insert(3, aTableSalaries.Coe4.GetValueOrDefault(0));
                ret.Insert(4, aTableSalaries.Coe5.GetValueOrDefault(0));
                ret.Insert(5, aTableSalaries.Coe6.GetValueOrDefault(0));
                ret.Insert(6, aTableSalaries.Coe7.GetValueOrDefault(0));
                ret.Insert(7, aTableSalaries.Coe8.GetValueOrDefault(0));
                ret.Insert(8, aTableSalaries.Coe9.GetValueOrDefault(0));
                ret.Insert(9, aTableSalaries.Coe10.GetValueOrDefault(0));
                ret.Insert(10, aTableSalaries.Coe11.GetValueOrDefault(0));
                ret.Insert(11, aTableSalaries.Coe12.GetValueOrDefault(0));
                ret.Insert(12, aTableSalaries.Coe13.GetValueOrDefault(0));
                ret.Insert(13, aTableSalaries.Coe14.GetValueOrDefault(0));
                ret.Insert(14, aTableSalaries.Coe15.GetValueOrDefault(0));
                ret.Insert(15, aTableSalaries.Coe16.GetValueOrDefault(0));
                return ret;

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmUpd_CalculatorSalaries.ConvertCoe\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
        }
 //Author : LinhTing
 //Function : Insert TableSalaries
 public int Insert(TableSalaries aTableSalaries)
 {
     try
     {
         aDatabaseDA.TableSalaries.Add(aTableSalaries);
         return aDatabaseDA.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("TableSalariesBO.Insert :"+ ex.Message.ToString()));
     }
 }
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            try
            {
                TableSalariesBO aTableSalariesBO = new TableSalariesBO();
                GroupTableSalariesBO aGroupTableSalariesBO = new GroupTableSalariesBO();
                if (ValidateData() == true)
                {
                    DateTime? NullDatetime = null;
                    // Disable Nhóm bảng lương cũ
                     GroupTableSalaries aGroupTableSalaries_Old = aGroupTableSalariesBO.Select_ByDisable();
                    if( aGroupTableSalaries_Old != null)
                    {
                        aGroupTableSalaries_Old.Disable = true;
                        aGroupTableSalaries_Old.EndDate = DateTime.Now;
                        aGroupTableSalariesBO.Update(aGroupTableSalaries_Old);
                    }
                    // Thêm Nhóm bảng lương mới
                    GroupTableSalaries aGroupTableSalaries_New = new GroupTableSalaries();
                    aGroupTableSalaries_New.Name = txtName.Text;
                    aGroupTableSalaries_New.EndDate = dtpEndDate.EditValue == null ? NullDatetime : dtpEndDate.DateTime;
                    aGroupTableSalaries_New.StartDate = dtpStartDate.EditValue == null ? NullDatetime : dtpStartDate.DateTime;
                    aGroupTableSalaries_New.Type = 1;
                    aGroupTableSalaries_New.Status = 1;
                    aGroupTableSalaries_New.Disable = false;
                    aGroupTableSalariesBO.Insert(aGroupTableSalaries_New);

                    // Thêm bảng lương vào nhóm bảng lương mới
                        TableSalaries aTableSalaries;
                        for (int i = 0; i < grvTableSalaries.RowCount; i++)
                        {
                            aTableSalaries = new TableSalaries();
                            aTableSalaries.IDGroupTableSalary = aGroupTableSalaries_New.ID;
                            aTableSalaries.Name = grvTableSalaries.GetRowCellValue(i, "Name").ToString();
                            aTableSalaries.NumCoefficents = Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "NumCoefficents"));
                            aTableSalaries.Sku = grvTableSalaries.GetRowCellValue(i, "Sku").ToString();

                            aTableSalaries.Coe1 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe1").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe1"));
                            aTableSalaries.Coe2 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe2").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe2"));
                            aTableSalaries.Coe3 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe3").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe3"));
                            aTableSalaries.Coe4 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe4").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe4"));
                            aTableSalaries.Coe5 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe5").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe5"));
                            aTableSalaries.Coe6 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe6").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe6"));
                            aTableSalaries.Coe7 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe7").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe7"));
                            aTableSalaries.Coe8 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe8").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe8"));
                            aTableSalaries.Coe9 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe9").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe9"));
                            aTableSalaries.Coe10 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe10").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe10"));
                            aTableSalaries.Coe11 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe11").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe11"));
                            aTableSalaries.Coe12 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe12").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe12"));
                            aTableSalaries.Coe13 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe13").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe13"));
                            aTableSalaries.Coe14 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe14").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe14"));
                            aTableSalaries.Coe15 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe15").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe15"));
                            aTableSalaries.Coe16 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Coe16").ToString()) ? 0 : Convert.ToDouble(grvTableSalaries.GetRowCellValue(i, "Coe16"));
                            aTableSalaries.Jump1 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump1").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump1"));
                            aTableSalaries.Jump2 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump2").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump2"));
                            aTableSalaries.Jump3 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump3").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump3"));
                            aTableSalaries.Jump4 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump4").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump4"));
                            aTableSalaries.Jump5 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump5").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump5"));
                            aTableSalaries.Jump6 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump6").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump6"));
                            aTableSalaries.Jump7 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump7").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump7"));
                            aTableSalaries.Jump8 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump8").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump8"));
                            aTableSalaries.Jump9 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump9").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump9"));
                            aTableSalaries.Jump10 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump10").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump10"));
                            aTableSalaries.Jump11 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump11").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump11"));
                            aTableSalaries.Jump12 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump12").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump12"));
                            aTableSalaries.Jump13 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump13").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump13"));
                            aTableSalaries.Jump14 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump14").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump14"));
                            aTableSalaries.Jump15 = string.IsNullOrEmpty(grvTableSalaries.GetRowCellValue(i, "Jump15").ToString()) ? 0 : Convert.ToInt32(grvTableSalaries.GetRowCellValue(i, "Jump15"));
                            aTableSalariesBO.Insert(aTableSalaries);
                        }
                        if (this.afrmLst_TableSalaries_Old != null)
                        {
                            this.afrmLst_TableSalaries_Old.Reload();
                        }
                        MessageBox.Show("Thêm mới thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }

            catch (Exception ex)
            {
                MessageBox.Show("frmIns_TableSalaries.btnAdd_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }