/// <summary> /// 额度逆返还 /// </summary> /// <param name="id">额度返还的单据phid</param> /// <returns></returns> public CommonResult DeleteReturn(long id) { ExpenseMstModel expenseMstEntity = base.Find(id).Data;//额度返还的单据 decimal FPlayamount = expenseMstEntity.FProjAmount - decimal.Parse(SumFSurplusamount(expenseMstEntity.FProjcode)) - expenseMstEntity.FReturnamount; var dicWhere = new Dictionary <string, object>(); new CreateCriteria(dicWhere).Add(ORMRestrictions <string> .Eq("FBillno", id.ToString())); var findedresultmst = base.Find(dicWhere).Data; //if (findedresultmst.Count > 0) //{ ExpenseMstModel expenseMstEntity2 = findedresultmst[0];//额度返还之前的单据 expenseMstEntity2.FIfpurchase = 0; expenseMstEntity2.FBillno = ""; expenseMstEntity2.FPlayamount = FPlayamount; expenseMstEntity2.PersistentState = SUP.Common.Base.PersistentState.Modified; //} var dicWhere2 = new Dictionary <string, object>(); new CreateCriteria(dicWhere2).Add(ORMRestrictions <string> .Eq("FProjcode", expenseMstEntity.FProjcode)) .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0)) .Add(ORMRestrictions <System.Int32> .NotEq("FIfpurchase", 1)) .Add(ORMRestrictions <System.Int64> .NotEq("PhId", expenseMstEntity.PhId)); IList <ExpenseMstModel> ExpenseMstList = base.Find(dicWhere2).Data; //List<ExpenseMstModel> ExpenseMstList = ExpenseMstList2.ToList().FindAll(t => t.FIfpurchase != 1); //只剩一条单据的时候 /*if (ExpenseMstList.Count == 1) * { * ExpenseMstList[0].FProjname = ExpenseMstList[0].FProjname.Replace("-" + ExpenseMstList[0].FIfperformanceappraisal.ToString(), ""); * ExpenseMstList[0].FIfperformanceappraisal = 1; * //删除额度返还的原单据 * if (ExpenseMstList[0].FIfpurchase == 2) * { * List<ExpenseMstModel> ExpenseMstList3 = ExpenseMstList2.ToList().FindAll(t => t.FBillno == ExpenseMstList[0].PhId.ToString()); * if (ExpenseMstList3.Count > 0) * { * ExpenseMstList3[0].FProjname.Replace("-" + ExpenseMstList3[0].FIfperformanceappraisal.ToString(), ""); * ExpenseMstList3[0].FIfperformanceappraisal = 1; * ExpenseMstFacade.Save<Int64>(ExpenseMstList3); * } * } * }*/ for (var i = 0; i < ExpenseMstList.Count; i++) { ExpenseMstList[i].FPlayamount = FPlayamount; ExpenseMstList[i].PersistentState = SUP.Common.Base.PersistentState.Modified; //base.Save<Int64>(ExpenseMstList[i]); } ExpenseMstFacade.Save <Int64>(ExpenseMstList); ExpenseMstFacade.Save <Int64>(expenseMstEntity2); CommonResult result = base.Delete <System.Int64>(id); return(result); }
/// <summary> /// 删除正常单据 可编报数变更 /// </summary> /// <param name="id"></param> /// <returns></returns> public CommonResult Delete2(long id) { ExpenseMstModel expenseMstEntity = base.Find(id).Data; if (expenseMstEntity.FIfpurchase == 0) { decimal FPlayamount = expenseMstEntity.FPlayamount + expenseMstEntity.FSurplusamount; var dicWhere2 = new Dictionary <string, object>(); new CreateCriteria(dicWhere2).Add(ORMRestrictions <string> .Eq("FProjcode", expenseMstEntity.FProjcode)) .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0)) //.Add(ORMRestrictions<System.Int32>.NotEq("FIfpurchase", 1)) .Add(ORMRestrictions <System.Int64> .NotEq("PhId", expenseMstEntity.PhId)); IList <ExpenseMstModel> ExpenseMstList2 = base.Find(dicWhere2).Data; List <ExpenseMstModel> ExpenseMstList = ExpenseMstList2.ToList().FindAll(t => t.FIfpurchase != 1); //只剩一条单据的时候 if (ExpenseMstList.Count == 1) { ExpenseMstList[0].FProjname = ExpenseMstList[0].FProjname.Replace("-" + ExpenseMstList[0].FIfperformanceappraisal.ToString(), ""); ExpenseMstList[0].FIfperformanceappraisal = 1; //删除额度返还的原单据 if (ExpenseMstList[0].FIfpurchase == 2) { List <ExpenseMstModel> ExpenseMstList3 = ExpenseMstList2.ToList().FindAll(t => t.FBillno == ExpenseMstList[0].PhId.ToString()); if (ExpenseMstList3.Count > 0) { ExpenseMstList3[0].FProjname.Replace("-" + ExpenseMstList3[0].FIfperformanceappraisal.ToString(), ""); ExpenseMstList3[0].FIfperformanceappraisal = 1; ExpenseMstList3[0].PersistentState = PersistentState.Modified; ExpenseMstFacade.Save <Int64>(ExpenseMstList3); } } } for (var i = 0; i < ExpenseMstList.Count; i++) { ExpenseMstList[i].FPlayamount = FPlayamount; ExpenseMstList[i].PersistentState = SUP.Common.Base.PersistentState.Modified; } ExpenseMstFacade.Save <Int64>(ExpenseMstList); } CommonResult result = base.Delete(id); return(result); }