public BaseTranDetail(TranCodeDetailFull_Info trancodedetail, string accountIdCust) { if (trancodedetail == null) { throw new Exception("trancodedetail is null or empty"); } _trandaydetail = new TrandayDetail_Info(); // kiểm tra gan tài khoản khách hàng. D_Account dalAccount = new D_Account(); Account_Info acInfo; if (trancodedetail.Is_Account_Cust == true) { // Xác định sự tồn tại của tài khoản khách hàng acInfo = dalAccount.GetOneAccount(accountIdCust); if (acInfo == null) { throw new Exception("AccountId Customer not found"); } _trandaydetail.Account_ID = accountIdCust; } else { List <Account_Info> list = dalAccount.GetListAccountLike(trancodedetail.Account_ID, trancodedetail.Categories); if (list.Count > 1 || list.Count == 0) { throw new Exception("AccountId invalid"); } _trandaydetail.Account_ID = list[0].Account_ID; } _trancodedetail = trancodedetail; _trandaydetail.SEQ = trancodedetail.SEQ; switch (trancodedetail.NumberType) { case NumberType.FixAmount: if (trancodedetail.CreditDebit == "DB") { _trandaydetail.DB_Amount = (decimal)trancodedetail.NumberValue; _completed = true; } else { _trandaydetail.CR_Amount = (decimal)trancodedetail.NumberValue; _completed = true; } break; default: _trandaydetail.DB_Amount = 0; _trandaydetail.CR_Amount = 0; _completed = false; break; } }
public BaseTrandayDetail(TranCodeDetailFull_Info trancodedetail, string accountIdCust, decimal amount) : base(trancodedetail, accountIdCust) { switch (trancodedetail.NumberType) { case NumberType.FixAmount: if (this.IsCompleted == false) { if (trancodedetail.CreditDebit == "DB") { this.TranDayDetailInfo.DB_Amount = (decimal)trancodedetail.NumberValue; this.IsCompleted = true; } else { this.TranDayDetailInfo.CR_Amount = (decimal)trancodedetail.NumberValue; this.IsCompleted = true; } } break; case NumberType.Percentage: if (trancodedetail.CreditDebit == "DB") { this.TranDayDetailInfo.DB_Amount = amount * (decimal)trancodedetail.NumberValue; this.IsCompleted = true; } else { this.TranDayDetailInfo.CR_Amount = amount * (decimal)trancodedetail.NumberValue; this.IsCompleted = true; } break; case NumberType.NA: this.IsCompleted = false; break; } }
private TranCodeDetailFull_Info GenerateObj(DataRow row) { if (row == null) { throw new Exception("Data object is null or empty"); } TranCodeDetailFull_Info objTranCodeDetailInfo = new TranCodeDetailFull_Info(); if (row["Code"] != DBNull.Value) { objTranCodeDetailInfo.Code = Convert.ToString(row["Code"]); } if (row["Name"] != DBNull.Value) { objTranCodeDetailInfo.Name = Convert.ToString(row["Name"]); } if (row["Status"] != DBNull.Value) { objTranCodeDetailInfo.Status = Convert.ToBoolean(row["Status"]); } if (row["DirecobjTranCodeDetailInfoon"] != DBNull.Value) { objTranCodeDetailInfo.Categories = Convert.ToString(row["Categories"]); } if (row["NextCode"] != DBNull.Value) { objTranCodeDetailInfo.NextCode = Convert.ToString(row["NextCode"]); } if (row["CostCode"] != DBNull.Value) { objTranCodeDetailInfo.CostCode = Convert.ToString(row["CostCode"]); } if (row["Descript"] != DBNull.Value) { objTranCodeDetailInfo.Descript = Convert.ToString(row["Descript"]); } if (row["CodeType"] != DBNull.Value) { objTranCodeDetailInfo.CodeType = Convert.ToString(row["CodeType"]); } if (row["Report"] != DBNull.Value) { objTranCodeDetailInfo.Report = Convert.ToBoolean(row["Report"]); } if (row["Display"] != DBNull.Value) { objTranCodeDetailInfo.Display = Convert.ToBoolean(row["Display"]); } if (row["Formula"] != DBNull.Value) { objTranCodeDetailInfo.Formula = Convert.ToString(row["Fomular"]); } if (row["RefNum"] != DBNull.Value) { objTranCodeDetailInfo.RefNum = Convert.ToString(row["RefNum"]); } if (row["CheckOn"] != DBNull.Value) { objTranCodeDetailInfo.CheckOn = Convert.ToBoolean(row["CheckOn"]); } if (row["DateCreated"] != DBNull.Value) { objTranCodeDetailInfo.DateCreated = Convert.ToDateTime(row["DateCreated"]); } if (row["UserCreate"] != DBNull.Value) { objTranCodeDetailInfo.UserCreate = Convert.ToString(row["UserCreate"]); } if (row["Branch_ID"] != DBNull.Value) { objTranCodeDetailInfo.Branch_ID = Convert.ToString(row["Branch_ID"]); } if (row["id"] != DBNull.Value) { objTranCodeDetailInfo.ID = Convert.ToDecimal(row["id"]); } if (row["Account_ID"] != DBNull.Value) { objTranCodeDetailInfo.Account_ID = Convert.ToString(row["Account_ID"]); } if (row["CreditDebit"] != DBNull.Value) { objTranCodeDetailInfo.CreditDebit = Convert.ToString(row["CreditDebit"]); } if (row["NumType"] != DBNull.Value) { objTranCodeDetailInfo.NumberType = (NumberType)Enum.Parse(typeof(NumberType), row["NumType"].ToString()); } if (row["NumValue"] != DBNull.Value) { objTranCodeDetailInfo.NumberValue = Convert.ToSingle(row["NumValue"]); } if (row["SEQ"] != DBNull.Value) { objTranCodeDetailInfo.SEQ = Convert.ToInt32(row["SEQ"]); } if (row["IsAccountCust"] != DBNull.Value) { objTranCodeDetailInfo.Is_Account_Cust = Convert.ToBoolean(row["IsAccountCust"]); } if (row["Master"] != DBNull.Value) { objTranCodeDetailInfo.Master = Convert.ToBoolean(row["Master"]); } return(objTranCodeDetailInfo); }