public void Verify(int MainID, bool IsVerify) { Hownet.BLL.Pack2DepotMain bllPDM = new Pack2DepotMain(); Hownet.Model.Pack2DepotMain modPDM = bllPDM.GetModel(MainID); List <Hownet.Model.Pack2DepotInfo> li = DataTableToList(GetList("(MainID=" + MainID + ")").Tables[0]); Hownet.BLL.Repertory bllRep = new Repertory(); Hownet.BLL.PackAmount bllPA = new PackAmount(); Hownet.BLL.RepertoryList bllRL = new RepertoryList(); Hownet.BLL.MaterielList bllML = new MaterielList(); Hownet.Model.MaterielList modML = new Model.MaterielList(); Hownet.Model.RepertoryList modRL = new Model.RepertoryList(); DataTable dtRL = new DataTable(); Hownet.Model.PackAmount modPA = new Hownet.Model.PackAmount(); Hownet.Model.Repertory modRep = new Hownet.Model.Repertory(); modRep.BrandName = modRep.ColorName = modRep.ColorOneName = modRep.ColorTwoName = modRep.CompanyName = modRep.DeparmentName = modRep.DepotInfoName = modRep.MaterielName = modRep.MeasureName = modRep.Remark = modRep.SizeName = modRep.SpecName = modRep.SupplierName = modRep.SupplierSN = string.Empty; Hownet.BLL.OtherType bllOT = new Hownet.BLL.OtherType(); DataTable dtOT = bllOT.GetTypeList("成品单位").Tables[0]; decimal one = 1; decimal two = 1; int dM = 0; if (dtOT.Rows.Count > 0) { one = Convert.ToDecimal(dtOT.Select("(Name='车间换算')")[0]["Value"]); two = Convert.ToDecimal(dtOT.Select("(Name='仓储换算')")[0]["Value"]); dM = Convert.ToInt32(dtOT.Select("(Name='仓储单位')")[0]["Value"]); } try { for (int i = 0; i < li.Count; i++) { modPA = bllPA.GetModel(li[i].PackAmountID); if (IsVerify) { if (one > 1 || two > 1) { if (one > 0) { modPA.Amount -= ((int)(li[i].NowAmount * two / one)); } } else { modPA.Amount -= li[i].NowAmount; } if (modPA.Amount < 0) { modPA.Amount = 0; } } else { if (one > 1 || two > 1) { if (one > 0) { modPA.Amount += ((int)(li[i].NowAmount * two / one)); } } else { modPA.Amount += li[i].NowAmount; } } bllPA.Update(modPA); modRep = new Hownet.Model.Repertory(); modRep.BrandName = modRep.ColorName = modRep.ColorOneName = modRep.ColorTwoName = modRep.CompanyName = modRep.DeparmentName = modRep.DepotInfoName = modRep.MaterielName = modRep.MeasureName = modRep.Remark = modRep.SizeName = modRep.SpecName = modRep.SupplierName = modRep.SupplierSN = string.Empty; modRep.DepartmentID = modPDM.DepotID; modRep.BrandID = modML.BrandID = li[i].BrandID; modRep.ColorID = modML.ColorID = li[i].ColorID; modRep.ColorOneID = modML.ColorOneID = li[i].ColorOneID; modRep.ColorTwoID = modML.ColorTwoID = li[i].ColorTwoID; modRep.SizeID = modML.SizeID = li[i].SizeID; modRep.MaterielID = modML.MaterielID = li[i].MaterielID; if (dM > 0) { modRep.MeasureID = dM; } else { modRep.MeasureID = li[i].MeasureID; } modML.MeasureID = modRep.MeasureID; modRep.Amount = li[i].NowAmount; modRep.MListID = li[i].MListID; if (li[i].DepotBrandID > 0) { modRep.BrandID = modML.BrandID = li[i].DepotBrandID; modRep.MListID = bllML.GetID(modML); } modRep.ID = bllRep.InOrOut(modRep, IsVerify); if (li[i].DepotInfoID > 0) { dtRL = bllRL.GetList("(BatchNumber=" + li[i].MListID + ") And (DepotInfoID=" + li[i].DepotInfoID + ")").Tables[0]; if (dtRL.Rows.Count == 0) { if (IsVerify) { modRL = new Model.RepertoryList(); modRL.A = 1; modRL.NotAmount = modRL.Amount = li[i].NowAmount; modRL.BatchNumber = li[i].MListID; modRL.DateTime = DateTime.Now; modRL.DepotInfoID = li[i].DepotInfoID; modRL.DepotInfoName = string.Empty; modRL.ID = 0; modRL.IsEnd = false; modRL.MainID = modRep.ID; modRL.PlanID = 0; modRL.QRID = li[i].MListID.ToString(); modRL.Remark = string.Empty; modRL.SpecID = 0; modRL.SpecName = string.Empty; modRL.StockListID = 0; bllRL.Add(modRL); } } else if (dtRL.Rows.Count == 1) { modRL = bllRL.GetModel(Convert.ToInt32(dtRL.Rows[0]["ID"])); if (IsVerify) { modRL.Amount += li[i].NowAmount; } else { modRL.Amount -= li[i].NowAmount; } bllRL.Update(modRL); } else if (dtRL.Rows.Count > 1) { List <Hownet.Model.RepertoryList> liRL = bllRL.DataTableToList(dtRL); for (int j = 1; j < liRL.Count; j++) { liRL[0].Amount += liRL[j].Amount; bllRL.Delete(liRL[j].ID); } if (IsVerify) { liRL[0].Amount += li[i].NowAmount; } else { liRL[0].Amount -= li[i].NowAmount; } bllRL.Update(liRL[0]); } } } if (!IsVerify) { modPDM.IsVerify = 1; modPDM.VerifyDate = Convert.ToDateTime("1900-1-1"); modPDM.VerifyMan = 0; bllPDM.Update(modPDM); } } catch (Exception ex) { } }