public void SaveBow(DataTable dt, int TaskID) { Hownet.BLL.SizeBow bllSB = new SizeBow(); Hownet.BLL.Materiel bllMat = new Materiel(); Hownet.BLL.MaterielAttribute blMa = new MaterielAttribute(); Hownet.Model.SizeBow modSB = new Hownet.Model.SizeBow(); int sizeID = 0; modSB.ProduceTaskID = TaskID; for (int c = 1; c < dt.Columns.Count; c++) { if (dt.DefaultView[0][c].ToString() != string.Empty) { sizeID = blMa.GetID(dt.DefaultView[0][c].ToString(), 2); modSB.SizeID = sizeID; if (dt.DefaultView[2][c] != null && dt.DefaultView[2][c].ToString() != string.Empty) { modSB.BowID = bllMat.GetID(dt.DefaultView[2][c].ToString()); } if (dt.DefaultView[1][c] != null && dt.DefaultView[2][c].ToString() != string.Empty) { modSB.CottonID = bllMat.GetID(dt.DefaultView[1][c].ToString()); } modSB.SizeBowID = bllSB.SelectSize(TaskID, sizeID); if (modSB.SizeBowID != 0) { bllSB.Update(modSB); } else { bllSB.Add(modSB); } } } }
public DataTable SizeBow(int TaskID) { Hownet.BLL.SizeBow bllSB = new SizeBow(); Hownet.BLL.ProduceTaskInfo pti = new ProduceTaskInfo(); int SizeID = 0; DataTable dt = new DataTable(); dt.TableName = "Bow"; dt.Clear(); dt.Columns.Clear(); dt.Columns.Add("Part", typeof(string)); dt.Rows.Add(dt.NewRow()); dt.Rows.Add(dt.NewRow()); dt.Rows.Add(dt.NewRow()); dt.Rows[1]["Part"] = "模具"; dt.Rows[2]["Part"] = "钢弓"; SqlDataReader myReader = pti.GetSize(TaskID); int i = 1; ArrayList SizeList = new ArrayList(); SizeList.Clear(); SizeList.Add(0); while (myReader.Read()) { dt.Columns.Add("Columns" + i); dt.Rows[0][i] = myReader[0].ToString(); SizeList.Add(int.Parse(myReader[1].ToString())); i++; } myReader.Close(); for (int c = dt.Columns.Count; c < 12; c++) { dt.Columns.Add("Columns" + c); } for (int r = 1; r < SizeList.Count; r++) { SizeID = int.Parse(SizeList[r].ToString()); dt.Rows[2][r] = bllSB.GetBowValue(TaskID, SizeID); dt.Rows[1][r] = bllSB.GetCottonValue(TaskID, SizeID); } return(dt); }
/// <summary> /// 显示生产单明细 /// </summary> /// <param name="TaskID"></param> /// <param name="t">真加空行,假不加</param> /// <returns></returns> public DataSet ShowInfo(int TaskID, bool t) { bool f = false; Hownet.BLL.ProduceTaskInfo pti = new ProduceTaskInfo(); Hownet.Model.ProduceTaskInfo modPti = new Hownet.Model.ProduceTaskInfo(); Hownet.BLL.SizeBow bllSB = new SizeBow(); Hownet.BLL.SizeTable bllST = new SizeTable(); DataTable dtSBInfo = bllSB.GetListByTask(TaskID).Tables[0]; DataTable dtSTInfo = bllST.GetListByTask(TaskID).Tables[0]; DataTable dtInfo = pti.GetList("(MainID=" + TaskID + ")").Tables[0]; DataTable dtSizePart = bllST.GetSizePartIDGroup(TaskID).Tables[0]; DataTable dt = new DataTable(); DataTable dtSB = new DataTable(); DataTable dtST = new DataTable(); dt.Columns.Add("Color", typeof(string)); dtSB.Columns.Add("SizeBow", typeof(string)); dtST.Columns.Add("SizePart", typeof(string)); dt.Rows.Add(dt.NewRow()); dtSB.Rows.Add(dtSB.NewRow()); dtST.Rows.Add(dtST.NewRow()); dtST.Rows[0]["SizePart"] = 0; dt.Rows[0]["Color"] = "颜色\\尺码"; if (dtSBInfo.Rows.Count > 0) { f = true; } SqlDataReader myReader = pti.GetSize(TaskID); int i = 1; ArrayList ColorList = new ArrayList(); ArrayList SizeList = new ArrayList(); ArrayList ColorOneList = new ArrayList(); ArrayList ColorTwoList = new ArrayList(); ColorList.Clear(); ColorOneList.Clear(); ColorTwoList.Clear(); SizeList.Clear(); ColorList.Add(0); SizeList.Add(0); ColorOneList.Add(0); ColorTwoList.Add(0); while (myReader.Read()) { dt.Columns.Add("Columns" + i); dtSB.Columns.Add("Columns" + i); dtST.Columns.Add("Columns" + i); dtST.Rows[0][i] = dtSB.Rows[0][i] = dt.Rows[0][i] = myReader[0].ToString(); SizeList.Add(int.Parse(myReader[1].ToString())); i++; } myReader.Close(); for (int c = dt.Columns.Count; c < 12; c++) { dt.Columns.Add("Columns" + c); } dt.Columns.Add("SumNum"); dt.Rows[0]["SumNum"] = "合计"; dt.Columns.Add("ColorOne", typeof(string)); dt.Columns.Add("ColorTwo", typeof(string)); dt.Rows[0]["ColorOne"] = "插色一"; dt.Rows[0]["ColorTwo"] = "插色二"; SqlDataReader ColorReader = pti.GetColor(TaskID); i = 1; while (ColorReader.Read()) { dt.Rows.Add(dt.NewRow()); dt.Rows[i][0] = ColorReader[0].ToString(); dt.Rows[i][dt.Columns.Count - 2] = ColorReader[3].ToString(); dt.Rows[i][dt.Columns.Count - 1] = ColorReader[5].ToString(); ColorList.Add(int.Parse(ColorReader[1].ToString())); ColorOneList.Add(int.Parse(ColorReader[4].ToString())); ColorTwoList.Add(int.Parse(ColorReader[6].ToString())); i++; } dtSB.Rows.Add(dtSB.NewRow()); dtSB.Rows.Add(dtSB.NewRow()); dtSB.Rows.Add(dtSB.NewRow()); dtSB.Rows.Add(dtSB.NewRow()); dtSB.Rows.Add(dtSB.NewRow()); dtSB.Rows[1][0] = "钢弓"; dtSB.Rows[2][0] = "棉碗"; dtSB.Rows[3][0] = "成品肩带"; dtSB.Rows[4][0] = "透明背带"; dtSB.Rows[5][0] = "胶骨"; ColorReader.Close(); if (dtSizePart.Rows.Count > 0) { for (int a = 0; a < dtSizePart.Rows.Count; a++) { object obj = dtSizePart.Rows[a][0].ToString(); dtST.Rows.Add(dtST.NewRow()); dtST.Rows[a + 1][0] = dtSizePart.Rows[a]["SizePartID"]; } } DataTable dtNotAmount = dt.Copy(); DataTable dtBackAmount = dt.Copy(); for (int r = 1; r < SizeList.Count; r++) { modPti.SizeID = int.Parse(SizeList[r].ToString()); for (int c = 1; c < ColorList.Count; c++) { modPti.ColorID = int.Parse(ColorList[c].ToString()); modPti.ColorOneID = int.Parse(ColorOneList[c].ToString()); modPti.ColorTwoID = int.Parse(ColorTwoList[c].ToString()); modPti.MainID = TaskID; string sql = "(SizeID=" + modPti.SizeID + ") and (ColorID=" + modPti.ColorID + ") and (ColorOneID=" + modPti.ColorOneID + ") and (ColorTwoID=" + modPti.ColorTwoID + ")"; DataRow[] drs = dtInfo.Select(sql); if (drs.Length > 0) { dt.Rows[c][r] = drs[0]["Amount"]; dtNotAmount.Rows[c][r] = drs[0]["NotAmount"]; dtBackAmount.Rows[c][r] = drs[0]["BackAmount"]; } } if (f) { DataRow[] drSb = dtSBInfo.Select("(SizeID=" + modPti.SizeID + ")"); if (drSb.Length > 0) { dtSB.Rows[1][r] = drSb[0]["BowName"]; dtSB.Rows[2][r] = drSb[0]["CottonName"]; dtSB.Rows[3][r] = drSb[0]["SashName"]; dtSB.Rows[4][r] = drSb[0]["OpenSashName"]; dtSB.Rows[5][r] = drSb[0]["PlasticBoneName"]; } } if (dtSTInfo.Rows.Count > 0) { for (int a = 0; a < dtSizePart.Rows.Count; a++) { string aaaa = "(SizeID=" + modPti.SizeID + ") and (SizePartID=" + dtSizePart.Rows[a]["SizePartID"] + ")"; DataRow[] drSt = dtSTInfo.Select(aaaa); if (drSt.Length > 0) { dtST.Rows[a + 1][r] = drSt[0]["Length"]; } } } } if (t) { //for (int r = dt.Rows.Count; r < 11; r++) //{ // DataRow dr = dt.NewRow(); // dt.Rows.Add(dr); //} dt.Rows.Add(dt.NewRow()); } DataSet ds = new DataSet(); ds.Tables.Add(dt); ds.Tables.Add(dtSB); ds.Tables.Add(dtST); ds.Tables.Add(dtNotAmount); ds.Tables.Add(dtBackAmount); return(ds); }