/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.MoveStore_ProductControl DataRowToModel(DataRow row) { Maticsoft.Model.MoveStore_ProductControl model = new Maticsoft.Model.MoveStore_ProductControl(); if (row != null) { if (row["MS_ID"] != null && row["MS_ID"].ToString() != "") { model.MS_ID = decimal.Parse(row["MS_ID"].ToString()); } if (row["Send_WK"] != null) { model.Send_WK = row["Send_WK"].ToString(); } if (row["Send_State"] != null) { model.Send_State = row["Send_State"].ToString(); } if (row["Send_USID"] != null) { model.Send_USID = row["Send_USID"].ToString(); } if (row["Receive_WK"] != null) { model.Receive_WK = row["Receive_WK"].ToString(); } if (row["Receive_State"] != null) { model.Receive_State = row["Receive_State"].ToString(); } if (row["Receive_USID"] != null) { model.Receive_USID = row["Receive_USID"].ToString(); } if (row["Count"] != null) { model.Count = row["Count"].ToString(); } if (row["Ord_ID"] != null) { model.Ord_ID = row["Ord_ID"].ToString(); } if (row["PB_ID"] != null) { model.PB_ID = row["PB_ID"].ToString(); } if (row["Note"] != null) { model.Note = row["Note"].ToString(); } if (row["DataTime"] != null) { model.Note = row["DataTime"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.MoveStore_ProductControl model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_MoveStore_ProductControl set "); strSql.Append("Send_WK=@Send_WK,"); strSql.Append("Send_State=@Send_State,"); strSql.Append("Send_USID=@Send_USID,"); strSql.Append("Receive_WK=@Receive_WK,"); strSql.Append("Receive_State=@Receive_State,"); strSql.Append("Receive_USID=@Receive_USID,"); strSql.Append("Count=@Count,"); strSql.Append("Ord_ID=@Ord_ID,"); strSql.Append("PB_ID=@PB_ID,"); strSql.Append("Note=@Note,"); strSql.Append("DataTime=@DataTime"); strSql.Append(" where MS_ID=@MS_ID"); SqlParameter[] parameters = { new SqlParameter("@Send_WK", SqlDbType.VarChar, 50), new SqlParameter("@Send_State", SqlDbType.VarChar, 50), new SqlParameter("@Send_USID", SqlDbType.VarChar, 50), new SqlParameter("@Receive_WK", SqlDbType.VarChar, 50), new SqlParameter("@Receive_State", SqlDbType.VarChar, 50), new SqlParameter("@Receive_USID", SqlDbType.VarChar, 50), new SqlParameter("@Count", SqlDbType.VarChar, 50), new SqlParameter("@Ord_ID", SqlDbType.VarChar, 50), new SqlParameter("@PB_ID", SqlDbType.VarChar, 50), new SqlParameter("@Note", SqlDbType.Text), new SqlParameter("@MS_ID", SqlDbType.Decimal, 9), new SqlParameter("@DataTime", SqlDbType.DateTime) }; parameters[0].Value = model.Send_WK; parameters[1].Value = model.Send_State; parameters[2].Value = model.Send_USID; parameters[3].Value = model.Receive_WK; parameters[4].Value = model.Receive_State; parameters[5].Value = model.Receive_USID; parameters[6].Value = model.Count; parameters[7].Value = model.Ord_ID; parameters[8].Value = model.PB_ID; parameters[9].Value = model.Note; parameters[10].Value = model.MS_ID; parameters[11].Value = model.DataTime; int rows = dbs.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
// //选择领线记录 // private void dgv_Source_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (dgv_Source.SelectedIndex >= 0) { btn_Add.IsEnabled = false; IsEn(true, false); _WTT_MoveStore_ProductControl = (Maticsoft.Model.MoveStore_ProductControl)dgv_Source.SelectedItem; txb_Quantity.Text = _WTT_MoveStore_ProductControl.Count; } }
/// <summary> /// 增加一条数据 /// </summary> public decimal Add(Maticsoft.Model.MoveStore_ProductControl model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_MoveStore_ProductControl("); strSql.Append("Send_WK,Send_State,Send_USID,Receive_WK,Receive_State,Receive_USID,Count,Ord_ID,PB_ID,Note,DataTime)"); strSql.Append(" values ("); strSql.Append("@Send_WK,@Send_State,@Send_USID,@Receive_WK,@Receive_State,@Receive_USID,@Count,@Ord_ID,@PB_ID,@Note,@DataTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Send_WK", SqlDbType.VarChar, 50), new SqlParameter("@Send_State", SqlDbType.VarChar, 50), new SqlParameter("@Send_USID", SqlDbType.VarChar, 50), new SqlParameter("@Receive_WK", SqlDbType.VarChar, 50), new SqlParameter("@Receive_State", SqlDbType.VarChar, 50), new SqlParameter("@Receive_USID", SqlDbType.VarChar, 50), new SqlParameter("@Count", SqlDbType.VarChar, 50), new SqlParameter("@Ord_ID", SqlDbType.VarChar, 50), new SqlParameter("@PB_ID", SqlDbType.VarChar, 50), new SqlParameter("@Note", SqlDbType.Text), new SqlParameter("@DataTime", SqlDbType.DateTime) }; parameters[0].Value = model.Send_WK; parameters[1].Value = model.Send_State; parameters[2].Value = model.Send_USID; parameters[3].Value = model.Receive_WK; parameters[4].Value = model.Receive_State; parameters[5].Value = model.Receive_USID; parameters[6].Value = model.Count; parameters[7].Value = model.Ord_ID; parameters[8].Value = model.PB_ID; parameters[9].Value = model.Note; parameters[10].Value = model.DataTime; object obj = dbs.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
// //添加记录 // private void btn_Add_Click(object sender, RoutedEventArgs e) { _WTT_MoveStore_ProductControl = new Maticsoft.Model.MoveStore_ProductControl() { Ord_ID = _WTT_WorkOrder.OrderID, Receive_USID = _WTT_UserRcecive.UserID, Receive_State = _WTT_StateList_Receive.Ste_ID.ToString(), Receive_WK = _WTT_WK_Receive.Wo_ID.ToString(), Send_USID = _WTT_UserSend.UserID, Send_State = _WTT_StateList_Send.Ste_ID.ToString(), Send_WK = _WTT_WK_Send.Wo_ID.ToString(), Count = txb_Quantity.Text.Trim(), DataTime = DateTime.Now }; if (MCP_CS._M_MoveStore_ProductControl.Add(_WTT_MoveStore_ProductControl) > 0) { showInfo(_WTT_StateList_Receive); My_MessageBox.My_MessageBox_Message("添加成功!"); } else { My_MessageBox.My_MessageBox_Message("添加失败!"); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.MoveStore_ProductControl GetModel(decimal MS_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 MS_ID,Send_WK,Send_State,Send_USID,Receive_WK,Receive_State,Receive_USID,Count,Ord_ID,PB_ID,Note,DataTime from tb_MoveStore_ProductControl "); strSql.Append(" where MS_ID=@MS_ID"); SqlParameter[] parameters = { new SqlParameter("@MS_ID", SqlDbType.Decimal) }; parameters[0].Value = MS_ID; Maticsoft.Model.MoveStore_ProductControl model = new Maticsoft.Model.MoveStore_ProductControl(); DataSet ds = dbs.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }