public int Add(SqlTransaction trans, SmPurchaseplanModel model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into Sm_Purchaseplan("); builder.Append("ppid,ppcode,flowstate,person,intime,acceptstate,annx,explain,Project)"); builder.Append(" values ("); builder.Append("@ppid,@ppcode,@flowstate,@person,@intime,@acceptstate,@annx,@explain,@Project)"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@ppid", SqlDbType.NVarChar, 50), new SqlParameter("@ppcode", SqlDbType.NVarChar, 0x40), new SqlParameter("@flowstate", SqlDbType.Int, 4), new SqlParameter("@person", SqlDbType.NVarChar, 0x40), new SqlParameter("@intime", SqlDbType.SmallDateTime), new SqlParameter("@acceptstate", SqlDbType.Int, 4), new SqlParameter("@annx", SqlDbType.NVarChar, 0x80), new SqlParameter("@explain", SqlDbType.NVarChar, 0x800), new SqlParameter("@Project", SqlDbType.NVarChar, 500) }; commandParameters[0].Value = model.ppid; commandParameters[1].Value = model.ppcode; commandParameters[2].Value = model.flowstate; commandParameters[3].Value = model.person; commandParameters[4].Value = model.intime; commandParameters[5].Value = model.acceptstate; commandParameters[6].Value = model.annx; commandParameters[7].Value = model.explain; commandParameters[8].Value = model.Project; if (trans == null) { return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); } return(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters)); }
public int Update(SqlTransaction trans, SmPurchaseplanModel model) { return(this.smPurchaseplan.Update(trans, model)); }
public int Update(SmPurchaseplanModel model) { return(this.smPurchaseplan.Update(null, model)); }
public int Add(SqlTransaction trans, SmPurchaseplanModel model) { return(this.smPurchaseplan.Add(trans, model)); }
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.wpcode = base.Request.QueryString["id"].ToString(); this.lblTitle.Text = "编辑采购计划单"; SmPurchaseplanModel model = this.smPurchaseplanBll.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.ppcode; this.txtProjectName.Value = this.pTPrjInfoBll.GetModelByPrjGuid(model.Project).PrjName; this.hdnProjectCode.Value = model.Project; this.hdflowstate.Value = model.flowstate.ToString(); this.hdGuid.Value = model.ppid; this.hdnCodeList.Value = "1"; string[] arrPpcode = new string[] { model.ppcode }; DataTable resourceByPpcodes = this.smPurchaseplanStockBll.GetResourceByPpcodes(arrPpcode); //预算数量 DataColumn dataColumn6 = new DataColumn("BugetNum", typeof(string)); dataColumn6.DefaultValue = 0.00; resourceByPpcodes.Columns.Add(dataColumn6); //预算单价 DataColumn dataColumn7 = new DataColumn("BugetPrice", typeof(string)); dataColumn7.DefaultValue = 0.00; resourceByPpcodes.Columns.Add(dataColumn7); //预算合计 DataColumn dataColumn8 = new DataColumn("BugetSum", typeof(string)); dataColumn8.DefaultValue = 0.00; resourceByPpcodes.Columns.Add(dataColumn8); this.ViewState["DataTable"] = resourceByPpcodes; this.BindGv(); } else { this.lblTitle.Text = "新增采购计划单"; string text = base.Request["prjId"].ToString(); this.hdnProjectCode.Value = text; this.txtProjectName.Value = this.pTPrjInfoBll.GetModelByPrjGuid(text).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); string[] arrPpcode2 = new string[] { "''" }; DataTable resourceByPpcodes = this.smPurchaseplanStockBll.GetResourceByPpcodes(arrPpcode2); //预算数量 DataColumn dataColumn6 = new DataColumn("BugetNum", typeof(string)); dataColumn6.DefaultValue = 0.00; resourceByPpcodes.Columns.Add(dataColumn6); //预算单价 DataColumn dataColumn7 = new DataColumn("BugetPrice", typeof(string)); dataColumn7.DefaultValue = 0.00; resourceByPpcodes.Columns.Add(dataColumn7); //预算合计 DataColumn dataColumn8 = new DataColumn("BugetSum", typeof(string)); dataColumn8.DefaultValue = 0.00; resourceByPpcodes.Columns.Add(dataColumn8); this.ViewState["DataTable"] = resourceByPpcodes; this.BindGv(); } this.FileLink1.MID = 1756; this.FileLink1.FID = this.hdGuid.Value; this.FileLink1.Type = 1; }
private void save(string type) { using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString)) { sqlConnection.Open(); SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); try { SmPurchaseplanModel smPurchaseplanModel = new SmPurchaseplanModel(); smPurchaseplanModel.acceptstate = 0; smPurchaseplanModel.annx = ""; smPurchaseplanModel.explain = this.txtExplain.Text; smPurchaseplanModel.flowstate = Convert.ToInt32(this.hdflowstate.Value); smPurchaseplanModel.intime = Convert.ToDateTime(this.txtInTime.Text); smPurchaseplanModel.person = this.txtPeople.Value; smPurchaseplanModel.ppcode = this.txtPPCode.Text; smPurchaseplanModel.ppid = this.hdGuid.Value; smPurchaseplanModel.Project = this.hdnProjectCode.Value; int num; if (base.Request.QueryString["id"] != null) { num = this.smPurchaseplanBll.Update(sqlTransaction, smPurchaseplanModel); } else { num = this.smPurchaseplanBll.Add(sqlTransaction, smPurchaseplanModel); } if (num != 0) { this.smPurchaseplanStockBll.DeleteByWhere(sqlTransaction, " where ppcode='" + smPurchaseplanModel.ppcode + "'"); DataTable dataTable = (DataTable)this.ViewState["DataTable"]; if (dataTable != null) { foreach (DataRow dataRow in dataTable.Rows) { SmPurchaseplanStockModel smPurchaseplanStockModel = new SmPurchaseplanStockModel(); smPurchaseplanStockModel.scode = dataRow["scode"].ToString(); smPurchaseplanStockModel.number = this.GetNumByScode(dataRow["scode"].ToString()); smPurchaseplanStockModel.ppcode = this.txtPPCode.Text; smPurchaseplanStockModel.wpsid = Guid.NewGuid().ToString(); if (this.gvNeedNote.Rows.Count > 0) { foreach (GridViewRow gridViewRow in this.gvNeedNote.Rows) { Label label = (Label)gridViewRow.FindControl("lbscode"); string text = label.Text; if (text == dataRow["scode"].ToString()) { TextBox textBox = (TextBox)gridViewRow.FindControl("txtarrivalDate"); if (!string.IsNullOrEmpty(textBox.Text.Trim())) { smPurchaseplanStockModel.ArrivalDate = textBox.Text.Trim().ToString(); } else { smPurchaseplanStockModel.ArrivalDate = ""; } TextBox textBox1 = (TextBox)gridViewRow.FindControl("txtarrivalDateNeed"); if (!string.IsNullOrEmpty(textBox1.Text.Trim())) { smPurchaseplanStockModel.ArrivalDateNeed = textBox1.Text.Trim().ToString(); } else { smPurchaseplanStockModel.ArrivalDateNeed = ""; } TextBox textBox2 = (TextBox)gridViewRow.FindControl("txtRemark"); smPurchaseplanStockModel.remark = textBox2.Text.Trim(); break; } } } this.smPurchaseplanStockBll.Add(sqlTransaction, smPurchaseplanStockModel); } } } this.UpdateWantplanAState(sqlTransaction, this.hdlfWantplanCodes.Value); sqlTransaction.Commit(); StringBuilder stringBuilder = new StringBuilder(); if (type == "pc") { string arg_317_0 = string.Empty; stringBuilder.Append("top.ui.show('" + this.SetMsg() + "成功!');").Append(Environment.NewLine); stringBuilder.Append("winclose('AddSmPurchaseplan','SmPurchaseplanList.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(('" + this.SetMsg() + "失败!'));"); } } } }