public int Update(SqlTransaction trans, RefundingModel model) { StringBuilder builder = new StringBuilder(); builder.Append("update Sm_Refunding set "); builder.Append("rid=@rid,"); builder.Append("procode=@procode,"); builder.Append("tcode=@tcode,"); builder.Append("flowstate=@flowstate,"); builder.Append("isin=@isin,"); builder.Append("person=@person,"); builder.Append("intime=@intime,"); builder.Append("annx=@annx,"); builder.Append("explain=@explain, "); builder.Append(" isintime=@isintime "); builder.Append(" where rcode=@rcode "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@rid", SqlDbType.NVarChar, 50), new SqlParameter("@rcode", SqlDbType.NVarChar, 0x40), new SqlParameter("@procode", SqlDbType.NVarChar, 0x40), new SqlParameter("@tcode", SqlDbType.NVarChar, 0x200), new SqlParameter("@flowstate", SqlDbType.Int, 4), new SqlParameter("@isin", SqlDbType.Bit, 1), new SqlParameter("@person", SqlDbType.NVarChar, 0x40), new SqlParameter("@intime", SqlDbType.SmallDateTime), new SqlParameter("@annx", SqlDbType.NVarChar, 0x80), new SqlParameter("@explain", SqlDbType.NVarChar, 0x800), new SqlParameter("@isintime", SqlDateTime.MinValue) }; commandParameters[0].Value = model.rid; commandParameters[1].Value = model.rcode; commandParameters[2].Value = model.procode; commandParameters[3].Value = model.tcode; commandParameters[4].Value = model.flowstate; commandParameters[5].Value = model.isin; commandParameters[6].Value = model.person; commandParameters[7].Value = model.intime; commandParameters[8].Value = model.annx; commandParameters[9].Value = model.explain; commandParameters[10].Value = model.IsInTime; if (trans == null) { return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); } return(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters)); }
public RefundingModel ReaderBind(IDataReader dataReader) { RefundingModel model = new RefundingModel { rid = dataReader["rid"].ToString(), rcode = dataReader["rcode"].ToString(), procode = dataReader["procode"].ToString(), tcode = dataReader["tcode"].ToString() }; object obj2 = dataReader["flowstate"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { model.flowstate = (int)obj2; } obj2 = dataReader["isin"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { model.isin = (bool)obj2; } model.person = dataReader["person"].ToString(); obj2 = dataReader["intime"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { model.intime = (DateTime)obj2; } model.annx = dataReader["annx"].ToString(); model.explain = dataReader["explain"].ToString(); return(model); }
public int Add(SqlTransaction trans, RefundingModel model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into Sm_Refunding("); builder.Append("rid,rcode,procode,tcode,flowstate,isin,person,intime,annx,explain)"); builder.Append(" values ("); builder.Append("@rid,@rcode,@procode,@tcode,@flowstate,@isin,@person,@intime,@annx,@explain)"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@rid", SqlDbType.NVarChar, 50), new SqlParameter("@rcode", SqlDbType.NVarChar, 0x40), new SqlParameter("@procode", SqlDbType.NVarChar, 0x40), new SqlParameter("@tcode", SqlDbType.NVarChar, 0x200), new SqlParameter("@flowstate", SqlDbType.Int, 4), new SqlParameter("@isin", SqlDbType.Bit, 1), new SqlParameter("@person", SqlDbType.NVarChar, 0x40), new SqlParameter("@intime", SqlDbType.SmallDateTime), new SqlParameter("@annx", SqlDbType.NVarChar, 0x80), new SqlParameter("@explain", SqlDbType.NVarChar, 0x800) }; commandParameters[0].Value = model.rid; commandParameters[1].Value = model.rcode; commandParameters[2].Value = model.procode; commandParameters[3].Value = model.tcode; commandParameters[4].Value = model.flowstate; commandParameters[5].Value = model.isin; commandParameters[6].Value = model.person; commandParameters[7].Value = model.intime; commandParameters[8].Value = model.annx; commandParameters[9].Value = model.explain; if (trans == null) { return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); } return(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters)); }
protected void btnOk_Click(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString)) { sqlConnection.Open(); SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); try { foreach (GridViewRow gridViewRow in this.gvRefunding.Rows) { CheckBox checkBox = gridViewRow.FindControl("cbBox") as CheckBox; if (checkBox != null && checkBox.Checked) { List <BackStockModel> listArray = this.backStockBll.GetListArray(" where rcode='" + checkBox.ToolTip + "'"); RefundingModel model = this.refundingBll.GetModel(checkBox.ToolTip); foreach (BackStockModel current in listArray) { TreasuryStockModel treasuryStockModel = new TreasuryStockModel(); treasuryStockModel.corp = current.corp; treasuryStockModel.incode = current.rcode; treasuryStockModel.intime = model.intime; treasuryStockModel.intype = 0; treasuryStockModel.isfirst = false; treasuryStockModel.scode = current.scode; treasuryStockModel.snumber = current.number; treasuryStockModel.sprice = current.sprice; treasuryStockModel.tcode = model.tcode; treasuryStockModel.tsid = Guid.NewGuid().ToString(); treasuryStockModel.Type = "B"; this.treasuryStockBll.Add(sqlTransaction, treasuryStockModel); } RefundingModel model2 = this.refundingBll.GetModel(checkBox.ToolTip); model2.isin = true; model2.IsInTime = DateTime.Now; this.refundingBll.Update(sqlTransaction, model2); } } sqlTransaction.Commit(); } catch (Exception) { sqlTransaction.Rollback(); base.RegisterScript("alert('系统提示:\\n\\n退库出现异常,退库失败!');"); } } base.RegisterScript("location='QoRefundingList.aspx?prjGuid=" + base.Request["prjGuid"].ToString() + "'"); }
public RefundingModel GetModelByIc(string ic) { StringBuilder builder = new StringBuilder(); builder.Append("select rid,rcode,procode,tcode,flowstate,isin,person,intime,annx,explain from Sm_Refunding "); builder.Append(" where rid=@rid "); RefundingModel model = null; using (IDataReader reader = SqlHelper.ExecuteReader(CommandType.Text, builder.ToString(), new SqlParameter[] { new SqlParameter("@rid", ic) })) { if (reader.Read()) { model = this.ReaderBind(reader); } } return(model); }
public void InitPage() { RefundingModel refundingModel = null; if (base.Request.QueryString["id"] != null && base.Request.QueryString["ic"] == null) { refundingModel = this.refundingBll.GetModel(base.Request.QueryString["id"]); } else { if (base.Request.QueryString["ic"] != null) { refundingModel = this.refundingBll.GetModelByIc(base.Request.QueryString["ic"]); } } this.lblExplain.Text = refundingModel.explain; this.lblInTime.Text = Common2.GetTime(refundingModel.intime.ToString()); this.lblPeople.Text = refundingModel.person; this.lblPPCode.Text = refundingModel.rcode; PrjInfoModel modelByPrjGuid = this.pTPrjInfoBll.GetModelByPrjGuid(refundingModel.procode); if (modelByPrjGuid != null) { this.lblProjectName.Text = modelByPrjGuid.PrjName; } else { DataTable tableByPrjGuid = this.pTPrjInfoBll.GetTableByPrjGuid(refundingModel.procode); if (tableByPrjGuid.Rows.Count > 0) { this.lblProjectName.Text = tableByPrjGuid.Rows[0]["prjName"].ToString().Trim(); } } this.lblBllProducer.Text = refundingModel.person; this.lblPrintDate.Text = DateTime.Now.ToShortDateString(); this.hdnProjectCode.Value = refundingModel.procode; this.hdflowstate.Value = refundingModel.flowstate.ToString(); this.hdGuid.Value = refundingModel.rid; this.lblTreasuryName.Text = this.treasury.GetModel(refundingModel.tcode).tname; this.ViewState["DataTable"] = this.backStockBll.GetTableByRcode(refundingModel.rcode); this.BindGv(); this.FileLink1.MID = 1805; this.FileLink1.FID = this.hdGuid.Value; this.FileLink1.Type = 1; }
public void InitPage() { if (base.Request.QueryString["t"] != null) { this.btnDel.Enabled = false; this.btnSave.Enabled = false; this.btnSelectByd.Disabled = true; } if (base.Request.QueryString["id"] != null) { this.hdwzId.Value = "1"; this.lblTitle.Text = "编辑退库单"; RefundingModel model = this.refundingBll.GetModel(base.Request.QueryString["id"]); this.txtExplain.Text = model.explain; this.txtInTime.Text = model.intime.ToString(); this.txtPeople.Value = model.person; this.txtPPCode.Text = model.rcode; this.txtProjectName.Value = this.pTPrjInfoBll.GetModelByPrjGuid(model.procode).PrjName; this.hdnProjectCode.Value = model.procode; this.hdflowstate.Value = model.flowstate.ToString(); this.hdGuid.Value = model.rid; this.hfldTrea.Value = model.tcode; this.txtTrea.Text = this.treasury.GetModel(model.tcode).tname; this.ViewState["DataTable"] = this.backStockBll.GetTableByRcode(model.rcode); this.BindGv(); } else { this.lblTitle.Text = "新增退库单"; this.hdnProjectCode.Value = this.prjId; this.txtProjectName.Value = (this.txtProjectName.Value = this.pTPrjInfoBll.GetModelByPrjGuid(this.prjId).PrjName); this.txtPPCode.Text = DateTime.Now.ToString("yyyyMMddHHmmss"); this.txtInTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); this.hdGuid.Value = Guid.NewGuid().ToString(); this.txtPeople.Value = PageHelper.QueryUser(this, base.UserCode); this.ViewState["DataTable"] = this.backStockBll.GetTableByRcode("'',"); this.BindGv(); } this.FileLink1.MID = 1805; this.FileLink1.FID = this.hdGuid.Value; this.FileLink1.Type = 1; }
private void save(string type) { this.UpdateDataSource(); using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString)) { sqlConnection.Open(); SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); try { RefundingModel refundingModel = new RefundingModel(); refundingModel.annx = ""; refundingModel.explain = this.txtExplain.Text; refundingModel.flowstate = Convert.ToInt32(this.hdflowstate.Value); refundingModel.intime = Convert.ToDateTime(this.txtInTime.Text); refundingModel.person = this.txtPeople.Value; refundingModel.rcode = this.txtPPCode.Text; refundingModel.rid = this.hdGuid.Value; refundingModel.procode = this.hdnProjectCode.Value; refundingModel.isin = false; refundingModel.tcode = this.hfldTrea.Value; int num; if (base.Request.QueryString["id"] != null) { num = this.refundingBll.Update(sqlTransaction, refundingModel); } else { num = this.refundingBll.Add(sqlTransaction, refundingModel); } if (num != 0) { this.backStockBll.DeleteByWhere(sqlTransaction, " where rcode='" + refundingModel.rcode + "'"); DataTable dataTable = (DataTable)this.ViewState["DataTable"]; if (dataTable != null) { foreach (DataRow dataRow in dataTable.Rows) { BackStockModel backStockModel = new BackStockModel(); backStockModel.corp = dataRow["CorpId"].ToString(); backStockModel.intype = ""; backStockModel.linkcode = dataRow["orcode"].ToString(); backStockModel.number = Convert.ToDecimal(dataRow["tnumber"]); backStockModel.rcode = this.txtPPCode.Text; backStockModel.rsid = Guid.NewGuid().ToString(); backStockModel.scode = dataRow["scode"].ToString(); backStockModel.sprice = Convert.ToDecimal(dataRow["sprice"]); backStockModel.taskId = dataRow["TaskId"].ToString(); this.backStockBll.Add(sqlTransaction, backStockModel); } } } sqlTransaction.Commit(); StringBuilder stringBuilder = new StringBuilder(); if (type == "pc") { stringBuilder.Append("top.ui.show('" + this.SetMsg() + "成功!');").Append(Environment.NewLine); stringBuilder.Append("winclose('AddRefunding','RefundingList.aspx?prjGuid=" + this.hdnProjectCode.Value + "',true)"); } else { stringBuilder.Append("alert('添加成功');"); stringBuilder.Append("parent.location.reload();"); } base.RegisterScript(stringBuilder.ToString()); } catch (Exception) { sqlTransaction.Rollback(); if (type == "pc") { base.RegisterScript("top.ui.show('" + this.SetMsg() + "失败!');"); } else { base.RegisterScript("alert('系统提示:\\n\\n添加失败!');"); } } } }
public int Update(SqlTransaction trans, RefundingModel model) { return(this.refunding.Update(trans, model)); }
public int Add(SqlTransaction trans, RefundingModel model) { return(this.refunding.Add(trans, model)); }