public static int AddReworkReson(AsmReworkResonObject uo) { using (IDbConnection conn = ClsCommon.OpenConnection()) //这里访问的是Sqlite数据文件,这里OpenConnection即上边获取连接数据库对象方法 { var result = conn.Insert(uo); return(Convert.ToInt32(result)); } }
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 } }
public static int AddReworkReson(AsmReworkResonObject uo) { int a = AsmReworkReson_DAL.AddReworkReson(uo); return(a); }