public bool ThemDong(DOLuong luong) { bool Kq = false; try { DatabaseFB db = HelpDB.getDatabase(); string InsertSql = "insert into BANG_LUONG(ID,NV_ID,THANG_NAM,TONG_THU_NHAP,TAM_UNG,IS_CHOT,DA_THANH_TOAN,TT_CON_LAI) values(@ID,@NV_ID,@THANG_NAM,@TONG_THU_NHAP,@TAM_UNG,'N',0,@TT_CON_LAI)"; DbCommand insert = db.GetSQLStringCommand(InsertSql); db.AddInParameter(insert, "@ID", DbType.Int32, luong.ID); db.AddInParameter(insert, "@NV_ID", DbType.Int32, luong.NV_ID); db.AddInParameter(insert, "@THANG_NAM", DbType.String, luong.THANG_NAM); db.AddInParameter(insert, "@TONG_THU_NHAP", DbType.Decimal, luong.TONG_THU_NHAP); db.AddInParameter(insert, "@TAM_UNG", DbType.Decimal, luong.TAM_UNG); db.AddInParameter(insert, "@TT_CON_LAI", DbType.Decimal, luong.TONG_THU_NHAP-luong.TAM_UNG-0); if (db.ExecuteNonQuery(insert) > 0) Kq = true; } catch (Exception ex) { PLException.AddException(ex); } return Kq; }
public bool SuaDong(DOLuong luong) { DatabaseFB db = HelpDB.getDatabase(); string cautruyvan = @"update BANG_LUONG set TONG_THU_NHAP=@TONG_THU_NHAP,TAM_UNG=@TAM_UNG,TT_CON_LAI = @TT_CON_LAI - DA_THANH_TOAN WHERE ID=@ID "; DbCommand update = db.GetSQLStringCommand(cautruyvan); db.AddInParameter(update, "@ID", DbType.Int32, luong.ID); db.AddInParameter(update, "@TONG_THU_NHAP", DbType.Decimal, luong.TONG_THU_NHAP); db.AddInParameter(update, "@TAM_UNG", DbType.Decimal, luong.TAM_UNG); db.AddInParameter(update, "@TT_CON_LAI", DbType.Decimal, luong.TONG_THU_NHAP-luong.TAM_UNG); if (db.ExecuteNonQuery(update) > 0) return true; return false; }