Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string            err         = gridview_err();
            string            str         = "";
            int               wuzi_id     = 0;
            AccountsPrincipal user        = new AccountsPrincipal(Context.User.Identity.Name);
            User              currentUser = new LTP.Accounts.Bus.User(user);
            string            fengongsi   = currentUser.TrueName;
            int               num         = 0;
            int               peixunbanid = Convert.ToInt16(qishu.SelectedValue);
            int               style       = Convert.ToInt16(RadioButtonList1.SelectedValue);
            DateTime          dtime       = DateTime.Now;
            string            beizhu      = "";

            if (err == "")
            {
                int i = 0;
                foreach (GridViewRow row in GridView1.Rows)
                {
                    num = Convert.ToInt16(((TextBox)row.FindControl("num")).Text);
                    if (num != 0)
                    {
                        beizhu  = ((TextBox)row.FindControl("beizhu")).Text;
                        wuzi_id = Convert.ToInt16(((Label)row.FindControl("id")).Text);
                        Maticsoft.Model.wuzi_diaoyong model = new Maticsoft.Model.wuzi_diaoyong();
                        model.wuzi_id     = wuzi_id;
                        model.fengongsi   = fengongsi;
                        model.num         = num;
                        model.peixunbanid = peixunbanid;
                        model.style       = style;
                        model.time        = dtime;
                        model.beizhu      = beizhu;
                        Maticsoft.BLL.wuzi_diaoyong bll = new Maticsoft.BLL.wuzi_diaoyong();
                        if (bll.Add(model) > 0)
                        {
                            i++;
                        }
                        ;
                    }
                }
                if (i > 0)
                {
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this, "共调用了" + i + "项物品", "list.aspx");
                }
            }
            else
            {
                MessageBox.Show(this, err);
                return;
            }
        }
