/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Material_Inject DataRowToModel(DataRow row) { Maticsoft.Model.Material_Inject model = new Maticsoft.Model.Material_Inject(); if (row != null) { if (row["In_ID"] != null && row["In_ID"].ToString() != "") { model.In_ID = decimal.Parse(row["In_ID"].ToString()); } if (row["Orm_ID"] != null) { model.Orm_ID = row["Orm_ID"].ToString(); } if (row["Count"] != null) { model.Count = row["Count"].ToString(); } if (row["UserID"] != null) { model.UserID = row["UserID"].ToString(); } if (row["WK_ID"] != null) { model.WK_ID = row["WK_ID"].ToString(); } if (row["DateTime"] != null && row["DateTime"].ToString() != "") { model.DateTime = DateTime.Parse(row["DateTime"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public decimal Add(Maticsoft.Model.Material_Inject model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_Material_Inject("); strSql.Append("Orm_ID,Count,UserID,WK_ID,DateTime)"); strSql.Append(" values ("); strSql.Append("@Orm_ID,@Count,@UserID,@WK_ID,@DateTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Orm_ID", SqlDbType.VarChar, 15), new SqlParameter("@Count", SqlDbType.VarChar, 50), new SqlParameter("@UserID", SqlDbType.VarChar, 50), new SqlParameter("@WK_ID", SqlDbType.VarChar, 50), new SqlParameter("@DateTime", SqlDbType.DateTime) }; parameters[0].Value = model.Orm_ID; parameters[1].Value = model.Count; parameters[2].Value = model.UserID; parameters[3].Value = model.WK_ID; parameters[4].Value = model.DateTime; object obj = dbs.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
// //选择投料记录 // private void dgv_source_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { btn_Add.IsEnabled = false; isEn(true, false); _WTT_Material_Inject = (Maticsoft.Model.Material_Inject)dgv_source.SelectedItem; txb_Count.Text = _WTT_Material_Inject.Count; txb_JobNumber_Receive.Text = _WTT_Material_Inject.UserID; _WTT_WK = MCP_CS._M_Workstation.GetModel(decimal.Parse(_WTT_Material_Inject.WK_ID)); cmb_Workstation_Receive.Text = _WTT_WK.Workstation; } catch { } }
// //添加投料数量 // private void btn_Add_Click(object sender, RoutedEventArgs e) { Maticsoft.Model.Material_Inject _Material_Inject = new Maticsoft.Model.Material_Inject() { Count = txb_Count.Text, DateTime = DateTime.Now, Orm_ID = Orm_ID, UserID = _WTT_User_Receive.UserID, WK_ID = _WTT_WK.Wo_ID.ToString() }; if (MCP_CS._M_Material_Inject.Add(_Material_Inject) > 0) { ShowUp(); My_MessageBox.My_MessageBox_Message("添加成功!"); } else { My_MessageBox.My_MessageBox_Message("添加失败!"); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Material_Inject model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_Material_Inject set "); strSql.Append("Orm_ID=@Orm_ID,"); strSql.Append("Count=@Count,"); strSql.Append("UserID=@UserID,"); strSql.Append("WK_ID=@WK_ID,"); strSql.Append("DateTime=@DateTime"); strSql.Append(" where In_ID=@In_ID"); SqlParameter[] parameters = { new SqlParameter("@Orm_ID", SqlDbType.VarChar, 15), new SqlParameter("@Count", SqlDbType.VarChar, 50), new SqlParameter("@UserID", SqlDbType.VarChar, 50), new SqlParameter("@WK_ID", SqlDbType.VarChar, 50), new SqlParameter("@DateTime", SqlDbType.DateTime), new SqlParameter("@In_ID", SqlDbType.Decimal, 9) }; parameters[0].Value = model.Orm_ID; parameters[1].Value = model.Count; parameters[2].Value = model.UserID; parameters[3].Value = model.WK_ID; parameters[4].Value = model.DateTime; parameters[5].Value = model.In_ID; int rows = dbs.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Material_Inject GetModel(decimal In_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 In_ID,Orm_ID,Count,UserID,WK_ID,DateTime from tb_Material_Inject "); strSql.Append(" where In_ID=@In_ID"); SqlParameter[] parameters = { new SqlParameter("@In_ID", SqlDbType.Decimal) }; parameters[0].Value = In_ID; Maticsoft.Model.Material_Inject model = new Maticsoft.Model.Material_Inject(); DataSet ds = dbs.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }