public static int AddPPlan(AsmPPlanObject uo) { using (IDbConnection conn = ClsCommon.OpenConnection()) //这里访问的是Sqlite数据文件,这里OpenConnection即上边获取连接数据库对象方法 { var result = conn.Insert(uo); return(Convert.ToInt32(result)); } }
public static int AddPPlan(AsmPPlanObject uo) { int a = AsmPPlan_DAL.AddPPlan(uo); return(a); }
/// <summary> /// 组合框事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ComboBox_SelectedIndexChanged(object sender, EventArgs e) { ComboBox combox = sender as ComboBox; //这里比较重要 // combox.Leave += new EventHandler(combox_Leave); try { //在这里就可以做值是否改变判断 if (combox.SelectedItem != null) { // ReflshDataGridView(); int row = DGV_Plan.SelectedRows[0].Index; if (combox.SelectedValue.ToString() == "0") { MessageBox.Show("计划已开始或已经是初始化,不能再初始化!"); combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged); ReflshDataGridView(); return; } else if (combox.SelectedValue.ToString() == "4" && Convert.ToInt32(planDt.Rows[row]["NUMBER"].ToString()) - Convert.ToInt32(planDt.Rows[row]["COMPLETE_NUMBER"].ToString()) > 0) { MessageBox.Show("计划没有完成,不能关闭计划!"); combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged); ReflshDataGridView(); return; } else if (combox.SelectedValue.ToString() == "4" && Convert.ToInt32(planDt.Rows[row]["NUMBER"].ToString()) - Convert.ToInt32(planDt.Rows[row]["COMPLETE_NUMBER"].ToString()) == 0) { combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged); #region >>>>>将运行时表中的数据转移到永久性表中 AsmPlanObject apo = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row]["ID"].ToString())); AsmPPlanObject appo = new AsmPPlanObject(); appo.DT = System.DateTime.Now; appo.COMPLETE_FLAG = "4"; appo.COMPLETE_NUMBER = apo.COMPLETE_NUMBER; appo.CREATE_BARCODE_FLAG = apo.CREATE_BARCODE_FLAG; appo.LINE_ID = apo.LINE_ID; appo.NAME = apo.NAME; appo.NG_NUMBER = apo.NG_NUMBER; appo.NUMBER = apo.NUMBER; appo.OK_NUMBER = apo.OK_NUMBER; appo.OPREATION_USER = apo.OPREATION_USER; appo.PLAN_LEVEL = apo.PLAN_LEVEL; appo.PRODUCTION_ID = apo.PRODUCTION_ID; appo.REMAIND_NUMBER = apo.REMAIND_NUMBER; AsmPPlan_BLL.AddPPlan(appo); AsmPlan_BLL.DeleteRPlanByCondition(" ID=" + apo.ID); if (row < this.DGV_Plan.Rows.Count - 1) { for (int i = 0; i < this.DGV_Plan.Rows.Count - 1 - row; i++) { AsmPlanObject apoNext = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row + i + 1]["ID"].ToString())); apoNext.PLAN_LEVEL = apo.PLAN_LEVEL + i; AsmPlan_BLL.UpdatePlan(apoNext); } } #endregion ReflshDataGridView(); return; } else if (combox.SelectedValue.ToString() == "3") { combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged); #region >>>>>将运行表中的数据转移到永久性表中 AsmPlanObject apo = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row]["ID"].ToString())); AsmPPlanObject appo = new AsmPPlanObject(); appo.DT = System.DateTime.Now; appo.COMPLETE_FLAG = "3"; appo.COMPLETE_NUMBER = apo.COMPLETE_NUMBER; appo.CREATE_BARCODE_FLAG = apo.CREATE_BARCODE_FLAG; appo.LINE_ID = apo.LINE_ID; appo.NAME = apo.NAME; appo.NG_NUMBER = apo.NG_NUMBER; appo.NUMBER = apo.NUMBER; appo.OK_NUMBER = apo.OK_NUMBER; appo.OPREATION_USER = apo.OPREATION_USER; appo.PLAN_LEVEL = apo.PLAN_LEVEL; appo.PRODUCTION_ID = apo.PRODUCTION_ID; appo.REMAIND_NUMBER = apo.REMAIND_NUMBER; AsmPPlan_BLL.AddPPlan(appo); AsmPlan_BLL.DeleteRPlanByCondition(" ID=" + apo.ID); if (row < this.DGV_Plan.Rows.Count - 1) { for (int i = 0; i < this.DGV_Plan.Rows.Count - 1 - row; i++) { AsmPlanObject apoNext = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row + i + 1]["ID"].ToString())); apoNext.PLAN_LEVEL = apo.PLAN_LEVEL + i; AsmPlan_BLL.UpdatePlan(apoNext); } } #endregion ReflshDataGridView(); return; } else { AsmPlanObject apo = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row]["ID"].ToString())); apo.COMPLETE_FLAG = combox.SelectedValue.ToString(); AsmPlan_BLL.UpdatePlan(apo); combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged); ReflshDataGridView(); // DGV_Plan.ClearSelection(); // DGV_Plan.Rows[row].Selected = true; return; } } // Thread.Sleep(100); } catch (Exception ex) { MessageBox.Show(ex.Message); } }