Ejemplo n.º 1
0
        public SendGoodsModel GetModel(string sgId)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select sgId,scode,snCode,number,suppyCode,price from sm_sendGoods ");
            builder.Append(" where sgId=@sgId ");
            SendGoodsModel model = null;

            using (IDataReader reader = SqlHelper.ExecuteReader(CommandType.Text, builder.ToString(), new SqlParameter[] { new SqlParameter("@sgId", sgId) }))
            {
                if (reader.Read())
                {
                    model = this.ReaderBind(reader);
                }
            }
            return(model);
        }
Ejemplo n.º 2
0
        public SendGoodsModel ReaderBind(IDataReader dataReader)
        {
            SendGoodsModel model = new SendGoodsModel {
                sgId   = dataReader["sgId"].ToString(),
                scode  = dataReader["scode"].ToString(),
                snCode = dataReader["snCode"].ToString()
            };

            if (dataReader["number"].ToString() != "")
            {
                model.Number = new decimal?(decimal.Parse(dataReader["number"].ToString()));
            }
            model.suppyCode = dataReader["suppyCode"].ToString();
            if (dataReader["price"].ToString() != "")
            {
                model.Price = new decimal?(decimal.Parse(dataReader["price"].ToString()));
            }
            return(model);
        }
Ejemplo n.º 3
0
        public int Add(SqlTransaction trans, SendGoodsModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into sm_sendGoods(");
            builder.Append("sgId,scode,snCode,number,suppyCode,price)");
            builder.Append(" values (");
            builder.Append("@sgId,@scode,@snCode,@number,@suppyCode,@price)");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@sgId", SqlDbType.NVarChar, 0x40), new SqlParameter("@scode", SqlDbType.VarChar, 100), new SqlParameter("@snCode", SqlDbType.NVarChar, 0x40), new SqlParameter("@number", SqlDbType.Decimal, 9), new SqlParameter("@suppyCode", SqlDbType.VarChar, 100), new SqlParameter("@price", SqlDbType.Decimal, 9) };
            commandParameters[0].Value = model.sgId;
            commandParameters[1].Value = model.scode;
            commandParameters[2].Value = model.snCode;
            commandParameters[3].Value = model.Number;
            commandParameters[4].Value = model.suppyCode;
            commandParameters[5].Value = model.Price;
            if (trans == null)
            {
                return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters));
            }
            return(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters));
        }
Ejemplo n.º 4
0
        public int Update(SqlTransaction trans, SendGoodsModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update sm_sendGoods set ");
            builder.Append("scode=@scode,");
            builder.Append("snCode=@snCode,");
            builder.Append("number=@number,");
            builder.Append("suppyCode=@suppyCode,");
            builder.Append("price=@price");
            builder.Append(" where sgId=@sgId ");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@scode", SqlDbType.VarChar, 100), new SqlParameter("@snCode", SqlDbType.NVarChar, 0x40), new SqlParameter("@number", SqlDbType.Decimal, 9), new SqlParameter("@suppyCode", SqlDbType.VarChar, 100), new SqlParameter("@sgId", SqlDbType.NVarChar, 0x40), new SqlParameter("@price", SqlDbType.Decimal, 9) };
            commandParameters[0].Value = model.scode;
            commandParameters[1].Value = model.snCode;
            commandParameters[2].Value = model.Number;
            commandParameters[3].Value = model.suppyCode;
            commandParameters[4].Value = model.sgId;
            commandParameters[5].Value = model.Price;
            if (trans == null)
            {
                return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters));
            }
            return(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters));
        }
