protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e) { Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict(); foreach (int rowIndex in modifiedDict.Keys) { int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]); ContractCarPriceSetInfo objInfo = Core.Container.Instance.Resolve <IServiceContractCarPriceSetInfo>().GetEntity(rowID); if (modifiedDict[rowIndex].Keys.Contains("TonPayPrice")) { objInfo.TonPayPrice = Convert.ToDecimal(modifiedDict[rowIndex]["TonPayPrice"]); } if (modifiedDict[rowIndex].Keys.Contains("CarPayPrice")) { objInfo.CarPayPrice = Convert.ToDecimal(modifiedDict[rowIndex]["CarPayPrice"]); } if (modifiedDict[rowIndex].Keys.Contains("MinTon")) { objInfo.MinTon = Convert.ToDecimal(modifiedDict[rowIndex]["MinTon"]); } Core.Container.Instance.Resolve <IServiceContractCarPriceSetInfo>().Update(objInfo); } BindGrid(); }
/// <summary> /// 绑定车辆费用信息 /// </summary> private void BindGrid() { //获取合同车辆费用信息 IList <ICriterion> qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("ContractID", ContractID)); //从默认的销售库房中获取当前库存大于0的物品信息 IList <ContractCarPriceSetInfo> list = Core.Container.Instance.Resolve <IServiceContractCarPriceSetInfo>().GetAllByKeys(qryList); if (list.Count > 0) { foreach (ContractCarPriceSetInfo detail in list) { detail.CarInfo = Core.Container.Instance.Resolve <IServiceCarInfo>().GetEntity(detail.CarID); } } else { #region 创建车辆报价 //获取车辆信息 qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("IsUsed", "1")); IList <CarInfo> carList = Core.Container.Instance.Resolve <IServiceCarInfo>().GetAllByKeys(qryList); ContractCarPriceSetInfo carSetInfo = new ContractCarPriceSetInfo(); //创建车辆运费 foreach (CarInfo obj in carList) { carSetInfo = new ContractCarPriceSetInfo(); carSetInfo.ContractID = ContractID; carSetInfo.CarID = obj.ID; carSetInfo.CarPayPrice = 0; carSetInfo.TonPayPrice = 0; carSetInfo.MinTon = 20; Core.Container.Instance.Resolve <IServiceContractCarPriceSetInfo>().Create(carSetInfo); } #endregion 创建车辆报价 list = Core.Container.Instance.Resolve <IServiceContractCarPriceSetInfo>().GetAllByKeys(qryList); } Grid1.DataSource = list; Grid1.DataBind(); }
/// <summary> /// 根据费用项费用价格获取类型获取价格 /// </summary> /// <param name="costProjectInfo">费用项信息</param> /// <param name="orderInfo">订单信息</param> /// <returns>价格</returns> private decimal GetCostPayPrice(RepairProjectInfo costProjectInfo, ContractOrderInfo orderInfo) { decimal payPrice = costProjectInfo.PayPrice; IList <ICriterion> qryList = new List <ICriterion>(); //获取费用项适用范围 string[] ids = costProjectInfo.UsingGoods.Split(','); //如果费用单价是从合同获取,根据合同获取单价【费用价格获取类型 0:自定义 1:合同客户运费 2:合同司机运费 3:合同单价 4:合同维修单价】 if (costProjectInfo.PriceSourceType > 0) { switch (costProjectInfo.PriceSourceType) { //合同客户运费(获取合同设定运费) case 1: //payPrice = orderInfo.ContractInfo.CarCostPrice; break; //合同司机运费(获取订单选择的车辆在合同中设定运费) case 2: //获取合同车辆信息 qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("CarID", orderInfo.CarID)); qryList.Add(Expression.Eq("ContractID", orderInfo.ContractInfo.ID)); ContractCarPriceSetInfo carPriceSetInfo = Core.Container.Instance.Resolve <IServiceContractCarPriceSetInfo>().GetEntityByFields(qryList); payPrice = carPriceSetInfo.TonPayPrice; break; //合同单价(获取租赁物品在合同中设定的单价) case 3: if (ids.Length > 0) { qryList = new List <ICriterion>(); // qryList.Add(Expression.Eq("SetID", orderInfo.ContractInfo.PriceSetID)); qryList.Add(Expression.Eq("GoodsTypeID", ids[0])); Order[] orderList = new Order[1]; Order orderli = new Order("ID", true); orderList[0] = orderli; //获取价格套系中物品设定信息 PriceSetGoodsInfo goodsInfo = Core.Container.Instance.Resolve <IServicePriceSetGoodsInfo>().GetFirstEntityByFields(qryList, orderList); //获取物品单价 payPrice = goodsInfo.UnitPrice; } break; //合同维修单价(获取租赁物品在合同中设定的维修价) case 4: if (ids.Length > 0) { qryList = new List <ICriterion>(); //qryList.Add(Expression.Eq("SetID", orderInfo.ContractInfo.PriceSetID)); qryList.Add(Expression.Eq("GoodsTypeID", int.Parse(ids[0]))); Order[] orderList = new Order[1]; Order orderli = new Order("ID", true); orderList[0] = orderli; //获取价格套系中物品设定信息 PriceSetGoodsInfo goodsInfo = Core.Container.Instance.Resolve <IServicePriceSetGoodsInfo>().GetFirstEntityByFields(qryList, orderList); //获取物品维修单价 payPrice = goodsInfo.FixPrice; } break; default: break; } } return(payPrice); }
/// <summary> /// 各类费用计算 /// </summary> /// <param name="costInfo">费用项信息</param> private void CalcCost(ContractOrderCostInfo costInfo) { //获取费用项信息 RepairProjectInfo costProjectInfo = Core.Container.Instance.Resolve <IServiceRepairProjectInfo>().GetEntity(costInfo.CostID); //获取费用项适用范围 string[] ids = costProjectInfo.UsingGoods.Split(','); //获取订单信息 IList <ICriterion> qryList = new List <ICriterion>(); qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("OrderNO", OrderNO)); ContractOrderInfo orderInfo = Core.Container.Instance.Resolve <IServiceContractOrderInfo>().GetEntityByFields(qryList); #region 获取费用项单价 costInfo.PayPrice = costProjectInfo.PayPrice; //如果费用单价是从合同获取,根据合同获取单价【费用价格获取类型 0:自定义 1:合同客户运费 2:合同司机运费 3:合同单价 4:合同维修单价】 if (costProjectInfo.PriceSourceType > 0) { switch (costProjectInfo.PriceSourceType) { //合同客户运费(获取合同设定运费) case 1: //costInfo.PayPrice = orderInfo.ContractInfo.CarCostPrice; break; //合同司机运费(获取订单选择的车辆在合同中设定运费) case 2: //获取合同车辆信息 qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("CarID", orderInfo.CarID)); ContractCarPriceSetInfo carPriceSetInfo = Core.Container.Instance.Resolve <IServiceContractCarPriceSetInfo>().GetEntityByFields(qryList); costInfo.PayPrice = carPriceSetInfo.TonPayPrice; break; //合同单价(获取租赁物品在合同中设定的单价) case 3: if (ids.Length > 0) { qryList = new List <ICriterion>(); //qryList.Add(Expression.Eq("SetID", orderInfo.ContractInfo.PriceSetID)); qryList.Add(Expression.Eq("GoodsTypeID", ids[0])); Order[] orderList = new Order[1]; Order orderli = new Order("ID", true); orderList[0] = orderli; //获取价格套系中物品设定信息 PriceSetGoodsInfo goodsInfo = Core.Container.Instance.Resolve <IServicePriceSetGoodsInfo>().GetFirstEntityByFields(qryList, orderList); //获取物品单价 costInfo.PayPrice = goodsInfo.UnitPrice; } break; //合同维修单价(获取租赁物品在合同中设定的维修价) case 4: if (ids.Length > 0) { qryList = new List <ICriterion>(); //qryList.Add(Expression.Eq("SetID", orderInfo.ContractInfo.PriceSetID)); qryList.Add(Expression.Eq("GoodsTypeID", ids[0])); Order[] orderList = new Order[1]; Order orderli = new Order("ID", true); orderList[0] = orderli; //获取价格套系中物品设定信息 PriceSetGoodsInfo goodsInfo = Core.Container.Instance.Resolve <IServicePriceSetGoodsInfo>().GetFirstEntityByFields(qryList, orderList); //获取物品维修单价 costInfo.PayPrice = goodsInfo.FixPrice; } break; default: break; } } #endregion 获取费用项单价 #region 获取费用项计价数量 string sql = string.Empty; //1:数量 2:计价单位 3:客户吨位 4:员工吨位 5:司机吨位 6:其他 switch (costProjectInfo.PayUnit) { //收货出库数量,收货明细表:GoodsNumber case "1": //获取运送获取重量信息 if (!string.IsNullOrEmpty(costProjectInfo.UsingGoods)) { sql = string.Format(@"select sum(GoodsNumber) as GoodsNumber from ContractOrderDetail where OrderNO ='{0}' and GoodTypeID in ({1}) ", OrderNO, costProjectInfo.UsingGoods.TrimEnd(',')); DataSet ds = DbHelperSQL.Query(sql); if (ds.Tables[0] != null) { costInfo.OrderNumber = decimal.Parse(ds.Tables[0].Rows[0]["GoodsNumber"].ToString()); } } break; //收货计价单位,例如米,收货明细表:GoodCalcPriceNumber case "2": //获取运送获取重量信息 if (!string.IsNullOrEmpty(costProjectInfo.UsingGoods)) { sql = string.Format(@"select isnull(sum(GoodCalcPriceNumber),0) as GoodsNumber from ContractOrderDetail where OrderNO ='{0}' and GoodTypeID in ({1}) ", OrderNO, costProjectInfo.UsingGoods.TrimEnd(',')); DataSet ds = DbHelperSQL.Query(sql); if (ds.Tables[0] != null) { costInfo.OrderNumber = decimal.Parse(ds.Tables[0].Rows[0]["GoodsNumber"].ToString()); } } break; //客户吨位,收货明细表:GoodsCustomerWeight case "3": //获取运送获取重量信息 if (!string.IsNullOrEmpty(costProjectInfo.UsingGoods)) { sql = string.Format(@"select isnull(sum(GoodsCustomerWeight),0) as GoodsNumber from ContractOrderDetail where OrderNO ='{0}' and GoodTypeID in ({1}) ", OrderNO, costProjectInfo.UsingGoods.TrimEnd(',')); DataSet ds = DbHelperSQL.Query(sql); if (ds.Tables[0] != null) { costInfo.OrderNumber = decimal.Parse(ds.Tables[0].Rows[0]["GoodsNumber"].ToString()); } } break; //员工吨位,收货明细表:GoodsStaffWeight case "4": //获取运送获取重量信息 if (!string.IsNullOrEmpty(costProjectInfo.UsingGoods)) { sql = string.Format(@"select isnull(sum(GoodsStaffWeight),0) as GoodsNumber from ContractOrderDetail where OrderNO ='{0}' and GoodTypeID in ({1}) ", OrderNO, costProjectInfo.UsingGoods.TrimEnd(',')); DataSet ds = DbHelperSQL.Query(sql); if (ds.Tables[0] != null) { costInfo.OrderNumber = decimal.Parse(ds.Tables[0].Rows[0]["GoodsNumber"].ToString()); } } break; //司机吨位,收货明细表:GoodsDriverWeight case "5": //获取运送获取重量信息 if (!string.IsNullOrEmpty(costProjectInfo.UsingGoods)) { sql = string.Format(@"select isnull(sum(GoodsDriverWeight),0) as GoodsNumber from ContractOrderDetail where OrderNO ='{0}' and GoodTypeID in ({1}) ", OrderNO, costProjectInfo.UsingGoods.TrimEnd(',')); DataSet ds = DbHelperSQL.Query(sql); if (ds.Tables[0] != null) { costInfo.OrderNumber = decimal.Parse(ds.Tables[0].Rows[0]["GoodsNumber"].ToString()); } } break; //其他,默认1 case "6": costInfo.OrderNumber = 1; break; default: costInfo.OrderNumber = 1; break; } #endregion 获取费用项计价数量 //更新费用项信息 costInfo.CostAmount = costInfo.PayPrice * costInfo.OrderNumber; Core.Container.Instance.Resolve <IServiceContractOrderCostInfo>().Update(costInfo); }