Exemplo n.º 1
0
        /// <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)
            {
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 添加纪录
 /// </summary>
 /// <param name="apwo"></param>
 public static void AddRecord(AsmProductionWayRecordObject apwo)
 {
     AsmProductionWayRecord_DAL.AddRecord(apwo);
 }
Exemplo n.º 3
0
        public static void AddRecord(AsmProductionWayRecordObject apwo)
        {
            string sl = "insert  into  dbo.C_ASM_PRODUCTION_WAY_T_Record (DT,PRODUCTION_NAME,PRODUCTION_ID,ST_NAME,ST_ID,SERIAL_NO) values('" + apwo.DT + "','" + apwo.PRODUCTION_NAME + "'," + apwo.PRODUCTION_ID + ",'" + apwo.ST_NAME + "'," + apwo.ST_ID + "," + apwo.SERIAL_NO + ")";

            ClsCommon.dbSql.ExecuteDataTable(sl);
        }