/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.hui_kuan_dan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update hui_kuan_dan set ");
            strSql.Append("huikuan_neirong=@huikuan_neirong,");
            strSql.Append("xiangmu_mingcheng=@xiangmu_mingcheng,");
            strSql.Append("xiangmu_zongkuan=@xiangmu_zongkuan,");
            strSql.Append("yifu_jine=@yifu_jine,");
            strSql.Append("zhifu_shijian=@zhifu_shijian,");
            strSql.Append("benci_jine=@benci_jine,");
            strSql.Append("yuji_yukuan=@yuji_yukuan,");
            strSql.Append("supplier_id=@supplier_id,");
            strSql.Append("leibie=@leibie,");
            strSql.Append("beizhu=@beizhu");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@huikuan_neirong",   SqlDbType.Text),
                new SqlParameter("@xiangmu_mingcheng", SqlDbType.Text),
                new SqlParameter("@xiangmu_zongkuan",  SqlDbType.Money, 8),
                new SqlParameter("@yifu_jine",         SqlDbType.Money, 8),
                new SqlParameter("@zhifu_shijian",     SqlDbType.Date,  3),
                new SqlParameter("@benci_jine",        SqlDbType.Money, 8),
                new SqlParameter("@yuji_yukuan",       SqlDbType.Date,  3),
                new SqlParameter("@supplier_id",       SqlDbType.Int,   4),
                new SqlParameter("@leibie",            SqlDbType.Int,   4),
                new SqlParameter("@beizhu",            SqlDbType.Text),
                new SqlParameter("@id",                SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.huikuan_neirong;
            parameters[1].Value  = model.xiangmu_mingcheng;
            parameters[2].Value  = model.xiangmu_zongkuan;
            parameters[3].Value  = model.yifu_jine;
            parameters[4].Value  = model.zhifu_shijian;
            parameters[5].Value  = model.benci_jine;
            parameters[6].Value  = model.yuji_yukuan;
            parameters[7].Value  = model.supplier_id;
            parameters[8].Value  = model.leibie;
            parameters[9].Value  = model.beizhu;
            parameters[10].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.hui_kuan_dan DataRowToModel(DataRow row)
 {
     Maticsoft.Model.hui_kuan_dan model = new Maticsoft.Model.hui_kuan_dan();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["huikuan_neirong"] != null)
         {
             model.huikuan_neirong = row["huikuan_neirong"].ToString();
         }
         if (row["xiangmu_mingcheng"] != null)
         {
             model.xiangmu_mingcheng = row["xiangmu_mingcheng"].ToString();
         }
         if (row["xiangmu_zongkuan"] != null && row["xiangmu_zongkuan"].ToString() != "")
         {
             model.xiangmu_zongkuan = decimal.Parse(row["xiangmu_zongkuan"].ToString());
         }
         if (row["yifu_jine"] != null && row["yifu_jine"].ToString() != "")
         {
             model.yifu_jine = decimal.Parse(row["yifu_jine"].ToString());
         }
         if (row["zhifu_shijian"] != null && row["zhifu_shijian"].ToString() != "")
         {
             model.zhifu_shijian = DateTime.Parse(row["zhifu_shijian"].ToString());
         }
         if (row["benci_jine"] != null && row["benci_jine"].ToString() != "")
         {
             model.benci_jine = decimal.Parse(row["benci_jine"].ToString());
         }
         if (row["yuji_yukuan"] != null && row["yuji_yukuan"].ToString() != "")
         {
             model.yuji_yukuan = DateTime.Parse(row["yuji_yukuan"].ToString());
         }
         if (row["supplier_id"] != null && row["supplier_id"].ToString() != "")
         {
             model.supplier_id = int.Parse(row["supplier_id"].ToString());
         }
         if (row["leibie"] != null && row["leibie"].ToString() != "")
         {
             model.leibie = int.Parse(row["leibie"].ToString());
         }
         if (row["beizhu"] != null)
         {
             model.beizhu = row["beizhu"].ToString();
         }
     }
     return(model);
 }
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.hui_kuan_dan   bll   = new Maticsoft.BLL.hui_kuan_dan();
     Maticsoft.Model.hui_kuan_dan model = bll.GetModel(id);
     this.lblid.Text = model.id.ToString();
     this.lblhuikuan_neirong.Text   = model.huikuan_neirong;
     this.lblxiangmu_mingcheng.Text = model.xiangmu_mingcheng;
     this.lblxiangmu_zongkuan.Text  = model.xiangmu_zongkuan.ToString();
     this.lblyifu_jine.Text         = model.yifu_jine.ToString();
     this.lblzhifu_shijian.Text     = model.zhifu_shijian.ToString();
     this.lblbenci_jine.Text        = model.benci_jine.ToString();
     this.lblyuji_yukuan.Text       = model.yuji_yukuan.ToString();
     this.lblsupplier_id.Text       = model.supplier_id.ToString();
     this.lblleibie.Text            = model.leibie.ToString();
     this.lblbeizhu.Text            = model.beizhu;
 }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.hui_kuan_dan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into hui_kuan_dan(");
            strSql.Append("huikuan_neirong,xiangmu_mingcheng,xiangmu_zongkuan,yifu_jine,zhifu_shijian,benci_jine,yuji_yukuan,supplier_id,leibie,beizhu)");
            strSql.Append(" values (");
            strSql.Append("@huikuan_neirong,@xiangmu_mingcheng,@xiangmu_zongkuan,@yifu_jine,@zhifu_shijian,@benci_jine,@yuji_yukuan,@supplier_id,@leibie,@beizhu)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@huikuan_neirong",   SqlDbType.Text),
                new SqlParameter("@xiangmu_mingcheng", SqlDbType.Text),
                new SqlParameter("@xiangmu_zongkuan",  SqlDbType.Money, 8),
                new SqlParameter("@yifu_jine",         SqlDbType.Money, 8),
                new SqlParameter("@zhifu_shijian",     SqlDbType.Date,  3),
                new SqlParameter("@benci_jine",        SqlDbType.Money, 8),
                new SqlParameter("@yuji_yukuan",       SqlDbType.Date,  3),
                new SqlParameter("@supplier_id",       SqlDbType.Int,   4),
                new SqlParameter("@leibie",            SqlDbType.Int,   4),
                new SqlParameter("@beizhu",            SqlDbType.Text)
            };
            parameters[0].Value = model.huikuan_neirong;
            parameters[1].Value = model.xiangmu_mingcheng;
            parameters[2].Value = model.xiangmu_zongkuan;
            parameters[3].Value = model.yifu_jine;
            parameters[4].Value = model.zhifu_shijian;
            parameters[5].Value = model.benci_jine;
            parameters[6].Value = model.yuji_yukuan;
            parameters[7].Value = model.supplier_id;
            parameters[8].Value = model.leibie;
            parameters[9].Value = model.beizhu;

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

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

            strSql.Append("select  top 1 id,huikuan_neirong,xiangmu_mingcheng,xiangmu_zongkuan,yifu_jine,zhifu_shijian,benci_jine,yuji_yukuan,supplier_id,leibie,beizhu from hui_kuan_dan ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Maticsoft.Model.hui_kuan_dan model = new Maticsoft.Model.hui_kuan_dan();
            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. 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txthuikuan_neirong.Text.Trim().Length == 0)
            {
                strErr += "huikuan_neirong不能为空!\\n";
            }
            if (this.txtxiangmu_mingcheng.Text.Trim().Length == 0)
            {
                strErr += "xiangmu_mingcheng不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtxiangmu_zongkuan.Text))
            {
                strErr += "xiangmu_zongkuan格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtyifu_jine.Text))
            {
                strErr += "yifu_jine格式错误!\\n";
            }
            //if(!PageValidate.IsDateTime(txtzhifu_shijian.Text))
            //{
            //    strErr+="zhifu_shijian格式错误!\\n";
            //}
            if (!PageValidate.IsDecimal(txtbenci_jine.Text))
            {
                strErr += "benci_jine格式错误!\\n";
            }
            //if(!PageValidate.IsDateTime(txtyuji_yukuan.Text))
            //{
            //    strErr+="yuji_yukuan格式错误!\\n";
            //}

            //if(!PageValidate.IsNumber(txtleibie.Text))
            //{
            //    strErr+="leibie格式错误!\\n";
            //}
            //if(this.txtbeizhu.Text.Trim().Length==0)
            //{
            //    strErr+="beizhu不能为空!\\n";
            //}

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string  huikuan_neirong   = this.txthuikuan_neirong.Text;
            string  xiangmu_mingcheng = this.txtxiangmu_mingcheng.Text;
            decimal xiangmu_zongkuan  = decimal.Parse(this.txtxiangmu_zongkuan.Text);
            decimal yifu_jine         = decimal.Parse(this.txtyifu_jine.Text);

            decimal benci_jine = decimal.Parse(this.txtbenci_jine.Text);

            int    supplier_id = int.Parse(this.DropDownList1.Text);
            string beizhu      = this.txtbeizhu.Text;

            Maticsoft.Model.hui_kuan_dan model = new Maticsoft.Model.hui_kuan_dan();
            model.huikuan_neirong   = huikuan_neirong;
            model.xiangmu_mingcheng = xiangmu_mingcheng;
            model.xiangmu_zongkuan  = xiangmu_zongkuan;
            model.yifu_jine         = yifu_jine;
            if (txtzhifu_shijian.Text != "")
            {
                model.zhifu_shijian = DateTime.Parse(this.txtzhifu_shijian.Text);
            }
            model.benci_jine = benci_jine;
            if (txtyuji_yukuan.Text != "")
            {
                model.yuji_yukuan = DateTime.Parse(this.txtyuji_yukuan.Text);
            }
            model.supplier_id = supplier_id;
            if (txtleibie.Text != "")
            {
                model.leibie = Convert.ToInt16(txtleibie.Text);
            }
            model.beizhu = beizhu;

            Maticsoft.BLL.hui_kuan_dan bll = new Maticsoft.BLL.hui_kuan_dan();
            bll.Add(model);
            Session["hui_mod"] = model;
            Maticsoft.Common.MessageBox.ShowAndOpennew(this, "保存成功!", "print.aspx");
        }