public SmWastageModel ReaderBind(IDataReader dataReader) { SmWastageModel model = new SmWastageModel { Id = dataReader["WastageId"].ToString(), Code = dataReader["WastageCode"].ToString(), Treasurycode = dataReader["Treasurycode"].ToString() }; object obj2 = dataReader["Flowstate"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { model.Flowstate = (int)obj2; } obj2 = dataReader["Isout"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { model.Isout = (bool)obj2; } model.InputPerson = dataReader["InputPerson"].ToString(); obj2 = dataReader["InputDate"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { model.InputDate = (DateTime)obj2; } model.Explain = dataReader["Explain"].ToString(); obj2 = dataReader["IsOutTime"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { model.IsOutTime = new DateTime?((DateTime)obj2); } return(model); }
public int Add(SqlTransaction trans, SmWastageModel model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into SM_Wastage("); builder.Append("WastageId,WastageCode,Treasurycode,Flowstate,Isout,InputPerson,InputDate,Explain,IsOutTime)"); builder.Append(" values ("); builder.Append("@WastageId,@WastageCode,@Treasurycode,@Flowstate,@Isout,@InputPerson,@InputDate,@Explain,@IsOutTime)"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@WastageId", SqlDbType.NVarChar, 50), new SqlParameter("@WastageCode", SqlDbType.NVarChar, 0x40), new SqlParameter("@Treasurycode", SqlDbType.NVarChar, 0x200), new SqlParameter("@Flowstate", SqlDbType.Int, 4), new SqlParameter("@Isout", SqlDbType.Bit, 1), new SqlParameter("@InputPerson", SqlDbType.NVarChar, 0x40), new SqlParameter("@InputDate", SqlDbType.DateTime), new SqlParameter("@Explain", SqlDbType.NVarChar, 0x800), new SqlParameter("@IsOutTime", SqlDbType.DateTime) }; commandParameters[0].Value = model.Id; commandParameters[1].Value = model.Code; commandParameters[2].Value = model.Treasurycode; commandParameters[3].Value = model.Flowstate; commandParameters[4].Value = model.Isout; commandParameters[5].Value = model.InputPerson; commandParameters[6].Value = model.InputDate; commandParameters[7].Value = model.Explain; if (!model.IsOutTime.HasValue) { commandParameters[8].Value = DBNull.Value; } else { commandParameters[8].Value = model.IsOutTime; } if (trans == null) { return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); } return(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters)); }
protected void btnSaveWX_Click(object sender, System.EventArgs e) { this.UpdateDataSource(); using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString)) { sqlConnection.Open(); SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); try { SmWastageModel smWastageModel = new SmWastageModel(); smWastageModel.Explain = this.txtExplain.Text; smWastageModel.Flowstate = System.Convert.ToInt32(this.hdflowstate.Value); smWastageModel.InputDate = System.Convert.ToDateTime(this.txtInTime.Text); smWastageModel.Isout = false; smWastageModel.Code = this.txtWastageCode.Text; smWastageModel.Id = this.hdGuid.Value; smWastageModel.InputPerson = this.txtPeople.Value; smWastageModel.Treasurycode = this.hfldTrea.Value; int num; if (this.action == "update") { num = this.smWastageBll.Update(sqlTransaction, smWastageModel); } else { num = this.smWastageBll.Add(sqlTransaction, smWastageModel); } if (num != 0) { this.smWastageStockBll.DeleteByWhere(sqlTransaction, " where wastageCode='" + smWastageModel.Code + "' "); DataTable dataTable = (DataTable)this.ViewState["DataTable"]; if (dataTable != null) { foreach (DataRow dataRow in dataTable.Rows) { SmWastageStockModel smWastageStockModel = new SmWastageStockModel(); smWastageStockModel.Corp = dataRow["CorpId"].ToString(); smWastageStockModel.Number = System.Convert.ToDecimal(dataRow["number"]); smWastageStockModel.WastageCode = this.txtWastageCode.Text; smWastageStockModel.Id = System.Guid.NewGuid().ToString(); smWastageStockModel.ResourceCode = dataRow["ResourceCode"].ToString(); smWastageStockModel.Sprice = System.Convert.ToDecimal(dataRow["sprice"]); this.smWastageStockBll.Add(sqlTransaction, smWastageStockModel); } } } sqlTransaction.Commit(); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("alert('" + this.SetMsg() + "成功!');").Append(System.Environment.NewLine); //stringBuilder.Append("winclose('AddReserve','SmWastageList.aspx',true)"); stringBuilder.Append("parent.location.reload();"); base.RegisterScript(stringBuilder.ToString()); } catch (System.Exception) { sqlTransaction.Rollback(); base.RegisterScript("alert('系统提示:\\n\\n对不起" + this.SetMsg() + "失败!');"); } } }
public SmWastageModel GetModelByIc(string ic) { StringBuilder builder = new StringBuilder(); builder.Append("select WastageId,WastageCode,Treasurycode,Flowstate,Isout,InputPerson,InputDate,Explain,IsOutTime from SM_Wastage "); builder.Append(" where WastageId=@WastageId "); SmWastageModel model = null; using (IDataReader reader = SqlHelper.ExecuteReader(CommandType.Text, builder.ToString(), new SqlParameter[] { new SqlParameter("@WastageId", ic) })) { if (reader.Read()) { model = this.ReaderBind(reader); } } return(model); }
public void InitPage() { SmWastageModel smWastageModel = null; if (base.Request.QueryString["id"] != null && base.Request.QueryString["ic"] == null) { smWastageModel = this.smWastageBll.GetModel(base.Request.QueryString["id"]); } else { if (base.Request.QueryString["ic"] != null) { smWastageModel = this.smWastageBll.GetModelByIc(base.Request.QueryString["ic"]); } } if (smWastageModel != null) { this.lblExplain.Text = smWastageModel.Explain; this.lblInTime.Text = Common2.GetTime(smWastageModel.InputDate.ToString()); this.lblPeople.Text = smWastageModel.InputPerson; this.lblPPCode.Text = smWastageModel.Code; this.lblBllProducer.Text = smWastageModel.InputPerson; this.lblPrintDate.Text = System.DateTime.Now.ToShortDateString(); this.hdGuid.Value = smWastageModel.Id; this.hdflowstate.Value = smWastageModel.Flowstate.ToString(); this.lblTerasuryName.Text = this.treasury.GetModel(smWastageModel.Treasurycode).tname; System.Collections.Generic.List <SmWastageStockModel> listArray = this.smWastageStockBll.GetListArray(" where WastageCode='" + smWastageModel.Code + "'"); string text = ""; foreach (SmWastageStockModel current in listArray) { text = text + "'" + current.ResourceCode + "',"; } if (text != "") { text = text.Substring(0, text.Length - 1); } this.ViewState["DataTable"] = this.smWastageStockBll.GetTableByWastageCode(smWastageModel.Code, smWastageModel.Treasurycode); this.BindGv(); this.FileUpload1.InnerHtml = this.FilesBind(smWastageModel.Id); } }
protected void Initialize() { if (this.action == "add") { this.lblTitle.Text = "新报损增出库单"; this.txtWastageCode.Text = System.DateTime.Now.ToString("yyyyMMddHHmmss"); this.txtInTime.Text = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); this.hdGuid.Value = System.Guid.NewGuid().ToString(); this.txtPeople.Value = PageHelper.QueryUser(this, base.UserCode); this.ViewState["DataTable"] = this.smWastageStockBll.GetTableByWastageCode("''", ""); this.BindGv(); return; } this.lblTitle.Text = "编辑报损出库单"; SmWastageModel model = this.smWastageBll.GetModel(this.wastageId); this.hdTsid.Value = "1"; this.txtExplain.Text = model.Explain; this.txtInTime.Text = model.InputDate.ToString(); this.txtPeople.Value = model.InputPerson; this.txtWastageCode.Text = model.Code; this.hdGuid.Value = model.Id; this.hdflowstate.Value = model.Flowstate.ToString(); this.hfldTrea.Value = model.Treasurycode; this.txtTrea.Text = this.treasury.GetModel(model.Treasurycode).tname; System.Collections.Generic.List <SmWastageStockModel> listArray = this.smWastageStockBll.GetListArray(" WHERE WastageCode='" + model.Code + "' "); string text = ""; foreach (SmWastageStockModel current in listArray) { text = text + "'" + current.ResourceCode + "',"; } if (text != "") { text = text.Substring(0, text.Length - 1); } this.ViewState["DataTable"] = this.smWastageStockBll.GetTableByWastageCode(model.Code, model.Treasurycode); this.BindGv(); }
public int Update(SqlTransaction trans, SmWastageModel model) { StringBuilder builder = new StringBuilder(); builder.Append("UPDATE SM_Wastage SET "); builder.Append("WastageId=@WastageId,"); builder.Append("Treasurycode=@Treasurycode,"); builder.Append("FlowState=@FlowState,"); builder.Append("Isout=@Isout,"); builder.Append("InputPerson=@InputPerson,"); builder.Append("InputDate=@InputDate,"); builder.Append("Explain=@Explain,"); builder.Append("IsOutTime=@IsOutTime"); builder.Append(" WHERE WastageCode=@WastageCode "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@WastageId", SqlDbType.NVarChar, 50), new SqlParameter("@WastageCode", SqlDbType.NVarChar, 0x40), new SqlParameter("@Treasurycode", SqlDbType.NVarChar, 0x200), new SqlParameter("@FlowState", SqlDbType.Int, 4), new SqlParameter("@Isout", SqlDbType.Bit, 1), new SqlParameter("@InputPerson", SqlDbType.NVarChar, 0x40), new SqlParameter("@InputDate", SqlDbType.DateTime), new SqlParameter("@Explain", SqlDbType.NVarChar, 0x800), new SqlParameter("@IsOutTime", SqlDbType.DateTime) }; commandParameters[0].Value = model.Id; commandParameters[1].Value = model.Code; commandParameters[2].Value = model.Treasurycode; commandParameters[3].Value = model.Flowstate; commandParameters[4].Value = model.Isout; commandParameters[5].Value = model.InputPerson; commandParameters[6].Value = model.InputDate; commandParameters[7].Value = model.Explain; if (!model.IsOutTime.HasValue) { commandParameters[8].Value = DBNull.Value; } else { commandParameters[8].Value = model.IsOutTime; } 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, SmWastageModel model) { return(this.smWastage.Update(trans, model)); }
public int Add(SqlTransaction trans, SmWastageModel model) { return(this.smWastage.Add(trans, model)); }
protected void btnOk_Click(object sender, System.EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString)) { sqlConnection.Open(); SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); try { foreach (GridViewRow gridViewRow in this.gvWastage.Rows) { CheckBox checkBox = gridViewRow.FindControl("cbBox") as CheckBox; if (checkBox != null && checkBox.Checked) { System.Collections.Generic.List <SmWastageStockModel> listArray = this.smWastageStockBll.GetListArray(" where WastageCode='" + checkBox.ToolTip + "' "); SmWastageModel modelByCode = this.smWastageBll.GetModelByCode(checkBox.ToolTip); foreach (SmWastageStockModel current in listArray) { System.Collections.Generic.List <TreasuryStockModel> listArray2 = this.treasuryStockBll.GetListArray(string.Concat(new object[] { " where scode='", current.ResourceCode, "' and sprice=", current.Sprice, " and ISNULL(corp,'')='", current.Corp, "' and tcode='", modelByCode.Treasurycode, "' order by intime asc" })); decimal num = 0m; foreach (TreasuryStockModel current2 in listArray2) { num += current2.snumber; } if (current.Number > num) { base.RegisterScript("top.ui.alert('库存量不足!')"); base.RegisterScript("location='ConfirmWastage.aspx'"); return; } foreach (TreasuryStockModel current3 in listArray2) { if (current3.snumber >= current.Number) { current3.snumber -= current.Number; if (current3.snumber == 0m) { this.treasuryStockBll.Delete(current3.tsid); } else { this.treasuryStockBll.Update(current3); } Common2.AlarmMethod(current3.tcode, current3.scode); break; } if (current3.snumber < current.Number) { current.Number -= current3.snumber; this.treasuryStockBll.Delete(current3.tsid); } } } SmWastageModel modelByCode2 = this.smWastageBll.GetModelByCode(checkBox.ToolTip); modelByCode2.Isout = true; modelByCode2.IsOutTime = new System.DateTime?(System.DateTime.Now); int num2 = this.smWastageBll.Update(null, modelByCode2); if (num2 > 0) { base.RegisterScript("top.ui.show('操作成功');"); } else { base.RegisterScript("top.ui.show('操作失败');"); } } } } catch (System.Exception) { sqlTransaction.Rollback(); base.RegisterScript("top.ui.alert('出库出现异常,出库失败!');"); } } base.RegisterScript("location='ConfirmWastage.aspx'"); }