public DiscountInfo Calculation(DiscountInfo discountInfo) { discountInfo.DisAmount = 0M; DataTable tempDt = NewDao <IPromotionProjectDao>().QueryPromotionDetail(PatientType, CostType, CardID, PromType); if (tempDt.Rows.Count > 0) { int PromBase = Convert.ToInt16(tempDt.Rows[0]["PromBase"]); //优惠基数 int Disco = Convert.ToInt16(tempDt.Rows[0]["DiscountNumber"]); //优惠数字 int PromID = Convert.ToInt16(tempDt.Rows[0]["PromID"]); //优惠方案ID string PromName = Convert.ToString(tempDt.Rows[0]["PromName"]); //优惠方案名称 int PromSunID = Convert.ToInt32(tempDt.Rows[0]["PromSunID"]); //优惠方案明细ID //当消费总额大于优惠基数时 if (discountInfo.Amount > PromBase) { if (Convert.ToInt16(tempDt.Rows[0]["Prom"]) == 1) //优惠方式为折扣方式 { discountInfo.DisAmount = discountInfo.Amount * Disco / 100; } else { if (discountInfo.Amount > Disco) //如果金额大于优惠 { discountInfo.DisAmount = Disco; } else { discountInfo.DisAmount = 0; } } } ME_DiscountList DiscountList = new ME_DiscountList(); DiscountList.PromID = PromID; DiscountList.AccountID = discountInfo.AccountID; DiscountList.SettlementNO = discountInfo.SettlementNO; DiscountList.PromName = PromName; DiscountList.PromSunID = PromSunID; DiscountList.CostTypeID = CostType; DiscountList.CardTypeID = CardID; //帐户表ID DiscountList.PatientType = PatientType; //病人类型门诊或住院 DiscountList.PromTypeID = PromType; //优惠类型 DiscountList.PromBase = PromBase; DiscountList.Prom = 1; // DiscountList.IsValid = 0; DiscountList.AccID = discountInfo.AccID; DiscountList.DiscountNumber = Disco; DiscountList.Amount = discountInfo.Amount; DiscountList.DiscountTotal = discountInfo.DisAmount; DiscountList.OperateDate = System.DateTime.Now; DiscountList.OperateID = discountInfo.OperateID; discountInfo.DiscountList.Add(DiscountList); } return(discountInfo); }
public DiscountInfo Calculation(DiscountInfo discountInfo) { decimal res = 0M; DataTable tempDt = NewDao <IPromotionProjectDao>().QueryPromotionDetail(PatientType, CostType, CardID, PromType);//获取优惠明细 for (int j = 0; j < tempDt.Rows.Count; j++) { int PromClass = Convert.ToInt16(tempDt.Rows[j]["PromClass"]); //优惠明细项目类别ID int Disco = Convert.ToInt16(tempDt.Rows[j]["DiscountNumber"]); //优惠额度 int promBase = Convert.ToInt16(tempDt.Rows[j]["PromBase"]); //优惠基数 string PromName = Convert.ToString(tempDt.Rows[0]["PromName"]); //优惠方案名称 int PromSunID = Convert.ToInt32(tempDt.Rows[0]["PromSunID"]); //优惠方案明细ID int PromID = Convert.ToInt16(tempDt.Rows[0]["PromID"]); //优惠方案ID decimal tempAount2 = 0; //当消费总额大于优惠基数时 DataRow[] drTemp = discountInfo.DtClass.Select(" ClassTypeID=" + PromClass); // decimal tempAount = 0; foreach (DataRow dr in drTemp) { //当消费总额大于优惠基数时 if (Convert.ToDecimal(dr["ClassAmount"]) > promBase) { if (Convert.ToInt32(tempDt.Rows[j]["Prom"]) == 1) //优惠方式为折扣方式 { tempAount = Convert.ToDecimal(dr["ClassAmount"]) * Disco / 100; } else { if (Convert.ToDecimal(dr["ClassAmount"]) > Disco) //如果金额大于优惠 { tempAount = Disco; } else { tempAount = 0; } } tempAount2 = tempAount2 + tempAount; dr["PromAmount"] = tempAount; } else { dr["PromAmount"] = 0M; } discountInfo.DtClass.AcceptChanges(); ME_DiscountList DiscountList = new ME_DiscountList(); DiscountList.AccountID = discountInfo.AccountID; DiscountList.PromID = PromID; DiscountList.SettlementNO = discountInfo.SettlementNO; DiscountList.PromName = PromName; DiscountList.PromSunID = PromSunID; DiscountList.CostTypeID = CostType; DiscountList.CardTypeID = CardID; //帐户表ID DiscountList.PatientType = PatientType; //病人类型门诊或住院 DiscountList.PromTypeID = PromType; //优惠类型 DiscountList.PromBase = promBase; DiscountList.PromClass = PromClass; DiscountList.Prom = 2; // DiscountList.IsValid = 0; DiscountList.AccID = discountInfo.AccID; DiscountList.DiscountNumber = Disco; DiscountList.Amount = discountInfo.Amount; DiscountList.DiscountTotal = tempAount; DiscountList.OperateDate = System.DateTime.Now; DiscountList.OperateID = discountInfo.OperateID; discountInfo.DiscountList.Add(DiscountList); } res = res + tempAount2; } discountInfo.DisAmount = res; return(discountInfo); }