private void ShowInfo(int RID) { Cao.WMS.BLL.caowms.Records bll = new Cao.WMS.BLL.caowms.Records(); Cao.WMS.Model.caowms.Records model = bll.GetModel(RID); this.lblRID.Text = model.RID.ToString(); this.lblRGID.Text = model.RGID; this.lblRWID.Text = model.RWID.ToString(); this.lblRQuantity.Text = model.RQuantity.ToString(); this.lblRtype.Text = model.Rtype.ToString(); this.lblRHandler.Text = model.RHandler; this.lblRTime.Text = model.RTime.ToString(); this.lbln_bakk.Text = model.n_bakk.ToString(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Cao.WMS.Model.caowms.Records model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Records set "); strSql.Append("RGID=@RGID,"); strSql.Append("RWID=@RWID,"); strSql.Append("RQuantity=@RQuantity,"); strSql.Append("Rtype=@Rtype,"); strSql.Append("RHandler=@RHandler,"); strSql.Append("RTime=@RTime"); strSql.Append("n_bakk=@n_bakk,"); strSql.Append(" where RID=@RID"); SqlParameter[] parameters = { new SqlParameter("@RGID", SqlDbType.NVarChar, 50), new SqlParameter("@RWID", SqlDbType.Int, 4), new SqlParameter("@RQuantity", SqlDbType.Int, 4), new SqlParameter("@Rtype", SqlDbType.Int, 4), new SqlParameter("@RHandler", SqlDbType.NVarChar, 50), new SqlParameter("@RTime", SqlDbType.DateTime), new SqlParameter("@n_bakk", SqlDbType.NVarChar, 200), new SqlParameter("@RID", SqlDbType.Int, 4) }; parameters[0].Value = model.RGID; parameters[1].Value = model.RWID; parameters[2].Value = model.RQuantity; parameters[3].Value = model.Rtype; parameters[4].Value = model.RHandler; parameters[5].Value = model.RTime; parameters[6].Value = model.n_bakk; parameters[7].Value = model.RID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Cao.WMS.Model.caowms.Records DataRowToModel(DataRow row) { Cao.WMS.Model.caowms.Records model = new Cao.WMS.Model.caowms.Records(); if (row != null) { if (row["RID"] != null && row["RID"].ToString() != "") { model.RID = int.Parse(row["RID"].ToString()); } if (row["RGID"] != null) { model.RGID = row["RGID"].ToString(); } if (row["RWID"] != null && row["RWID"].ToString() != "") { model.RWID = row["RWID"].ToString(); } if (row["RQuantity"] != null && row["RQuantity"].ToString() != "") { model.RQuantity = int.Parse(row["RQuantity"].ToString()); } if (row["Rtype"] != null && row["Rtype"].ToString() != "") { model.Rtype = int.Parse(row["Rtype"].ToString()); } if (row["RHandler"] != null) { model.RHandler = row["RHandler"].ToString(); } if (row["n_bakk"] != null) { model.n_bakk = row["n_bakk"].ToString(); } if (row["RTime"] != null && row["RTime"].ToString() != "") { model.RTime = DateTime.Parse(row["RTime"].ToString()); } } return(model); }
private void ShowInfo(int RID) { Cao.WMS.BLL.caowms.Records bll = new Cao.WMS.BLL.caowms.Records(); Cao.WMS.Model.caowms.Records model = bll.GetModel(RID); this.lblRID.Text = model.RID.ToString(); this.txtRGID.Text = model.RGID; this.txtRWID.Text = model.RWID.ToString(); this.txtRQuantity.Text = model.RQuantity.ToString(); //this.txtRtype.Text=model.Rtype.ToString(); if (model.Rtype == 2) { this.RadioButton2.Checked = true; } else { this.RadioButton1.Checked = true; } this.txtRHandler.Text = model.RHandler; this.txtRTime.Text = model.RTime.ToString(); this.txt_bak.Text = model.n_bakk; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Cao.WMS.Model.caowms.Records model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Records("); strSql.Append("RGID,RWID,RQuantity,Rtype,RHandler,RTime,n_bakk)"); strSql.Append(" values ("); strSql.Append("@RGID,@RWID,@RQuantity,@Rtype,@RHandler,@RTime,@n_bakk)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@RGID", SqlDbType.NVarChar, 50), new SqlParameter("@RWID", SqlDbType.Int, 4), new SqlParameter("@RQuantity", SqlDbType.Int, 4), new SqlParameter("@Rtype", SqlDbType.Int, 4), new SqlParameter("@RHandler", SqlDbType.NVarChar, 50), new SqlParameter("@RTime", SqlDbType.DateTime), new SqlParameter("@n_bakk", SqlDbType.NVarChar, 200) }; parameters[0].Value = model.RGID; parameters[1].Value = model.RWID; parameters[2].Value = model.RQuantity; parameters[3].Value = model.Rtype; parameters[4].Value = model.RHandler; parameters[5].Value = model.RTime; parameters[4].Value = model.n_bakk; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Cao.WMS.Model.caowms.Records GetModel(int RID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 RID,RGID,RWID,RQuantity,Rtype,RHandler,RTime,n_bakk from Records "); strSql.Append(" where RID=@RID"); SqlParameter[] parameters = { new SqlParameter("@RID", SqlDbType.Int, 4) }; parameters[0].Value = RID; Cao.WMS.Model.caowms.Records model = new Cao.WMS.Model.caowms.Records(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
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"); }