Ejemplo n.º 5
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString))
     {
         sqlConnection.Open();
         SqlTransaction sqlTransaction = sqlConnection.BeginTransaction();
         try
         {
             SendNodteModel sendNodteModel = new SendNodteModel();
             sendNodteModel.sendState = new int?(0);
             sendNodteModel.remark    = this.txtremark.Text;
             sendNodteModel.snId      = this.hdGuid.Value;
             sendNodteModel.snAddTime = new DateTime?(Convert.ToDateTime(this.txtsnAddTime.Text));
             sendNodteModel.snAddUser = base.UserCode;
             sendNodteModel.snCode    = this.txtsnCode.Text;
             if (this.hdnProjectCode.Value != "")
             {
                 sendNodteModel.prjCode = new Guid(this.hdnProjectCode.Value);
             }
             else
             {
                 sendNodteModel.prjCode = new Guid("00000000-0000-0000-0000-000000000000");
             }
             sendNodteModel.Limits = (
                 from c in this.hf.Value.Split(new char[]
             {
                 ','
             })
                 where c.Length == 8
                 select c).ToCsv();
             int num;
             if (base.Request.QueryString["id"] != null)
             {
                 num = this.sendnote.Update(sqlTransaction, sendNodteModel);
             }
             else
             {
                 num = this.sendnote.Add(sqlTransaction, sendNodteModel);
             }
             int num2 = 0;
             if (num != 0)
             {
                 this.sendgoods.DeleteBysnId(sqlTransaction, sendNodteModel.snId);
                 DataTable dataTable = (DataTable)this.ViewState["DataTable"];
                 if (dataTable != null)
                 {
                     int num3 = 0;
                     foreach (DataRow dataRow in dataTable.Rows)
                     {
                         TextBox        textBox        = this.gvNeedNote.Rows[num3].FindControl("txtNum") as TextBox;
                         SendGoodsModel sendGoodsModel = new SendGoodsModel();
                         if (textBox.Text != "")
                         {
                             sendGoodsModel.Number = new decimal?(Convert.ToDecimal(textBox.Text));
                         }
                         else
                         {
                             sendGoodsModel.Number = new decimal?(0m);
                         }
                         sendGoodsModel.scode  = dataRow["scode"].ToString();
                         sendGoodsModel.snCode = this.hdGuid.Value;
                         sendGoodsModel.sgId   = Guid.NewGuid().ToString();
                         TextBox textBox2 = this.gvNeedNote.Rows[num3].FindControl("txtPrice") as TextBox;
                         try
                         {
                             sendGoodsModel.Price = new decimal?(Convert.ToDecimal(textBox2.Text.ToString()));
                         }
                         catch
                         {
                             sendGoodsModel.Price = new decimal?(0m);
                         }
                         Label label = this.gvNeedNote.Rows[num3].FindControl("labCrop") as Label;
                         if (label.ToolTip == "")
                         {
                             num2 = 1;
                             break;
                         }
                         sendGoodsModel.suppyCode = label.ToolTip;
                         this.sendgoods.Add(sqlTransaction, sendGoodsModel);
                         num3++;
                     }
                     if (num2 == 1)
                     {
                         base.RegisterScript("top.ui.alert('供应商不能为空');");
                         return;
                     }
                 }
             }
             if (num2 == 0)
             {
                 this.UpdateWantplanAState(sqlTransaction, this.hdlfWantplanCodes.Value.Trim());
                 sqlTransaction.Commit();
                 string mes;
                 if (base.Request.QueryString["id"] != null)
                 {
                     mes = "现场收货通知:发货单号为" + sendNodteModel.snCode + "的发货单已修改。";
                 }
                 mes = "现场收货通知:发货单号为" + sendNodteModel.snCode + "的物资已发货。";
                 string[] array = (
                     from c in this.hf.Value.Split(new char[]
                 {
                     ','
                 })
                     where c.Length == 8
                     select c).ToArray <string>();
                 string[] array2 = array;
                 for (int i = 0; i < array2.Length; i++)
                 {
                     string jsyhdm = array2[i];
                     this.getOrganiger(sendNodteModel.snId, mes, jsyhdm);
                 }
                 StringBuilder stringBuilder = new StringBuilder();
                 stringBuilder.Append("top.ui.show('" + this.SetMsg() + "成功!');").Append(Environment.NewLine);
                 stringBuilder.Append("top.ui.tabSuccess({parentName: '_addSendNote'});");
                 base.RegisterScript(stringBuilder.ToString());
             }
             else
             {
                 if (num2 == 1)
                 {
                     new StringBuilder();
                     base.RegisterScript("top.ui.show('" + this.SetMsg() + "失败!');");
                 }
             }
         }
         catch
         {
             sqlTransaction.Rollback();
             base.RegisterScript("alert('系统提示:\\n\\n对不起" + this.SetMsg() + "失败!');");
         }
     }
 }
Ejemplo n.º 6
0
 public void Add(SqlTransaction trans, SendGoodsModel modelGoods)
 {
     this.sendgoods.Add(trans, modelGoods);
 }