Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtmoney_id.Text))
            {
                strErr+="财富ID格式错误!\\n";
            }
            if(this.txtuser_telphone.Text.Trim().Length==0)
            {
                strErr+="用户Phone不能为空!\\n";
            }
            if(!PageValidate.IsDecimal(txtmoney_change.Text))
            {
                strErr+="财富变化格式错误!\\n";
            }
            if(!PageValidate.IsDateTime(txtmoneychange_time.Text))
            {
                strErr+="财富变化时间格式错误!\\n";
            }
            if(this.txtmoneychange_comment.Text.Trim().Length==0)
            {
                strErr+="财富变化说明不能为空!\\n";
            }
            if(!PageValidate.IsDecimal(txtmoney_balance.Text))
            {
                strErr+="余额格式错误!\\n";
            }
            if(this.txtmoneychange_type.Text.Trim().Length==0)
            {
                strErr+="财富变化类型不能为空!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            int money_id=int.Parse(this.txtmoney_id.Text);
            string user_telphone=this.txtuser_telphone.Text;
            decimal money_change=decimal.Parse(this.txtmoney_change.Text);
            DateTime moneychange_time=DateTime.Parse(this.txtmoneychange_time.Text);
            string moneychange_comment=this.txtmoneychange_comment.Text;
            decimal money_balance=decimal.Parse(this.txtmoney_balance.Text);
            string moneychange_type=this.txtmoneychange_type.Text;

            la.Model.money model=new la.Model.money();
            model.money_id=money_id;
            model.user_telphone=user_telphone;
            model.money_change=money_change;
            model.moneychange_time=moneychange_time;
            model.moneychange_comment=moneychange_comment;
            model.money_balance=money_balance;
            model.moneychange_type=moneychange_type;

            la.BLL.money bll=new la.BLL.money();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx");
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public la.Model.money DataRowToModel(DataRow row)
 {
     la.Model.money model=new la.Model.money();
     if (row != null)
     {
         if(row["money_id"]!=null && row["money_id"].ToString()!="")
         {
             model.money_id=int.Parse(row["money_id"].ToString());
         }
         if(row["user_telphone"]!=null)
         {
             model.user_telphone=row["user_telphone"].ToString();
         }
         if(row["money_change"]!=null && row["money_change"].ToString()!="")
         {
             model.money_change=decimal.Parse(row["money_change"].ToString());
         }
         if(row["moneychange_time"]!=null && row["moneychange_time"].ToString()!="")
         {
             model.moneychange_time=DateTime.Parse(row["moneychange_time"].ToString());
         }
         if(row["moneychange_comment"]!=null)
         {
             model.moneychange_comment=row["moneychange_comment"].ToString();
         }
         if(row["money_balance"]!=null && row["money_balance"].ToString()!="")
         {
             model.money_balance=decimal.Parse(row["money_balance"].ToString());
         }
         if(row["moneychange_type"]!=null)
         {
             model.moneychange_type=row["moneychange_type"].ToString();
         }
     }
     return model;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public la.Model.money GetModel(int money_id,string user_telphone)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 money_id,user_telphone,money_change,moneychange_time,moneychange_comment,money_balance,moneychange_type from money ");
            strSql.Append(" where money_id=@money_id and user_telphone=@user_telphone ");
            SqlParameter[] parameters = {
                    new SqlParameter("@money_id", SqlDbType.Int,4),
                    new SqlParameter("@user_telphone", SqlDbType.VarChar,20)			};
            parameters[0].Value = money_id;
            parameters[1].Value = user_telphone;

            la.Model.money model=new la.Model.money();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }