Example #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public la.Model.travel GetModel(int travle_ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 travle_ID,promoter_userid,release_time,Destination,startplace,return_time,start_time,transportation,fee,travle_theme,travle_personcount,companion_condition,travle_msg,pic1,pic2,pic3,income_condition,car_condition,height_condition,credit_condition,wantget_gift,wantsend_gift,reg_fee from travel ");
            strSql.Append(" where travle_ID=@travle_ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@travle_ID", SqlDbType.Int,4)			};
            parameters[0].Value = travle_ID;

            la.Model.travel model=new la.Model.travel();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public la.Model.travel DataRowToModel(DataRow row)
 {
     la.Model.travel model=new la.Model.travel();
     if (row != null)
     {
         if(row["travle_ID"]!=null && row["travle_ID"].ToString()!="")
         {
             model.travle_ID=int.Parse(row["travle_ID"].ToString());
         }
         if(row["promoter_userid"]!=null && row["promoter_userid"].ToString()!="")
         {
             model.promoter_userid=row["promoter_userid"].ToString();
         }
         if(row["release_time"]!=null && row["release_time"].ToString()!="")
         {
             model.release_time=DateTime.Parse(row["release_time"].ToString());
         }
         if(row["Destination"]!=null)
         {
             model.Destination=row["Destination"].ToString();
         }
         if(row["startplace"]!=null)
         {
             model.startplace=row["startplace"].ToString();
         }
         if(row["return_time"]!=null && row["return_time"].ToString()!="")
         {
             model.return_time=DateTime.Parse(row["return_time"].ToString());
         }
         if(row["start_time"]!=null && row["start_time"].ToString()!="")
         {
             model.start_time=DateTime.Parse(row["start_time"].ToString());
         }
         if(row["transportation"]!=null)
         {
             model.transportation=row["transportation"].ToString();
         }
         if(row["fee"]!=null)
         {
             model.fee=row["fee"].ToString();
         }
         if(row["travle_theme"]!=null)
         {
             model.travle_theme=row["travle_theme"].ToString();
         }
         if(row["travle_personcount"]!=null && row["travle_personcount"].ToString()!="")
         {
             model.travle_personcount=int.Parse(row["travle_personcount"].ToString());
         }
         if(row["companion_condition"]!=null)
         {
             model.companion_condition=row["companion_condition"].ToString();
         }
         if(row["travle_msg"]!=null)
         {
             model.travle_msg=row["travle_msg"].ToString();
         }
         if(row["pic1"]!=null)
         {
             model.pic1=row["pic1"].ToString();
         }
         if(row["pic2"]!=null)
         {
             model.pic2=row["pic2"].ToString();
         }
         if(row["pic3"]!=null)
         {
             model.pic3=row["pic3"].ToString();
         }
         if(row["income_condition"]!=null)
         {
             model.income_condition=row["income_condition"].ToString();
         }
         if(row["car_condition"]!=null)
         {
             model.car_condition=row["car_condition"].ToString();
         }
         if(row["height_condition"]!=null)
         {
             model.height_condition=row["height_condition"].ToString();
         }
         if(row["credit_condition"]!=null)
         {
             model.credit_condition=row["credit_condition"].ToString();
         }
         if(row["wantget_gift"]!=null)
         {
             model.wantget_gift=row["wantget_gift"].ToString();
         }
         if(row["wantsend_gift"]!=null)
         {
             model.wantsend_gift=row["wantsend_gift"].ToString();
         }
         if(row["reg_fee"]!=null && row["reg_fee"].ToString()!="")
         {
             model.reg_fee=decimal.Parse(row["reg_fee"].ToString());
         }
     }
     return model;
 }
