/// <summary> /// 增加一条数据 /// </summary> public int Add(Cao.WMS.Model.caowms.Store model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Store("); strSql.Append("SGID,SWID,STopLine,SbaseLine,SQuantity)"); strSql.Append(" values ("); strSql.Append("@SGID,@SWID,@STopLine,@SbaseLine,@SQuantity)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@SGID", SqlDbType.NVarChar, 50), new SqlParameter("@SWID", SqlDbType.NVarChar, 50), new SqlParameter("@STopLine", SqlDbType.Int, 4), new SqlParameter("@SbaseLine", SqlDbType.Int, 4), new SqlParameter("@SQuantity", SqlDbType.Int, 4) }; parameters[0].Value = model.SGID; parameters[1].Value = model.SWID; parameters[2].Value = model.STopLine; parameters[3].Value = model.SbaseLine; parameters[4].Value = model.SQuantity; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/* * /// <summary> * /// 分页获取数据列表 * /// </summary> * public DataSet GetList(int PageSize,int PageIndex,string strWhere) * { * SqlParameter[] parameters = { * new SqlParameter("@tblName", SqlDbType.VarChar, 255), * new SqlParameter("@fldName", SqlDbType.VarChar, 255), * new SqlParameter("@PageSize", SqlDbType.Int), * new SqlParameter("@PageIndex", SqlDbType.Int), * new SqlParameter("@IsReCount", SqlDbType.Bit), * new SqlParameter("@OrderType", SqlDbType.Bit), * new SqlParameter("@strWhere", SqlDbType.VarChar,1000), * }; * parameters[0].Value = "Store"; * parameters[1].Value = "SID"; * parameters[2].Value = PageSize; * parameters[3].Value = PageIndex; * parameters[4].Value = 0; * parameters[5].Value = 0; * parameters[6].Value = strWhere; * return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); * }*/ #endregion BasicMethod #region ExtensionMethod /// <summary> /// 得到一个对象实体 /// </summary> public Cao.WMS.Model.caowms.Store GetModel(string SGID, string SWID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 SID,SGID,SWID,STopLine,SbaseLine,SQuantity from Store "); strSql.Append(" where SGID=@SGID"); strSql.Append(" and SWID=@SWID"); SqlParameter[] parameters = { new SqlParameter("@SGID", SqlDbType.NVarChar, 50), new SqlParameter("@SWID", SqlDbType.NVarChar, 50) }; parameters[0].Value = SGID; parameters[1].Value = SWID; Cao.WMS.Model.caowms.Store model = new Cao.WMS.Model.caowms.Store(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Cao.WMS.Model.caowms.Store DataRowToModel(DataRow row) { Cao.WMS.Model.caowms.Store model = new Cao.WMS.Model.caowms.Store(); if (row != null) { if (row["SID"] != null && row["SID"].ToString() != "") { model.SID = int.Parse(row["SID"].ToString()); } if (row["SGID"] != null) { model.SGID = row["SGID"].ToString(); } if (row["SWID"] != null && row["SWID"].ToString() != "") { model.SWID = row["SWID"].ToString(); } if (row["STopLine"] != null && row["STopLine"].ToString() != "") { model.STopLine = int.Parse(row["STopLine"].ToString()); } if (row["SbaseLine"] != null && row["SbaseLine"].ToString() != "") { model.SbaseLine = int.Parse(row["SbaseLine"].ToString()); } if (row["SQuantity"] != null && row["SQuantity"].ToString() != "") { model.SQuantity = int.Parse(row["SQuantity"].ToString()); } } return(model); }
private void ShowInfo(int SID) { Cao.WMS.BLL.caowms.Store bll = new Cao.WMS.BLL.caowms.Store(); Cao.WMS.Model.caowms.Store model = bll.GetModel(SID); this.lblSID.Text = model.SID.ToString(); this.lblSGID.Text = model.SGID; this.lblSWID.Text = model.SWID.ToString(); this.lblSTopLine.Text = model.STopLine.ToString(); this.lblSbaseLine.Text = model.SbaseLine.ToString(); this.lblSQuantity.Text = model.SQuantity.ToString(); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtSGID.Text.Trim().Length == 0) { strErr += "货物类型编号不能为空!\\n"; } if (!PageValidate.IsNumber(txtSWID.Text)) { strErr += "存放仓库编号格式错误!\\n"; } if (!PageValidate.IsNumber(txtSTopLine.Text)) { strErr += "货物存放下限格式错误!\\n"; } if (!PageValidate.IsNumber(txtSbaseLine.Text)) { strErr += "货物存放上限格式错误!\\n"; } if (!PageValidate.IsNumber(txtSQuantity.Text)) { strErr += "当前存储量格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int SID = int.Parse(this.lblSID.Text); string SGID = this.txtSGID.Text; string SWID = this.txtSWID.Text; int STopLine = int.Parse(this.txtSTopLine.Text); int SbaseLine = int.Parse(this.txtSbaseLine.Text); int SQuantity = int.Parse(this.txtSQuantity.Text); Cao.WMS.Model.caowms.Store model = new Cao.WMS.Model.caowms.Store(); model.SID = SID; model.SGID = SGID; model.SWID = SWID; model.STopLine = STopLine; model.SbaseLine = SbaseLine; model.SQuantity = SQuantity; Cao.WMS.BLL.caowms.Store bll = new Cao.WMS.BLL.caowms.Store(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Cao.WMS.Model.caowms.Store model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Store set "); strSql.Append("SGID=@SGID,"); strSql.Append("SWID=@SWID,"); strSql.Append("STopLine=@STopLine,"); strSql.Append("SbaseLine=@SbaseLine,"); strSql.Append("SQuantity=@SQuantity"); strSql.Append(" where SID=@SID"); SqlParameter[] parameters = { new SqlParameter("@SGID", SqlDbType.NVarChar, 50), new SqlParameter("@SWID", SqlDbType.NVarChar, 50), new SqlParameter("@STopLine", SqlDbType.Int, 4), new SqlParameter("@SbaseLine", SqlDbType.Int, 4), new SqlParameter("@SQuantity", SqlDbType.Int, 4), new SqlParameter("@SID", SqlDbType.Int, 4) }; parameters[0].Value = model.SGID; parameters[1].Value = model.SWID; parameters[2].Value = model.STopLine; parameters[3].Value = model.SbaseLine; parameters[4].Value = model.SQuantity; parameters[5].Value = model.SID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtRGID.Text.Trim().Length == 0) { strErr += "SKU编号不能为空!\\n"; } if (this.txtRWID.Text.Trim().Length == 0) { strErr += "存储仓库编号不能为空!\\n"; } if (!PageValidate.IsNumber(txtRQuantity.Text)) { strErr += "进出数量格式错误!\\n"; } //if(!PageValidate.IsNumber(txtRtype.Text)) //{ // strErr+="1入库 2出库格式错误!\\n"; //} if (this.txtRHandler.Text.Trim().Length == 0) { strErr += "提(送)货人名不能为空!\\n"; } if (!PageValidate.IsDateTime(txtRTime.Text)) { strErr += "RTime格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int RID = int.Parse(this.lblRID.Text); string RGID = this.txtRGID.Text; string RWID = this.txtRWID.Text; int RQuantity = int.Parse(this.txtRQuantity.Text); int Rtype = 1; string RHandler = this.txtRHandler.Text; DateTime RTime = DateTime.Parse(this.txtRTime.Text); if (RadioButton2.Checked == true) { Rtype = 2; } else { Rtype = 1; } //判断如果SKU和仓库 addGoods(); addWarehouses(); //如果没有此款规则 则添加默认规则 ExistsGoodsGIDadnWarehousesWID(); if (!addStore) { newSQuantity = "0"; //当前数量为0; } else { modelStore = bllStore.GetModel(this.txtRGID.Text, this.txtRWID.Text); newSQuantity = modelStore.SQuantity.ToString(); } //否则 根据出入库计算 当前数据 //当前数量 入库则加 if (Rtype == 1) { //当前数据库加 现在入库的 // newSQuantity = Convert.ToString(int.Parse(newSQuantity) + int.Parse(txtSQuantity.Text)); newSQuantity = Convert.ToString(int.Parse(newSQuantity) + RQuantity); modelStore.SQuantity = int.Parse(newSQuantity); bllStore.Update(modelStore); } //出库则减 else { //当前数据库减 现在入库的 //newSQuantity = Convert.ToString(int.Parse(newSQuantity) - int.Parse(txtSQuantity.Text)); newSQuantity = Convert.ToString(int.Parse(newSQuantity) + RQuantity); if (int.Parse(newSQuantity) < 0) { strErr += "超出库存量 \\n"; MessageBox.Show(this, strErr); return; } if (int.Parse(newSQuantity) == 0) { strErr += "SKU清空为0 \\n"; MessageBox.Show(this, strErr); // return; } modelStore.SQuantity = int.Parse(newSQuantity); bllStore.Update(modelStore); } Cao.WMS.Model.caowms.Records model = new Cao.WMS.Model.caowms.Records(); model.RID = RID; model.RGID = RGID; model.RWID = RWID; model.RQuantity = RQuantity; model.Rtype = Rtype; model.RHandler = RHandler; model.RTime = RTime; model.n_bakk = this.txt_bak.Text.Trim(); Cao.WMS.BLL.caowms.Records bll = new Cao.WMS.BLL.caowms.Records(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }