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 void SaveSizePart(DataTable dt, int TaskID) { Hownet.BLL.SizePart bllSP = new SizePart(); Hownet.BLL.SizeTable bllSt = new SizeTable(); Hownet.BLL.MaterielAttribute blMa = new MaterielAttribute(); Hownet.Model.SizeTable modST = new Hownet.Model.SizeTable(); ArrayList PartList = new ArrayList(); ArrayList SizeList = new ArrayList(); bllSt.DelTask(TaskID); PartList.Clear(); SizeList.Clear(); PartList.Add(0); SizeList.Add(0); for (int r = 1; r < dt.Rows.Count - 1; r++) { int partID = 0; if (dt.DefaultView[r]["Part"].ToString() != string.Empty) { partID = bllSP.GetID(dt.DefaultView[r]["Part"].ToString()); } PartList.Add(partID); } for (int c = 1; c < dt.Columns.Count; c++) { int sizeID = 0; if (dt.DefaultView[0][c].ToString() != string.Empty) { sizeID = blMa.GetID(dt.DefaultView[0][c].ToString(), 2); } SizeList.Add(sizeID); } for (int r = 0; r < PartList.Count; r++) { if (PartList[r].ToString() != "0") { for (int c = 0; c < SizeList.Count; c++) { if (SizeList[c].ToString() != "0") { if (dt.DefaultView[r][c].ToString() != string.Empty && dt.DefaultView[r][c].ToString() != "0") { modST.ProduceTaskID = TaskID; modST.SizeID = int.Parse(SizeList[c].ToString()); modST.SizePartID = int.Parse(PartList[r].ToString()); modST.Length = decimal.Parse(dt.DefaultView[r][c].ToString()); bllSt.Add(modST); } } } } } }
public DataTable GroupTable(DataTable dt, DataTable dtSouGong) { bool t = false; Hownet.BLL.Materiel bllMat = new Materiel(); Hownet.BLL.MaterielAttribute bllMA = new MaterielAttribute(); Hownet.BLL.Department bllDep = new Department(); DataTable dtMD = dtSouGong.Clone(); for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dtMD.Rows.Count; j++) { t = false; if (dt.DefaultView[i]["MaterielID"].Equals(dtMD.DefaultView[j]["MaterielID"]) && dt.DefaultView[i]["ColorID"].Equals(dtMD.DefaultView[j]["ColorID"]) && dt.DefaultView[i]["DepartmentID"].Equals(dtMD.DefaultView[j]["TaskID"]) && dt.DefaultView[i]["ProductTaskID"].Equals(dtMD.DefaultView[j]["ProduceTaskID"]) && dt.DefaultView[i]["SizeID"].Equals(dtMD.DefaultView[j]["SizeID"]) && dt.DefaultView[i]["BrandID"].Equals(dtMD.DefaultView[j]["BrandID"]) && dt.DefaultView[i]["ColorOneID"].Equals(dtMD.DefaultView[j]["ColorOneID"]) && dt.DefaultView[i]["ColorTwoID"].Equals(dtMD.DefaultView[j]["ColorTwoID"])) { dtMD.Rows[j]["EligibleAmount"] = int.Parse(dt.DefaultView[i]["EligibleAmount"].ToString()) + int.Parse(dtMD.DefaultView[j]["EligibleAmount"].ToString()); dtMD.Rows[j]["InferiorAmount"] = int.Parse(dt.DefaultView[i]["InferiorAmount"].ToString()) + int.Parse(dtMD.DefaultView[j]["InferiorAmount"].ToString()); t = true; break; } } if (!t) { DataRow dr = dtMD.NewRow(); dr["MaterielID"] = dt.DefaultView[i]["MaterielID"]; dr["ColorID"] = dt.DefaultView[i]["ColorID"]; dr["SizeID"] = dt.DefaultView[i]["SizeID"]; dr["TaskID"] = dt.DefaultView[i]["DepartmentID"]; dr["ProduceTaskID"] = dt.DefaultView[i]["ProductTaskID"]; dr["EligibleAmount"] = dt.DefaultView[i]["EligibleAmount"]; dr["InferiorAmount"] = dt.DefaultView[i]["InferiorAmount"]; dr["BrandID"] = dt.DefaultView[i]["BrandID"]; dr["ColorOneID"] = dt.DefaultView[i]["ColorOneID"]; dr["ColorTwoID"] = dt.DefaultView[i]["ColorTwoID"]; dtMD.Rows.Add(dr); } } for (int i = 0; i < dtSouGong.Rows.Count; i++) { for (int j = 0; j < dtMD.Rows.Count; j++) { t = false; if (dtSouGong.DefaultView[i][2].Equals(dtMD.DefaultView[j][2]) && dtSouGong.DefaultView[i][3].Equals(dtMD.DefaultView[j][3]) && dtSouGong.DefaultView[i][5].Equals(dtMD.DefaultView[j][5]) && dtSouGong.DefaultView[i][6].Equals(dtMD.DefaultView[j][6]) && dtSouGong.DefaultView[i][9].Equals(dtMD.DefaultView[j][9]) && dtSouGong.DefaultView[i]["BrandID"].Equals(dtMD.DefaultView[j]["BrandID"]) && dtSouGong.DefaultView[i]["ColorOneID"].Equals(dtMD.DefaultView[j]["ColorOneID"]) && dtSouGong.DefaultView[i]["ColorTwoID"].Equals(dtMD.DefaultView[j]["ColorTwoID"])) { dtMD.Rows[j]["EligibleAmount"] = int.Parse(dtSouGong.DefaultView[i]["EligibleAmount"].ToString()) + int.Parse(dtMD.DefaultView[j]["EligibleAmount"].ToString()); dtMD.Rows[j]["InferiorAmount"] = int.Parse(dtSouGong.DefaultView[i]["InferiorAmount"].ToString()) + int.Parse(dtMD.DefaultView[j]["InferiorAmount"].ToString()); t = true; break; } } if (!t) { DataRow dr = dtMD.NewRow(); dr["MaterielID"] = dtSouGong.DefaultView[i]["MaterielID"]; dr["ColorID"] = dtSouGong.DefaultView[i]["ColorID"]; dr["SizeID"] = dtSouGong.DefaultView[i]["SizeID"]; dr["TaskID"] = dtSouGong.DefaultView[i]["TaskID"]; dr["ProduceTaskID"] = dtSouGong.DefaultView[i]["ProduceTaskID"]; dr["EligibleAmount"] = dtSouGong.DefaultView[i]["EligibleAmount"]; dr["InferiorAmount"] = dtSouGong.DefaultView[i]["InferiorAmount"]; dr["BrandID"] = dtSouGong.DefaultView[i]["BrandID"]; dr["ColorOneID"] = dtSouGong.DefaultView[i]["ColorOneID"]; dr["ColorTwoID"] = dtSouGong.DefaultView[i]["ColorTwoID"]; dtMD.Rows.Add(dr); } } DataTable dtMat = bllMat.GetList("(AttributeID=1) OR (AttributeID=5)").Tables[0]; DataTable dtMA = bllMA.GetAllList().Tables[0]; DataTable dtDep = bllDep.GetTypeList("иВок").Tables[0]; dtMD.Columns.Add("MaterielName", typeof(string)); dtMD.Columns.Add("ColorName", typeof(string)); dtMD.Columns.Add("SizeName", typeof(string)); dtMD.Columns.Add("DeparmentName", typeof(string)); dtMD.Columns.Add("BrandName", typeof(string)); dtMD.Columns.Add("ColorOneName", typeof(string)); dtMD.Columns.Add("ColorTwoName", typeof(string)); for (int i = 0; i < dtMD.Rows.Count; i++) { dtMD.Rows[i]["MaterielName"] = dtMat.Select("(MaterielID=" + dtMD.Rows[i]["MaterielID"] + ")")[0]["MaterielName"]; dtMD.Rows[i]["ColorName"] = dtMA.Select("(MaterielAttributeID=" + dtMD.Rows[i]["ColorID"] + ")")[0]["MaterielAttributeName"]; dtMD.Rows[i]["SizeName"] = dtMA.Select("(MaterielAttributeID=" + dtMD.Rows[i]["SizeID"] + ")")[0]["MaterielAttributeName"]; dtMD.Rows[i]["DeparmentName"] = dtDep.Select("(DepartmentID=" + dtMD.Rows[i]["TaskID"] + ")")[0]["DepartmentName"]; if (dtMD.Rows[i]["BrandID"].ToString() != "0") { dtMD.Rows[i]["BrandName"] = dtMat.Select("(MaterielID=" + dtMD.Rows[i]["BrandID"] + ")")[0]["MaterielName"]; } if (dtMD.Rows[i]["ColorOneID"].ToString() != "0") { dtMD.Rows[i]["ColorOneName"] = dtMA.Select("(MaterielAttributeID=" + dtMD.Rows[i]["ColorOneID"] + ")")[0]["MaterielAttributeName"]; } if (dtMD.Rows[i]["ColorTwoID"].ToString() != "0") { dtMD.Rows[i]["ColorTwoName"] = dtMA.Select("(MaterielAttributeID=" + dtMD.Rows[i]["ColorTwoID"] + ")")[0]["MaterielAttributeName"]; } object obj = dtMD.Rows[i]["BrandID"]; } return(dtMD); }