Ejemplo n.º 1
0
        private void BT_Save_Click(object sender, EventArgs e)
        {
            if (aro == null)//未指定总成
            {
                MessageBox.Show("保存失败。请点击查询确认总成!");
            }
            else
            {
                #region >>>>>维护下线
                if (RB_Offline.Checked == true)
                {
                    AsmReworkResonObject arro = new AsmReworkResonObject();
                    arro.SN    = aro.SN;
                    arro.DT    = DateTime.Now;
                    arro.Type  = aro.TypeName;
                    arro.Reson = CB_Reson.Text + ";" + TB_Reson.Text;
                    if (AsmReworkReson_BLL.AddReworkReson(arro) > 0)
                    {
                        #region >>>>>将运行表中的数据转移到永久性表中
                        try
                        {
                            string             sql  = "sn='" + aro.SN + "'";
                            AsmRTrackingObject arto = AsmRTracking_BLL.GetAsmRTrackingObjectBySn(sql);
                            AsmPTrackingObject apto = new AsmPTrackingObject();
                            apto.DT          = arto.DT;
                            apto.ST          = arto.ST;
                            apto.BST         = arto.BST;
                            apto.SN          = arto.SN;
                            apto.EngineSN    = arto.EngineSN;
                            apto.GearboxSN   = arto.GearboxSN;
                            apto.TypeName    = arto.TypeName;
                            apto.TrayNum     = arto.TrayNum;
                            apto.ProductNum  = arto.ProductNum;
                            apto.STATUS      = "RF";
                            apto.PLAN_ID     = arto.PLAN_ID;
                            apto.REWORK_FLAG = arto.REWORK_FLAG;
                            apto.OFFLINE_DT  = DateTime.Now;
                            AsmPTracking_BLL.AddPTrackingObject(apto);
                            AsmRTracking_BLL.DeleteRTrackingByCondition("R_TRACKING_ID=" + arto.R_TRACKING_ID);
                            MessageBox.Show("保存成功!");
                            BT_Save.Enabled   = false;
                            TB_Sn.Text        = "";
                            label_ST.Text     = "";
                            label_Status.Text = "";
                            label_Type.Text   = "";
                            aro                      = null;
                            lststationDt             = null;
                            newstationDt             = null;
                            lststationDt             = AsmStation_BLL.GetOtherStation();
                            newstationDt             = AsmStation_BLL.GetFirstStation();
                            lstStation.DataSource    = lststationDt;
                            lstStation.DisplayMember = "STATION_NAME";
                            lstStation.ValueMember   = "STATION_ID";
                            newStation.DataSource    = newstationDt;
                            newStation.DisplayMember = "STATION_NAME";
                            newStation.ValueMember   = "STATION_ID";
                            CB_Reson.SelectedIndex   = -1;
                            TB_Reson.Text            = "";
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        #endregion
                    }
                    else
                    {
                        MessageBox.Show("保存失败,请检查输入信息是否正确!");
                    }
                }
                #endregion
                #region >>>>>返工
                else if (RB_Return.Checked == true)
                {
                    DataTable dt_way    = AsmReworkWay_BLL.SelectWayByCondition("SN='" + TB_Sn.Text.Trim() + "'");
                    DataTable dt_reason = AsmReworkReson_BLL.GetReasonByCondition("SN='" + TB_Sn.Text.Trim() + "'");
                    if (dt_way.Rows.Count > 0 || dt_reason.Rows.Count > 0)
                    {
                        AsmReworkWay_BLL.DeleteWayBycondition("SN='" + TB_Sn.Text.Trim() + "'");
                        AsmReworkReson_BLL.DeleteReasonByCondition("SN='" + TB_Sn.Text.Trim() + "'");
                        #region
                        //存储到ReworkWay表
                        AsmReworkWayObject arwo;
                        for (int i = 0; i < newstationDt.Rows.Count; i++)
                        {
                            arwo           = new AsmReworkWayObject();
                            arwo.DT        = DateTime.Now;
                            arwo.SN        = aro.SN;
                            arwo.ST_NAME   = newstationDt.Rows[i][2].ToString();
                            arwo.ST_ID     = int.Parse(newstationDt.Rows[i][0].ToString());
                            arwo.SERIAL_NO = i;
                            AsmReworkWay_BLL.AddReworkWay(arwo);
                        }
                        //存储到ReworkReson表
                        AsmReworkResonObject arro = new AsmReworkResonObject();
                        arro.SN    = aro.SN;
                        arro.DT    = DateTime.Now;
                        arro.Type  = aro.TypeName;
                        arro.Reson = CB_Reson.Text + ";" + TB_Reson.Text;
                        if (AsmReworkReson_BLL.AddReworkReson(arro) > 0)
                        {
                            #region >>>>>将运行表中的数据转移到永久性表中
                            try
                            {
                                //string sql = "sn='" + aro.SN + "'";
                                //AsmRTrackingObject arto = AsmRTracking_BLL.GetAsmRTrackingObjectBySn(sql);
                                //AsmPTrackingObject apto = new AsmPTrackingObject();
                                //apto.DT = System.DateTime.Now;
                                //apto.ST = arto.ST;
                                //apto.BST = arto.BST;
                                //apto.SN = arto.SN;
                                //apto.EngineSN = arto.EngineSN;
                                //apto.GearboxSN = arto.GearboxSN;
                                //apto.TypeName = arto.TypeName;
                                //apto.TrayNum = arto.TrayNum;
                                //apto.ProductNum = arto.ProductNum;
                                //apto.STATUS = "NG";
                                //AsmPTracking_BLL.AddPTrackingObject(apto);
                                //AsmRTracking_BLL.DeleteRTrackingByCondition("R_TRACKING_ID=" + arto.R_TRACKING_ID);
                                MessageBox.Show("保存成功!");
                                BT_Save.Enabled   = false;
                                TB_Sn.Text        = "";
                                label_ST.Text     = "";
                                label_Status.Text = "";
                                label_Type.Text   = "";
                                aro                      = null;
                                lststationDt             = null;
                                newstationDt             = null;
                                lststationDt             = AsmStation_BLL.GetOtherStation();
                                newstationDt             = AsmStation_BLL.GetFirstStation();
                                lstStation.DataSource    = lststationDt;
                                lstStation.DisplayMember = "STATION_NAME";
                                lstStation.ValueMember   = "STATION_ID";
                                newStation.DataSource    = newstationDt;
                                newStation.DisplayMember = "STATION_NAME";
                                newStation.ValueMember   = "STATION_ID";
                                CB_Reson.SelectedIndex   = -1;
                                TB_Reson.Text            = "";
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                            #endregion
                        }
                        else
                        {
                            MessageBox.Show("保存失败,请检查输入信息是否正确!");
                        }
                        #endregion
                    }

                    else
                    {
                        #region
                        //存储到ReworkWay表
                        AsmReworkWayObject arwo;
                        for (int i = 0; i < newstationDt.Rows.Count; i++)
                        {
                            arwo           = new AsmReworkWayObject();
                            arwo.DT        = DateTime.Now;
                            arwo.SN        = aro.SN;
                            arwo.ST_NAME   = newstationDt.Rows[i][2].ToString();
                            arwo.ST_ID     = int.Parse(newstationDt.Rows[i][0].ToString());
                            arwo.SERIAL_NO = i;
                            AsmReworkWay_BLL.AddReworkWay(arwo);
                        }
                        //存储到ReworkReson表
                        AsmReworkResonObject arro = new AsmReworkResonObject();
                        arro.SN    = aro.SN;
                        arro.DT    = DateTime.Now;
                        arro.Type  = aro.TypeName;
                        arro.Reson = CB_Reson.Text + ";" + TB_Reson.Text;
                        if (AsmReworkReson_BLL.AddReworkReson(arro) > 0)
                        {
                            #region >>>>>将运行表中的数据转移到永久性表中
                            try
                            {
                                //string sql = "sn='" + aro.SN + "'";
                                //AsmRTrackingObject arto = AsmRTracking_BLL.GetAsmRTrackingObjectBySn(sql);
                                //AsmPTrackingObject apto = new AsmPTrackingObject();
                                //apto.DT = System.DateTime.Now;
                                //apto.ST = arto.ST;
                                //apto.BST = arto.BST;
                                //apto.SN = arto.SN;
                                //apto.EngineSN = arto.EngineSN;
                                //apto.GearboxSN = arto.GearboxSN;
                                //apto.TypeName = arto.TypeName;
                                //apto.TrayNum = arto.TrayNum;
                                //apto.ProductNum = arto.ProductNum;
                                //apto.STATUS = "NG";
                                //AsmPTracking_BLL.AddPTrackingObject(apto);
                                //AsmRTracking_BLL.DeleteRTrackingByCondition("R_TRACKING_ID=" + arto.R_TRACKING_ID);
                                MessageBox.Show("保存成功!");
                                BT_Save.Enabled   = false;
                                TB_Sn.Text        = "";
                                label_ST.Text     = "";
                                label_Status.Text = "";
                                label_Type.Text   = "";
                                aro                      = null;
                                lststationDt             = null;
                                newstationDt             = null;
                                lststationDt             = AsmStation_BLL.GetOtherStation();
                                newstationDt             = AsmStation_BLL.GetFirstStation();
                                lstStation.DataSource    = lststationDt;
                                lstStation.DisplayMember = "STATION_NAME";
                                lstStation.ValueMember   = "STATION_ID";
                                newStation.DataSource    = newstationDt;
                                newStation.DisplayMember = "STATION_NAME";
                                newStation.ValueMember   = "STATION_ID";
                                CB_Reson.SelectedIndex   = -1;
                                TB_Reson.Text            = "";
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                            #endregion
                        }
                        else
                        {
                            MessageBox.Show("保存失败,请检查输入信息是否正确!");
                        }
                        #endregion
                    }
                }
                #endregion
                #region >>>>>报废
                else if (RB_Scrap.Checked == true)
                {
                    AsmReworkResonObject arro = new AsmReworkResonObject();
                    arro.SN    = aro.SN;
                    arro.DT    = DateTime.Now;
                    arro.Type  = aro.TypeName;
                    arro.Reson = CB_Reson.Text + ";" + TB_Reson.Text;
                    if (AsmReworkReson_BLL.AddReworkReson(arro) > 0)
                    {
                        #region >>>>>将运行表中的数据转移到永久性表中
                        try
                        {
                            string             sql  = "sn='" + aro.SN + "'";
                            AsmRTrackingObject arto = AsmRTracking_BLL.GetAsmRTrackingObjectBySn(sql);
                            AsmPTrackingObject apto = new AsmPTrackingObject();
                            apto.DT          = System.DateTime.Now;
                            apto.ST          = arto.ST;
                            apto.BST         = arto.BST;
                            apto.SN          = arto.SN;
                            apto.EngineSN    = arto.EngineSN;
                            apto.GearboxSN   = arto.GearboxSN;
                            apto.TypeName    = arto.TypeName;
                            apto.TrayNum     = arto.TrayNum;
                            apto.ProductNum  = arto.ProductNum;
                            apto.STATUS      = "RJ";
                            apto.PLAN_ID     = arto.PLAN_ID;
                            apto.REWORK_FLAG = arto.REWORK_FLAG;
                            apto.OFFLINE_DT  = DateTime.Now;
                            AsmPTracking_BLL.AddPTrackingObject(apto);
                            AsmRTracking_BLL.DeleteRTrackingByCondition("R_TRACKING_ID=" + arto.R_TRACKING_ID);
                            MessageBox.Show("保存成功!");
                            BT_Save.Enabled   = false;
                            TB_Sn.Text        = "";
                            label_ST.Text     = "";
                            label_Status.Text = "";
                            label_Type.Text   = "";
                            aro                      = null;
                            lststationDt             = null;
                            newstationDt             = null;
                            lststationDt             = AsmStation_BLL.GetOtherStation();
                            newstationDt             = AsmStation_BLL.GetFirstStation();
                            lstStation.DataSource    = lststationDt;
                            lstStation.DisplayMember = "STATION_NAME";
                            lstStation.ValueMember   = "STATION_ID";
                            newStation.DataSource    = newstationDt;
                            newStation.DisplayMember = "STATION_NAME";
                            newStation.ValueMember   = "STATION_ID";
                            CB_Reson.SelectedIndex   = -1;
                            TB_Reson.Text            = "";
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        #endregion
                    }
                    else
                    {
                        MessageBox.Show("保存失败,请检查输入信息是否正确!");
                    }
                }
                #endregion
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 查询
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BT_Search_Click(object sender, EventArgs e)
 {
     data = new Dictionary <string, object>();
     if (!String.IsNullOrEmpty(TB_Sn.Text))
     {
         AsmRTrackingObject aro = AsmRTracking_BLL.GetAsmRTrackingObjectBySn(" SN='" + TB_Sn.Text.Trim() + "'");
         if (aro != null)
         {
             label6.Text = TB_Sn.Text.Trim();
             label6.Refresh();
             label8.Text = aro.TypeName;
             label8.Refresh();
             label10.Text = aro.DT.ToString("yyyy-MM-dd HH:mm:ss");
             label10.Refresh();
             label12.Text = "           ";
             label12.Refresh();
             //data = new Dictionary<string, object>();
             data.Add("sn", TB_Sn.Text.Trim());
             data.Add("productionType", aro.TypeName);
             data.Add("onlineDate", aro.DT.ToString());
             data.Add("offlineDate", "");
             DataTable dt = Bolt_BLL.GetBoltByCondition(" SN='" + TB_Sn.Text.Trim() + "'");
             if (dt.Rows.Count != 0)
             {
                 DGV_Bolt.DataSource = dt;//DGV_Bolt接收数据
                 DGV_Bolt.Visible    = true;
                 label3.Visible      = true;
                 DGV_Bolt.ClearSelection();
             }
             else
             {
                 label3.Visible   = false;
                 DGV_Bolt.Visible = false;
             }
             data.Add("bolt", dt);
             DataTable materialdt = AsmKeypart_BLL.GetKeypartByCondition(" SN='" + TB_Sn.Text.Trim() + "'");
             if (materialdt.Rows.Count != 0)
             {
                 DGV_Material.DataSource = materialdt;//DGV_Material接收数据
                 DGV_Material.Visible    = true;
                 label2.Visible          = true;
                 DGV_Material.ClearSelection();
             }
             else
             {
                 label2.Visible       = false;
                 DGV_Material.Visible = false;
             }
             data.Add("material", materialdt);
             DataTable leakagedt = AsmLeakage_BLL.GetLeakageBySn(" SN='" + TB_Sn.Text.Trim() + "'");
             if (leakagedt.Rows.Count != 0)
             {
                 DGV_Leakage.DataSource = leakagedt;//DGV_Leakage接收数据
                 DGV_Leakage.Visible    = true;
                 label5.Visible         = true;
                 DGV_Leakage.ClearSelection();
             }
             else
             {
                 label5.Visible      = false;
                 DGV_Leakage.Visible = false;
             }
             data.Add("leakage", leakagedt);
             return;
         }
         else
         {
             AsmPTrackingObject apo = AsmPTracking_BLL.GetPTrackingObjectByCondition(" SN='" + TB_Sn.Text.Trim() + "'");
             if (apo != null)
             {
                 label6.Text = TB_Sn.Text.Trim();
                 label6.Refresh();
                 label8.Text = apo.TypeName;
                 label8.Refresh();
                 label10.Text = apo.DT.ToString("yyyy-MM-dd HH:mm:ss");
                 label10.Refresh();
                 label12.Text = apo.OFFLINE_DT.ToString("yyyy-MM-dd HH:mm:ss");
                 label12.Refresh();
                 //data = new Dictionary<string, object>();
                 data.Add("sn", TB_Sn.Text.Trim());
                 data.Add("productionType", apo.TypeName);
                 data.Add("onlineDate", apo.DT.ToString());
                 data.Add("offlineDate", apo.OFFLINE_DT.ToString());
                 DataTable dt = Bolt_BLL.GetBoltByCondition(" SN='" + TB_Sn.Text.Trim() + "'");
                 if (dt.Rows.Count != 0)
                 {
                     DGV_Bolt.DataSource = dt;//DGV_Bolt接收数据
                     DGV_Bolt.Visible    = true;
                     label3.Visible      = true;
                     DGV_Bolt.ClearSelection();
                 }
                 else
                 {
                     label3.Visible   = false;
                     DGV_Bolt.Visible = false;
                 }
                 data.Add("bolt", dt);
                 DataTable materialdt = AsmKeypart_BLL.GetKeypartByCondition(" SN='" + TB_Sn.Text.Trim() + "'");
                 if (materialdt.Rows.Count != 0)
                 {
                     DGV_Material.DataSource = materialdt;//DGV_Material接收数据
                     DGV_Material.Visible    = true;
                     label2.Visible          = true;
                     DGV_Material.ClearSelection();
                 }
                 else
                 {
                     label2.Visible       = false;
                     DGV_Material.Visible = false;
                 }
                 data.Add("material", materialdt);
                 DataTable leakagedt = AsmLeakage_BLL.GetLeakageBySn(" SN='" + TB_Sn.Text.Trim() + "'");
                 if (leakagedt.Rows.Count != 0)
                 {
                     DGV_Leakage.DataSource = leakagedt;//DGV_Leakage接收数据
                     DGV_Leakage.Visible    = true;
                     label5.Visible         = true;
                     DGV_Leakage.ClearSelection();
                 }
                 else
                 {
                     label5.Visible      = false;
                     DGV_Leakage.Visible = false;
                 }
                 data.Add("leakage", leakagedt);
                 return;
             }
             else
             {
                 MessageBox.Show("不存在此总成号,请重新输入");
                 TB_Sn.Text = "";
             }
         }
     }
     else
     {
         MessageBox.Show("请输入总成号!");
     }
 }