public static bool EditSplanSum(SupplyPlanDetailCollection details) { bool flag = false; StringBuilder builder = new StringBuilder(); builder.Append("begin "); if (details.Count > 0) { int count = details.Count; for (int i = 0; i < count; i++) { builder.Append(string.Format("update EPM_Stuff_SupplyPlan_Detail set StuffCount={0},PrePrice={1},FactPrice={2},ArrivalDate='{3}' where ItemID={4}", new object[] { details[i].StuffCount, details[i].StuffPrice, details[i].FactPrice, details[i].ArrivalDate, details[i].ItemID }) + ";"); } builder.Append(" end"); try { flag = publicDbOpClass.NonQuerySqlString(builder.ToString()); } catch (Exception exception) { throw exception; } } return(flag); }
public static SupplyPlanDetailCollection GetPlanSelectSum(int planid, bool isSum) { string str; if (isSum) { str = string.Format("select splan.ItemID,splan.StuffCode,splan.StuffCount,splan.SupplyPlanID,splan.PrePrice StuffPrice,splan.FactPrice FactPrice, splan.ArrivalDate,res.resourceName StuffName,res.specification StuffSpecs,res.UnitName StuffUnit from EPM_Stuff_SupplyPlan_Detail splan,EPM_V_Res_ResourceBasic res where SupplyPlanID={0} and splan.StuffCode=res.resourceCode ", planid); } else { str = string.Format("select StuffName, StuffSpecs,StuffName,sum(StuffCount) StuffCount from V_StuffSupply_Details_Temp where SupplyPlanID={0} group by StuffCode, StuffName,StuffSpecs", planid); } DataTable table = new DataTable(); table = publicDbOpClass.DataTableQuary(str); SupplyPlanDetailCollection details = new SupplyPlanDetailCollection(); if (table != null) { foreach (DataRow row in table.Rows) { SupplyPlanDetail detail = new SupplyPlanDetail { StuffCode = row["StuffCode"].ToString(), StuffName = row["StuffName"].ToString(), StuffSpecs = row["StuffSpecs"].ToString(), StuffCount = Convert.ToDecimal(row["StuffCount"]), StuffPrice = Convert.ToDecimal(row["StuffPrice"]), FactPrice = Convert.ToDecimal(row["FactPrice"]), StuffUnit = row["StuffUnit"].ToString(), ItemID = Convert.ToInt32(row["ItemID"]), ArrivalDate = (DateTime)row["ArrivalDate"] }; details.Add(detail); } } return(details); }