Esempio n. 2
0
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.wuzi_diaoyong   bll   = new Maticsoft.BLL.wuzi_diaoyong();
     Maticsoft.Model.wuzi_diaoyong model = bll.GetModel(id);
     this.lblid.Text          = model.id.ToString();
     this.txtwuzi_id.Text     = model.wuzi_id.ToString();
     this.txtfengongsi.Text   = model.fengongsi;
     this.txtnum.Text         = model.num.ToString();
     this.txtpeixunbanid.Text = model.peixunbanid.ToString();
     this.txtstyle.Text       = model.style.ToString();
     this.txttime.Text        = model.time.ToString();
     this.txtbeizhu.Text      = model.beizhu;
     this.txtbeizhu2.Text     = model.beizhu2;
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.wuzi_diaoyong model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wuzi_diaoyong set ");
            strSql.Append("wuzi_id=@wuzi_id,");
            strSql.Append("fengongsi=@fengongsi,");
            strSql.Append("num=@num,");
            strSql.Append("peixunbanid=@peixunbanid,");
            strSql.Append("style=@style,");
            strSql.Append("time=@time,");
            strSql.Append("beizhu=@beizhu,");
            strSql.Append("beizhu2=@beizhu2");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wuzi_id",     SqlDbType.Int,        4),
                new SqlParameter("@fengongsi",   SqlDbType.NChar,     50),
                new SqlParameter("@num",         SqlDbType.Int,        4),
                new SqlParameter("@peixunbanid", SqlDbType.Int,        4),
                new SqlParameter("@style",       SqlDbType.Int,        4),
                new SqlParameter("@time",        SqlDbType.DateTime),
                new SqlParameter("@beizhu",      SqlDbType.Text),
                new SqlParameter("@beizhu2",     SqlDbType.Text),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wuzi_id;
            parameters[1].Value = model.fengongsi;
            parameters[2].Value = model.num;
            parameters[3].Value = model.peixunbanid;
            parameters[4].Value = model.style;
            parameters[5].Value = model.time;
            parameters[6].Value = model.beizhu;
            parameters[7].Value = model.beizhu2;
            parameters[8].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.wuzi_diaoyong DataRowToModel(DataRow row)
 {
     Maticsoft.Model.wuzi_diaoyong model = new Maticsoft.Model.wuzi_diaoyong();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["wuzi_id"] != null && row["wuzi_id"].ToString() != "")
         {
             model.wuzi_id = int.Parse(row["wuzi_id"].ToString());
         }
         if (row["fengongsi"] != null)
         {
             model.fengongsi = row["fengongsi"].ToString();
         }
         if (row["num"] != null && row["num"].ToString() != "")
         {
             model.num = int.Parse(row["num"].ToString());
         }
         if (row["peixunbanid"] != null && row["peixunbanid"].ToString() != "")
         {
             model.peixunbanid = int.Parse(row["peixunbanid"].ToString());
         }
         if (row["style"] != null && row["style"].ToString() != "")
         {
             model.style = int.Parse(row["style"].ToString());
         }
         if (row["time"] != null && row["time"].ToString() != "")
         {
             model.time = DateTime.Parse(row["time"].ToString());
         }
         if (row["beizhu"] != null)
         {
             model.beizhu = row["beizhu"].ToString();
         }
         if (row["beizhu2"] != null)
         {
             model.beizhu2 = row["beizhu2"].ToString();
         }
     }
     return(model);
 }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.wuzi_diaoyong model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wuzi_diaoyong(");
            strSql.Append("wuzi_id,fengongsi,num,peixunbanid,style,time,beizhu,beizhu2)");
            strSql.Append(" values (");
            strSql.Append("@wuzi_id,@fengongsi,@num,@peixunbanid,@style,@time,@beizhu,@beizhu2)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wuzi_id",     SqlDbType.Int,        4),
                new SqlParameter("@fengongsi",   SqlDbType.NChar,     50),
                new SqlParameter("@num",         SqlDbType.Int,        4),
                new SqlParameter("@peixunbanid", SqlDbType.Int,        4),
                new SqlParameter("@style",       SqlDbType.Int,        4),
                new SqlParameter("@time",        SqlDbType.DateTime),
                new SqlParameter("@beizhu",      SqlDbType.Text),
                new SqlParameter("@beizhu2",     SqlDbType.Text)
            };
            parameters[0].Value = model.wuzi_id;
            parameters[1].Value = model.fengongsi;
            parameters[2].Value = model.num;
            parameters[3].Value = model.peixunbanid;
            parameters[4].Value = model.style;
            parameters[5].Value = model.time;
            parameters[6].Value = model.beizhu;
            parameters[7].Value = model.beizhu2;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.wuzi_diaoyong GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wuzi_id,fengongsi,num,peixunbanid,style,time,beizhu,beizhu2 from wuzi_diaoyong ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Maticsoft.Model.wuzi_diaoyong model = new Maticsoft.Model.wuzi_diaoyong();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtwuzi_id.Text))
            {
                strErr += "wuzi_id格式错误!\\n";
            }
            if (this.txtfengongsi.Text.Trim().Length == 0)
            {
                strErr += "fengongsi不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtnum.Text))
            {
                strErr += "num格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtpeixunbanid.Text))
            {
                strErr += "peixunbanid格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtstyle.Text))
            {
                strErr += "style格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txttime.Text))
            {
                strErr += "time格式错误!\\n";
            }
            if (this.txtbeizhu.Text.Trim().Length == 0)
            {
                strErr += "beizhu不能为空!\\n";
            }
            if (this.txtbeizhu2.Text.Trim().Length == 0)
            {
                strErr += "beizhu2不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      id          = int.Parse(this.lblid.Text);
            int      wuzi_id     = int.Parse(this.txtwuzi_id.Text);
            string   fengongsi   = this.txtfengongsi.Text;
            int      num         = int.Parse(this.txtnum.Text);
            int      peixunbanid = int.Parse(this.txtpeixunbanid.Text);
            int      style       = int.Parse(this.txtstyle.Text);
            DateTime time        = DateTime.Parse(this.txttime.Text);
            string   beizhu      = this.txtbeizhu.Text;
            string   beizhu2     = this.txtbeizhu2.Text;


            Maticsoft.Model.wuzi_diaoyong model = new Maticsoft.Model.wuzi_diaoyong();
            model.id          = id;
            model.wuzi_id     = wuzi_id;
            model.fengongsi   = fengongsi;
            model.num         = num;
            model.peixunbanid = peixunbanid;
            model.style       = style;
            model.time        = time;
            model.beizhu      = beizhu;
            model.beizhu2     = beizhu2;

            Maticsoft.BLL.wuzi_diaoyong bll = new Maticsoft.BLL.wuzi_diaoyong();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }