Esempio n. 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public la.Model.log DataRowToModel(DataRow row)
 {
     la.Model.log model=new la.Model.log();
     if (row != null)
     {
         if(row["log_id"]!=null && row["log_id"].ToString()!="")
         {
             model.log_id=int.Parse(row["log_id"].ToString());
         }
         if(row["user_telphone"]!=null)
         {
             model.user_telphone=row["user_telphone"].ToString();
         }
         if(row["log_ip"]!=null)
         {
             model.log_ip=row["log_ip"].ToString();
         }
         if(row["log_time"]!=null && row["log_time"].ToString()!="")
         {
             model.log_time=DateTime.Parse(row["log_time"].ToString());
         }
         if(row["LAT"]!=null && row["LAT"].ToString()!="")
         {
             model.LAT=decimal.Parse(row["LAT"].ToString());
         }
         if(row["LNG"]!=null && row["LNG"].ToString()!="")
         {
             model.LNG=decimal.Parse(row["LNG"].ToString());
         }
     }
     return model;
 }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtlog_id.Text))
            {
                strErr+="日志编号格式错误!\\n";
            }
            if(this.txtuser_telphone.Text.Trim().Length==0)
            {
                strErr+="用户Phone不能为空!\\n";
            }
            if(this.txtlog_ip.Text.Trim().Length==0)
            {
                strErr+="登录IP不能为空!\\n";
            }
            if(!PageValidate.IsDateTime(txtlog_time.Text))
            {
                strErr+="登录时间格式错误!\\n";
            }
            if(!PageValidate.IsDecimal(txtLAT.Text))
            {
                strErr+="LAT格式错误!\\n";
            }
            if(!PageValidate.IsDecimal(txtLNG.Text))
            {
                strErr+="LNG格式错误!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            int log_id=int.Parse(this.txtlog_id.Text);
            string user_telphone=this.txtuser_telphone.Text;
            string log_ip=this.txtlog_ip.Text;
            DateTime log_time=DateTime.Parse(this.txtlog_time.Text);
            decimal LAT=decimal.Parse(this.txtLAT.Text);
            decimal LNG=decimal.Parse(this.txtLNG.Text);

            la.Model.log model=new la.Model.log();
            model.log_id=log_id;
            model.user_telphone=user_telphone;
            model.log_ip=log_ip;
            model.log_time=log_time;
            model.LAT=LAT;
            model.LNG=LNG;

            la.BLL.log bll=new la.BLL.log();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx");
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public la.Model.log GetModel(int log_id,string user_telphone)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 log_id,user_telphone,log_ip,log_time,LAT,LNG from log ");
            strSql.Append(" where log_id=@log_id and user_telphone=@user_telphone ");
            SqlParameter[] parameters = {
                    new SqlParameter("@log_id", SqlDbType.Int,4),
                    new SqlParameter("@user_telphone", SqlDbType.VarChar,20)			};
            parameters[0].Value = log_id;
            parameters[1].Value = user_telphone;

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