/// <summary> /// 增加一条数据 /// </summary> public decimal Add(Maticsoft.Model.ConsumableReceive model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_ConsumableReceive("); strSql.Append("C_Barcode,Count,UserName,Datetime,Remarks)"); strSql.Append(" values ("); strSql.Append("@C_Barcode,@Count,@UserName,@Datetime,@Remarks)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@C_Barcode", SqlDbType.VarChar, 50), new SqlParameter("@Count", SqlDbType.Int, 4), new SqlParameter("@UserName", SqlDbType.VarChar, 50), new SqlParameter("@Datetime", SqlDbType.VarChar, 50), new SqlParameter("@Remarks", SqlDbType.Text) }; parameters[0].Value = model.C_Barcode; parameters[1].Value = model.Count; parameters[2].Value = model.UserName; parameters[3].Value = model.Datetime; parameters[4].Value = model.Remarks; object obj = dbs.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToDecimal(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.ConsumableReceive DataRowToModel(DataRow row) { Maticsoft.Model.ConsumableReceive model = new Maticsoft.Model.ConsumableReceive(); if (row != null) { if (row["C_RecID"] != null && row["C_RecID"].ToString() != "") { model.C_RecID = decimal.Parse(row["C_RecID"].ToString()); } if (row["C_Barcode"] != null) { model.C_Barcode = row["C_Barcode"].ToString(); } if (row["Count"] != null && row["Count"].ToString() != "") { model.Count = int.Parse(row["Count"].ToString()); } if (row["UserName"] != null) { model.UserName = row["UserName"].ToString(); } if (row["Datetime"] != null) { model.Datetime = row["Datetime"].ToString(); } if (row["Remarks"] != null) { model.Remarks = row["Remarks"].ToString(); } } return(model); }
private void ShowInfo(decimal C_RecID) { Maticsoft.BLL.ConsumableReceive bll = new Maticsoft.BLL.ConsumableReceive(); Maticsoft.Model.ConsumableReceive model = bll.GetModel(C_RecID); this.lblC_RecID.Text = model.C_RecID.ToString(); this.lblC_Barcode.Text = model.C_Barcode; this.lblCount.Text = model.Count.ToString(); this.lblUserName.Text = model.UserName; this.lblDatetime.Text = model.Datetime; this.lblRemarks.Text = model.Remarks; }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtC_Barcode.Text.Trim().Length == 0) { strErr += "C_Barcode不能为空!\\n"; } if (!PageValidate.IsNumber(txtCount.Text)) { strErr += "Count格式错误!\\n"; } if (this.txtUserName.Text.Trim().Length == 0) { strErr += "UserName不能为空!\\n"; } if (this.txtDatetime.Text.Trim().Length == 0) { strErr += "Datetime不能为空!\\n"; } if (this.txtRemarks.Text.Trim().Length == 0) { strErr += "Remarks不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } decimal C_RecID = decimal.Parse(this.lblC_RecID.Text); string C_Barcode = this.txtC_Barcode.Text; int Count = int.Parse(this.txtCount.Text); string UserName = this.txtUserName.Text; string Datetime = this.txtDatetime.Text; string Remarks = this.txtRemarks.Text; Maticsoft.Model.ConsumableReceive model = new Maticsoft.Model.ConsumableReceive(); model.C_RecID = C_RecID; model.C_Barcode = C_Barcode; model.Count = Count; model.UserName = UserName; model.Datetime = Datetime; model.Remarks = Remarks; Maticsoft.BLL.ConsumableReceive bll = new Maticsoft.BLL.ConsumableReceive(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 保存领料记录 并更改库存 /// </summary> private int Add_Receive(DataGrid _Grid) { ConsumableReceive _M_ConsumableReceive = new ConsumableReceive(); ConsumableInfo _M_ConsumableInfo = new ConsumableInfo(); int _recode = 0; string _Message = ""; foreach (object tem in _Grid.ItemsSource) { Maticsoft.Model.ConsumableReceive _tem = (Maticsoft.Model.ConsumableReceive)tem; Maticsoft.Model.ConsumableInfo _ConsumableInfo = _M_ConsumableInfo.GetModel(_tem.C_Barcode); int _Count = 0, _SaftCount = 0, Stock = 0; int.TryParse(_tem.Count.ToString(), out _Count); //领取数量 int.TryParse(_ConsumableInfo.C_SafeStock, out _SaftCount); //安全库存 int.TryParse(_ConsumableInfo.Stock, out Stock); //当前剩余数量 if (_Count < Stock) //如果领取数量小于库存数量 { if ((Stock - _Count) <= _SaftCount) { _Message += "编号:" + _ConsumableInfo.C_Barcode + "名称:" + _ConsumableInfo.C_Name + "库存不足,请立即请购!"; } _tem.Datetime = DateTime.Now.ToString(); if (_M_ConsumableReceive.Add(_tem) > 0) { _recode++; } } else { _Message += "\r\n保存失败警告:编号:" + _ConsumableInfo.C_Barcode + "名称:" + _ConsumableInfo.C_Name + "库存不足,未进行保存"; } } if (_Message.Length > 2) { My_MessageBox.My_MessageBox_Message(_Message); } return(_recode); }
// //添加 // private void btn_Add_Click(object sender, RoutedEventArgs e) { Maticsoft.Model.ConsumableReceive _Receive = new Maticsoft.Model.ConsumableReceive(); // _Receive = (Maticsoft.Model.ConsumableReceive)dgv_ConsumableList.DataContext; Maticsoft.Model.ConsumableStorage _Storage = new Maticsoft.Model.ConsumableStorage(); // _Storage = (Maticsoft.Model.ConsumableStorage)dgv_ConsumableList.DataContext; bool IsOk = true; MCP_CS.CheckTextBoxNotNull(ref IsOk, txb_Consumable_Barcode, txb_R_Count, txb_R_Remaks, txb_R_UserID, txb_R_UserName); if (IsOk) { if (_ConsumOperation.Operation == Maticsoft.BLL.cls_Consumable.ConsumableOperation.Receive) { _Receive.C_Barcode = txb_Consumable_Barcode.Text.Trim(); _Receive.C_Name = txb_ConsumableName.Text.Trim(); _Receive.Datetime = DateTime.Now.ToString(); _Receive.Count = int.Parse(txb_R_Count.Text.Trim()); _Receive.UserName = txb_R_UserName.Text.Trim(); _Receive.Remarks = txb_R_Remaks.Text.Trim(); _dataList_Receive.Add(_Receive); } else { _Storage.C_Barcode = txb_Consumable_Barcode.Text.Trim(); _Storage.C_Name = txb_ConsumableName.Text.Trim(); _Storage.Datetime = DateTime.Now.ToString(); _Storage.Count = int.Parse(txb_R_Count.Text.Trim()); _Storage.UserName = txb_R_UserName.Text.Trim(); _Storage.Remarks = txb_R_Remaks.Text.Trim(); _dataList_Storage.Add(_Storage); } // txb_R_Count.Text = ""; txb_Consumable_Barcode.Text = ""; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.ConsumableReceive model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_ConsumableReceive set "); strSql.Append("C_Barcode=@C_Barcode,"); strSql.Append("Count=@Count,"); strSql.Append("UserName=@UserName,"); strSql.Append("Datetime=@Datetime,"); strSql.Append("Remarks=@Remarks"); strSql.Append(" where C_RecID=@C_RecID"); SqlParameter[] parameters = { new SqlParameter("@C_Barcode", SqlDbType.VarChar, 50), new SqlParameter("@Count", SqlDbType.Int, 4), new SqlParameter("@UserName", SqlDbType.VarChar, 50), new SqlParameter("@Datetime", SqlDbType.VarChar, 50), new SqlParameter("@Remarks", SqlDbType.Text), new SqlParameter("@C_RecID", SqlDbType.Decimal, 9) }; parameters[0].Value = model.C_Barcode; parameters[1].Value = model.Count; parameters[2].Value = model.UserName; parameters[3].Value = model.Datetime; parameters[4].Value = model.Remarks; parameters[5].Value = model.C_RecID; int rows = dbs.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.ConsumableReceive GetModel(decimal C_RecID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 C_RecID,C_Barcode,Count,UserName,Datetime,Remarks from tb_ConsumableReceive "); strSql.Append(" where C_RecID=@C_RecID"); SqlParameter[] parameters = { new SqlParameter("@C_RecID", SqlDbType.Decimal) }; parameters[0].Value = C_RecID; Maticsoft.Model.ConsumableReceive model = new Maticsoft.Model.ConsumableReceive(); DataSet ds = dbs.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }