/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bt_save_Click(object sender, EventArgs e) { string str_product_name = cB_product_name.SelectedItem.ToString(); DataTable dt = AsmproductionWayRecord_BLL.GetAllByCondition("PRODUCTION_NAME='" + str_product_name + "'"); if (dt.Rows.Count > 0) { AsmproductionWayRecord_BLL.DeleteAllByCondition("PRODUCTION_NAME='" + str_product_name + "'"); StoreData(); } else { StoreData(); } MessageBox.Show("保存成功!"); }
/// <summary> /// 查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_select_Click(object sender, EventArgs e) { try { this.addFlow.Clear(); this.CreateDiagram(this.addFlow); bt_save.Enabled = true; addFlow.Enabled = true; Node[] nodes = addFlow.Items.OfType <Node>().ToArray(); DataTable dt = AsmproductionWayRecord_BLL.GetAllByCondition("PRODUCTION_NAME = '" + cB_product_name.SelectedItem.ToString() + "'"); int K_left = 0, K_right = 0; if (!(dt.Rows.Count > 0)) { MessageBox.Show("该产品未配置工艺路线"); this.addFlow.Clear(); this.CreateDiagram(this.addFlow); return; } for (int j = 0; j < dt.Rows.Count; j++) { for (int i = 0; i < nodes.Count(); i++) { if (nodes[i].Text.Equals(dt.Rows[j]["ST_NAME"])) { K_left = i; break; } } j++; for (int i = 0; i < nodes.Count(); i++) { if (nodes[i].Text.Equals(dt.Rows[j]["ST_NAME"])) { K_right = i; break; } } //nodes[K_right].Location = new PointF(59 * (K_right + 2), 62 * (K_right + 2)); List <PointF> list = SetPointF(); nodes[K_left].Location = list[K_left]; nodes[K_right].Location = list[K_right]; Link link = new Link(nodes[K_left], nodes[K_right], "", addFlow); this.addFlow.AddLink(link); } } catch (Exception eee) { } }
/// <summary> /// 存储数据 /// </summary> public void StoreData() { try { List <Item> list_item = addFlow.Items; DataTable dt = AsmStation_BLL.GetAllStation(); AsmProductionWayRecordObject apwo = null; AsmProductionWayRecordObject apwo_right = null; List <string> list = new List <string>(); bool judge = false; bool judge_right = false; int j = 1; List <Item> list_link = new List <Item>(); for (int i = 0; i < list_item.Count; i++) { if (list_item[i].GetType().ToString().Contains("Link")) { list_link.Add(list_item[i]); } } for (int i = 0; i < list_link.Count; i++) { string str_left = (list_link[i] as Link).Org.Text; string str_right = (list_link[i] as Link).Dst.Text; if (list.Count > 0) { for (int m = 0; m < list.Count; m++) { if (str_left.Equals(list[m])) { judge = false; } else { judge = true; } } } else { judge = true; } if (judge) { apwo = new AsmProductionWayRecordObject(); apwo.ST_NAME = str_left; AsmProductionObject apo = AsmProduction_BLL.GetAsmProductionByCondition("PRODUCTION_NAME='" + cB_product_name.SelectedItem.ToString() + "'"); if (apo != null) { apwo.PRODUCTION_NAME = apo.PRODUCTION_NAME; apwo.PRODUCTION_ID = apo.PRODUCTION_ID; } AsmStationObject aso = AsmStation_BLL.GetStationByCondition("STATION_NAME='" + apwo.ST_NAME + "'"); if (aso != null) { apwo.ST_ID = aso.STATION_ID; } apwo.DT = System.DateTime.Now; apwo.SERIAL_NO = j++; AsmproductionWayRecord_BLL.AddRecord(apwo); } if (list.Count > 0) { for (int m = 0; m < list.Count; m++) { if (str_right.Equals(list[m])) { judge_right = false; } else { judge_right = true; } } } else { judge_right = true; } if (judge_right) { apwo_right = new AsmProductionWayRecordObject(); apwo_right.ST_NAME = str_right; AsmProductionObject apoX = AsmProduction_BLL.GetAsmProductionByCondition("PRODUCTION_NAME='" + cB_product_name.SelectedItem.ToString() + "'"); apwo_right.PRODUCTION_NAME = apoX.PRODUCTION_NAME; apwo_right.PRODUCTION_ID = apoX.PRODUCTION_ID; AsmStationObject asoX = AsmStation_BLL.GetStationByCondition("STATION_NAME='" + apwo_right.ST_NAME + "'"); apwo_right.ST_ID = asoX.STATION_ID; apwo_right.DT = System.DateTime.Now; apwo_right.SERIAL_NO = j++; AsmproductionWayRecord_BLL.AddRecord(apwo_right); } } DataTable dt_way = AsmProductionWay_BLL.GetWayByCondition("PRODUCTION_NAME= '" + cB_product_name.SelectedItem.ToString().Trim() + "'"); if (!(dt_way.Rows.Count > 0)) { DataTable dt_record = AsmproductionWayRecord_BLL.GetAllRecordByCondition(cB_product_name.SelectedItem.ToString().Trim()); AsmProductionWayObject apwro = null; for (int i = 0; i < dt_record.Rows.Count; i++) { apwro = new AsmProductionWayObject(); apwro.ST_NAME = dt_record.Rows[i]["ST_NAME"].ToString(); apwro.DT = Convert.ToDateTime(dt_record.Rows[i]["DT"].ToString()); apwro.PRODUCTION_NAME = dt_record.Rows[i]["PRODUCTION_NAME"].ToString(); apwro.PRODUCTION_ID = Convert.ToInt32(dt_record.Rows[i]["PRODUCTION_ID"].ToString()); apwro.ST_NAME = dt_record.Rows[i]["ST_NAME"].ToString(); apwro.ST_ID = Convert.ToInt32(dt_record.Rows[i]["ST_ID"].ToString()); apwro.SERIAL_NO = i + 1; AsmProductionWay_BLL.AddRoutingRecord(apwro); } } else { AsmProductionWay_BLL.DeleteAllByCondition("PRODUCTION_NAME= '" + cB_product_name.SelectedItem.ToString().Trim() + "'"); DataTable dt_record = AsmproductionWayRecord_BLL.GetAllRecordByCondition(cB_product_name.SelectedItem.ToString().Trim()); AsmProductionWayObject apwro = null; for (int i = 0; i < dt_record.Rows.Count; i++) { apwro = new AsmProductionWayObject(); apwro.DT = Convert.ToDateTime(dt_record.Rows[i]["DT"]); apwro.PRODUCTION_NAME = dt_record.Rows[i]["PRODUCTION_NAME"].ToString(); apwro.PRODUCTION_ID = Convert.ToInt32(dt_record.Rows[i]["PRODUCTION_ID"].ToString()); apwro.ST_NAME = dt_record.Rows[i]["ST_NAME"].ToString(); apwro.ST_ID = Convert.ToInt32(dt_record.Rows[i]["ST_ID"].ToString()); apwro.SERIAL_NO = i + 1; AsmProductionWay_BLL.AddRoutingRecord(apwro); } } } catch (Exception) { } }