/// <summary> /// 主材买赔数量编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gdGoodsDetail_AfterEdit(object sender, GridAfterEditEventArgs e) { Dictionary <int, Dictionary <string, object> > modifiedDict = gdGoodsDetail.GetModifiedDict(); foreach (int rowIndex in modifiedDict.Keys) { //根据绑定列的记录编号,获取买赔物品信息和物品基本信息 int rowID = Convert.ToInt32(gdGoodsDetail.DataKeys[rowIndex][0]); ContractPayOrderDetail objInfo = Core.Container.Instance.Resolve <IServiceContractPayOrderDetail>().GetEntity(rowID); objInfo.GoodsTypeInfo = Core.Container.Instance.Resolve <IServiceEquipmentTypeInfo>().GetEntity(objInfo.GoodTypeID); //修改买赔数量 if (modifiedDict[rowIndex].Keys.Contains("GoodsNumber")) { objInfo.GoodsNumber = Convert.ToDecimal(modifiedDict[rowIndex]["GoodsNumber"]); //最终买赔数量 } //修改买赔单价 if (modifiedDict[rowIndex].Keys.Contains("GoodsUnitPrice")) { objInfo.GoodsUnitPrice = Convert.ToDecimal(modifiedDict[rowIndex]["GoodsUnitPrice"]); //最终买赔单价 } //计算并更新买赔金额 objInfo.PayAmount = objInfo.GoodsNumber * objInfo.GoodsUnitPrice; //更新订单明细 Core.Container.Instance.Resolve <IServiceContractPayOrderDetail>().Update(objInfo); } //重新加载订单买赔信息 BindMainGoodsInfo(); }
/// <summary> /// 创建买赔物品明细 /// </summary> /// <param name="orderNO">合同买赔单号</param> private void CreatePayGoodsInfo(string orderNO) { ContractPayOrderDetail payOrderDetail = new ContractPayOrderDetail(); //获取合同信息 ContractInfo contractInfo = Core.Container.Instance.Resolve <IServiceContractInfo>().GetEntity(int.Parse(ddlContract.SelectedValue)); //获取合同价格套系信息 // PriceSetInfo priceSetInfo = Core.Container.Instance.Resolve<IServicePriceSetInfo>().GetEntity(contractInfo.PriceSetID); //获取合同发货主材类别信息 string sql = string.Format(@"select * from EquipmentTypeInfo where id in (select distinct(GoodTypeID) as GoodTypeID from ContractOrderDetail where OrderNO in (select OrderNO from ContractOrderInfo where ContractID ={0} and OrderType=1))", contractInfo.ID); DataSet ds = DbHelperSQL.Query(sql); if (ds.Tables[0] != null) { foreach (DataRow row in ds.Tables[0].Rows) { payOrderDetail = new ContractPayOrderDetail(); payOrderDetail.OrderNO = OrderNO; payOrderDetail.OrderDate = DateTime.Now; payOrderDetail.GoodTypeID = int.Parse(row["ID"].ToString()); payOrderDetail.GoodsNumber = 0; payOrderDetail.GoodsUnit = row["TypeUnit"].ToString(); payOrderDetail.GoodsUnitPrice = decimal.Parse(row["PayForPrice"].ToString()); /*-------------------获取合同价格-------------------*/ EquipmentTypeInfo equipmentTypeInfo = Core.Container.Instance.Resolve <IServiceEquipmentTypeInfo>().GetEntity(payOrderDetail.GoodTypeID); IList <ICriterion> qryList = new List <ICriterion>(); //qryList.Add(Expression.Eq("SetID", priceSetInfo.ID)); qryList.Add(Expression.Eq("EquipmentID", payOrderDetail.GoodTypeID)); PriceSetGoodsInfo priceSetGoodsInfo = Core.Container.Instance.Resolve <IServicePriceSetGoodsInfo>().GetEntityByFields(qryList); if (priceSetGoodsInfo != null) { payOrderDetail.GoodsUnitPrice = priceSetGoodsInfo.UnitPrice; } payOrderDetail.PayAmount = payOrderDetail.GoodsNumber * payOrderDetail.GoodsUnitPrice; //保存赔偿材料信息 Core.Container.Instance.Resolve <IServiceContractPayOrderDetail>().Create(payOrderDetail); } } }