/// <summary> /// Formula表数据导入到CustMixprop表 /// </summary> /// <param name="sid">Formula表主键ID</param> /// <returns></returns> public bool FO2CU(string sid, string did) { using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction()) { try { Formula obj = this.Get(sid); CustMixprop newobj = new CustMixprop(); if (did.Length > 0) { newobj.ID = did; } newobj.CarpRadii = obj.CarpRadii; newobj.CementType = obj.CementType; newobj.ConStrength = obj.ConStrength; newobj.ImpGrade = obj.ImpGrade; newobj.Mesh = obj.Mesh; newobj.MixpropCode = obj.FormulaName; newobj.SCRate = obj.SCRate; newobj.Slump = obj.Slump; newobj.WCRate = obj.WCRate; newobj.Weight = obj.Weight; newobj = this.m_UnitOfWork.GetRepositoryBase <CustMixprop>().Add(newobj); IList <FormulaItem> list = obj.FormulaItems; IList <StuffInfo> slist = this.m_UnitOfWork.GetRepositoryBase <StuffInfo>().Query().Where(m => m.IsUsed).ToList(); foreach (FormulaItem item in list) { foreach (StuffInfo stuff in slist) { if (stuff.StuffTypeID.ToString() == item.StuffTypeID.ToString()) { CustMixpropItem temp = new CustMixpropItem(); temp.Amount = item.StuffAmount; temp.StandardAmount = item.StandardAmount; temp.CustMixprop = newobj; temp.CustMixpropID = newobj.ID; temp.StuffInfo = stuff; temp.StuffID = stuff.ID; this.m_UnitOfWork.GetRepositoryBase <CustMixpropItem>().Add(temp); } } } tx.Commit(); return(true); } catch (Exception ex) { tx.Rollback(); logger.Error(ex.Message); throw; } } }
public override CustMixprop Add(CustMixprop entity) { using (var tx = this.m_UnitOfWork.BeginTransaction()) { CustMixprop cm = null; try { cm = base.Add(entity); this.m_UnitOfWork.Flush(); IRepositoryBase <CustMixpropItem> itemResp = this.m_UnitOfWork.GetRepositoryBase <CustMixpropItem>(); IRepositoryBase <StuffInfo> typeResp = this.m_UnitOfWork.GetRepositoryBase <StuffInfo>(); IList <StuffInfo> list = typeResp.Query().Where(m => m.StuffType.TypeID == "StuffType" && m.IsUsed == true && m.TestType.Length > 0).ToList(); IList <CustMixpropItem> items = itemResp.Query() .Where(m => m.CustMixpropID == cm.ID) .ToList(); foreach (CustMixpropItem item in items) { itemResp.Delete(item); } foreach (StuffInfo item in list) { CustMixpropItem temp = new CustMixpropItem(); temp.StuffID = item.ID; temp.Amount = 0; temp.StandardAmount = 0; temp.CustMixpropID = cm.ID; itemResp.Add(temp); } tx.Commit(); } catch { tx.Rollback(); throw; } return(cm); } }
public bool ExportStuff(string formulaid) { using (var tx = this.m_UnitOfWork.BeginTransaction()) { try { IRepositoryBase <CustMixpropItem> itemResp = this.m_UnitOfWork.GetRepositoryBase <CustMixpropItem>(); IRepositoryBase <StuffInfo> typeResp = this.m_UnitOfWork.GetRepositoryBase <StuffInfo>(); IList <StuffInfo> list = typeResp.Query().Where(m => m.StuffType.TypeID == "StuffType" && m.IsUsed == true && m.TestType.Length > 0).ToList(); IList <CustMixpropItem> items = itemResp.Query() .Where(m => m.CustMixpropID == formulaid) .ToList(); foreach (CustMixpropItem item in items) { itemResp.Delete(item); } foreach (StuffInfo item in list) { CustMixpropItem temp = new CustMixpropItem(); temp.StuffID = item.ID; temp.Amount = 0; temp.StandardAmount = 0; temp.CustMixpropID = formulaid; itemResp.Add(temp); } tx.Commit(); return(true); } catch (Exception ex) { tx.Rollback(); logger.Error(ex.Message); return(false); } } }