Example #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txttravle_ID.Text))
            {
                strErr+="旅行ID格式错误!\\n";
            }
            if(!PageValidate.IsNumber(txtpromoter_userid.Text))
            {
                strErr+="发起人格式错误!\\n";
            }
            if(!PageValidate.IsDateTime(txtrelease_time.Text))
            {
                strErr+="发布时间格式错误!\\n";
            }
            if(this.txtDestination.Text.Trim().Length==0)
            {
                strErr+="目的地不能为空!\\n";
            }
            if(this.txtstartplace.Text.Trim().Length==0)
            {
                strErr+="出发地不能为空!\\n";
            }
            if(!PageValidate.IsDateTime(txtreturn_time.Text))
            {
                strErr+="返回时间格式错误!\\n";
            }
            if(!PageValidate.IsDateTime(txtstart_time.Text))
            {
                strErr+="出发时间格式错误!\\n";
            }
            if(this.txttransportation.Text.Trim().Length==0)
            {
                strErr+="交通方式不能为空!\\n";
            }
            if(this.txtfee.Text.Trim().Length==0)
            {
                strErr+="费用说明不能为空!\\n";
            }
            if(this.txttravle_theme.Text.Trim().Length==0)
            {
                strErr+="旅行主题不能为空!\\n";
            }
            if(!PageValidate.IsNumber(txttravle_personcount.Text))
            {
                strErr+="需要旅伴人数格式错误!\\n";
            }
            if(this.txtcompanion_condition.Text.Trim().Length==0)
            {
                strErr+="旅伴要求不能为空!\\n";
            }
            if(this.txttravle_msg.Text.Trim().Length==0)
            {
                strErr+="留言不能为空!\\n";
            }
            if(this.txtpic1.Text.Trim().Length==0)
            {
                strErr+="图1不能为空!\\n";
            }
            if(this.txtpic2.Text.Trim().Length==0)
            {
                strErr+="图2不能为空!\\n";
            }
            if(this.txtpic3.Text.Trim().Length==0)
            {
                strErr+="图3不能为空!\\n";
            }
            if(this.txtincome_condition.Text.Trim().Length==0)
            {
                strErr+="旅伴收入要求不能为空!\\n";
            }
            if(this.txtcar_condition.Text.Trim().Length==0)
            {
                strErr+="旅伴车辆要求不能为空!\\n";
            }
            if(this.txtheight_condition.Text.Trim().Length==0)
            {
                strErr+="旅伴身高要求不能为空!\\n";
            }
            if(this.txtcredit_condition.Text.Trim().Length==0)
            {
                strErr+="旅伴信用要求不能为空!\\n";
            }
            if(this.txtwantget_gift.Text.Trim().Length==0)
            {
                strErr+="想得到的礼品不能为空!\\n";
            }
            if(this.txtwantsend_gift.Text.Trim().Length==0)
            {
                strErr+="想送出的礼品不能为空!\\n";
            }
            if(!PageValidate.IsDecimal(txtreg_fee.Text))
            {
                strErr+="报名费用(旅币)格式错误!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            int travle_ID=int.Parse(this.txttravle_ID.Text);
            int promoter_userid=int.Parse(this.txtpromoter_userid.Text);
            DateTime release_time=DateTime.Parse(this.txtrelease_time.Text);
            string Destination=this.txtDestination.Text;
            string startplace=this.txtstartplace.Text;
            DateTime return_time=DateTime.Parse(this.txtreturn_time.Text);
            DateTime start_time=DateTime.Parse(this.txtstart_time.Text);
            string transportation=this.txttransportation.Text;
            string fee=this.txtfee.Text;
            string travle_theme=this.txttravle_theme.Text;
            int travle_personcount=int.Parse(this.txttravle_personcount.Text);
            string companion_condition=this.txtcompanion_condition.Text;
            string travle_msg=this.txttravle_msg.Text;
            string pic1=this.txtpic1.Text;
            string pic2=this.txtpic2.Text;
            string pic3=this.txtpic3.Text;
            string income_condition=this.txtincome_condition.Text;
            string car_condition=this.txtcar_condition.Text;
            string height_condition=this.txtheight_condition.Text;
            string credit_condition=this.txtcredit_condition.Text;
            string wantget_gift=this.txtwantget_gift.Text;
            string wantsend_gift=this.txtwantsend_gift.Text;
            decimal reg_fee=decimal.Parse(this.txtreg_fee.Text);

            la.Model.travel model=new la.Model.travel();
            model.travle_ID=travle_ID;
            model.promoter_userid=promoter_userid;
            model.release_time=release_time;
            model.Destination=Destination;
            model.startplace=startplace;
            model.return_time=return_time;
            model.start_time=start_time;
            model.transportation=transportation;
            model.fee=fee;
            model.travle_theme=travle_theme;
            model.travle_personcount=travle_personcount;
            model.companion_condition=companion_condition;
            model.travle_msg=travle_msg;
            model.pic1=pic1;
            model.pic2=pic2;
            model.pic3=pic3;
            model.income_condition=income_condition;
            model.car_condition=car_condition;
            model.height_condition=height_condition;
            model.credit_condition=credit_condition;
            model.wantget_gift=wantget_gift;
            model.wantsend_gift=wantsend_gift;
            model.reg_fee=reg_fee;

            la.BLL.travel bll=new la.BLL.travel();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx");
        }