/// <summary> /// 撤销合同关联处理 /// </summary> public void RHTCancel(RecPay entity, int p_DtsID, IDBTransAccess sqlTrans) { try { string sql = string.Empty; //First 处理收付款主表数据 RecPay entitypay = new RecPay(sqlTrans);//处理收付款主表数据 entitypay.ID = entity.ID; entitypay.SelectByID(); //Second 删除付款核销明细数据 RecPayHTDtsRule dtsRule = new RecPayHTDtsRule(); RecPayHTDts dtsentity = new RecPayHTDts(sqlTrans); dtsentity.ID = p_DtsID; dtsentity.SelectByID(); dtsRule.RDelete(dtsentity, sqlTrans);//删除明细实体 //First 处理收付款主表数据 entitypay.HTFlag = (int)YesOrNo.No; entitypay.HTAmount -= dtsentity.HTAmount; entitypay.HTNo = entitypay.HTNo.Replace(dtsentity.HTNo, "").Replace(" " + dtsentity.HTNo, "");//替换合同号 if (entitypay.HTGoodsCode != "") { entitypay.HTGoodsCode = entitypay.HTGoodsCode.Replace(dtsentity.HTGoodsCode, "").Replace(" " + dtsentity.HTGoodsCode, "");//替换商品码 } this.RUpdate(entitypay, sqlTrans); //关联到采购单或者销售合同资金实际执行表 if (dtsentity.HTTypeID == (int)EnumRecPayType.收款) { SaleOrderCapExDtsRule capRule = new SaleOrderCapExDtsRule(); capRule.RHTCancel(dtsentity, sqlTrans); } else if (dtsentity.HTTypeID == (int)EnumRecPayType.付款) { ItemBuyCapExDtsRule capRule = new ItemBuyCapExDtsRule(); capRule.RHTCancel(dtsentity, sqlTrans); } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 合同关联处理 /// </summary> public void RHT(RecPay entity, string p_HTNo, string p_HTItemCode, string p_HTGoodsCode, decimal p_HTAmount, int p_HTTypeID, IDBTransAccess sqlTrans) { try { string sql = string.Empty; //First 处理收付款主表数据 RecPay entitypay = new RecPay(sqlTrans);//处理收付款主表数据 entitypay.ID = entity.ID; entitypay.SelectByID(); if (entitypay.HTAmount + p_HTAmount > entitypay.ExAmount) { throw new Exception("不能操作,关联合同金额超过了收付款金额"); } if (entitypay.HTAmount + p_HTAmount == entitypay.ExAmount) { entitypay.HTFlag = (int)YesOrNo.Yes; } entitypay.HTAmount += p_HTAmount; if (entitypay.HTNo == string.Empty || entitypay.HTNo.IndexOf(" " + p_HTNo) == -1) { if (entitypay.HTNo != string.Empty)//多合同关联 { entitypay.HTNo += " "; } entitypay.HTNo += p_HTNo; } if (entitypay.HTGoodsCode == string.Empty || entitypay.HTGoodsCode.IndexOf(" " + p_HTGoodsCode) == -1) { if (entitypay.HTGoodsCode != string.Empty)//多合同关联 { entitypay.HTGoodsCode += " "; } entitypay.HTGoodsCode += p_HTGoodsCode; } this.RUpdate(entitypay, sqlTrans); //Second 增加付款合同明细数据 RecPayHTDtsRule dtsRule = new RecPayHTDtsRule(); RecPayHTDts dtsentity = new RecPayHTDts(sqlTrans); dtsentity.MainID = entity.ID; dtsentity.HTOPID = entity.MakeOPID; dtsentity.HTOPName = entity.MakeOPName; dtsentity.HTDate = DateTime.Now; dtsentity.HTAmount = p_HTAmount; dtsentity.HTNo = p_HTNo; dtsentity.HTGoodsCode = p_HTGoodsCode; dtsentity.HTTypeID = p_HTTypeID; dtsentity.HTItemCode = p_HTItemCode; dtsRule.RAdd(dtsentity, sqlTrans);//增加明细实体 //关联到采购单或者销售合同资金实际执行表 if (p_HTTypeID == (int)EnumRecPayType.收款) { SaleOrderCapExDtsRule capRule = new SaleOrderCapExDtsRule(); capRule.RHT(entitypay, dtsentity, sqlTrans); } else if (p_HTTypeID == (int)EnumRecPayType.付款) { ItemBuyCapExDtsRule capRule = new ItemBuyCapExDtsRule(); capRule.RHT(entitypay, dtsentity, sqlTrans); } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }