Esempio n. 1
0
        /// <summary>
        /// 验证用户token是否有用
        /// </summary>
        /// <param name="memberid"></param>
        /// <returns></returns>
        public static string getUserToke(string memberid)
        {
            string membertoken = "";

            System.Model.t_custom tc = _bll.tcbll.GetModel(Utility.Helper.gerInt(memberid));
            if (tc != null)
            {
                membertoken = tc.id.ToString();
            }
            return(membertoken);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(System.Model.t_custom model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_custom set ");

            strSql.Append(" phone = @phone , ");
            strSql.Append(" pwd = @pwd , ");
            strSql.Append(" nicheng = @nicheng , ");
            strSql.Append(" img = @img , ");
            strSql.Append(" name = @name , ");
            strSql.Append(" pudate = @pudate , ");
            strSql.Append(" yqm = @yqm , ");
            strSql.Append(" syMoney = @syMoney , ");
            strSql.Append(" syJf = @syJf  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",      SqlDbType.Int,        4),
                new SqlParameter("@phone",   SqlDbType.NVarChar,  50),
                new SqlParameter("@pwd",     SqlDbType.NVarChar,  50),
                new SqlParameter("@nicheng", SqlDbType.NVarChar,  50),
                new SqlParameter("@img",     SqlDbType.NVarChar, 200),
                new SqlParameter("@name",    SqlDbType.NVarChar,  50),
                new SqlParameter("@pudate",  SqlDbType.NVarChar,  50),
                new SqlParameter("@yqm",     SqlDbType.NVarChar,  50),
                new SqlParameter("@syMoney", SqlDbType.Money,      8),
                new SqlParameter("@syJf",    SqlDbType.Int, 4)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.phone;
            parameters[2].Value = model.pwd;
            parameters[3].Value = model.nicheng;
            parameters[4].Value = model.img;
            parameters[5].Value = model.name;
            parameters[6].Value = model.pudate;
            parameters[7].Value = model.yqm;
            parameters[8].Value = model.syMoney;
            parameters[9].Value = model.syJf;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public System.Model.t_custom GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, phone, pwd, nicheng, img, name, pudate, yqm, syMoney, syJf  ");
            strSql.Append("  from t_custom ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.phone   = ds.Tables[0].Rows[0]["phone"].ToString();
                model.pwd     = ds.Tables[0].Rows[0]["pwd"].ToString();
                model.nicheng = ds.Tables[0].Rows[0]["nicheng"].ToString();
                model.img     = ds.Tables[0].Rows[0]["img"].ToString();
                model.name    = ds.Tables[0].Rows[0]["name"].ToString();
                model.pudate  = ds.Tables[0].Rows[0]["pudate"].ToString();
                model.yqm     = ds.Tables[0].Rows[0]["yqm"].ToString();
                if (ds.Tables[0].Rows[0]["syMoney"].ToString() != "")
                {
                    model.syMoney = decimal.Parse(ds.Tables[0].Rows[0]["syMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["syJf"].ToString() != "")
                {
                    model.syJf = int.Parse(ds.Tables[0].Rows[0]["syJf"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(System.Model.t_custom model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_custom(");
            strSql.Append("phone,pwd,nicheng,img,name,pudate,yqm,syMoney,syJf");
            strSql.Append(") values (");
            strSql.Append("@phone,@pwd,@nicheng,@img,@name,@pudate,@yqm,@syMoney,@syJf");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@phone",   SqlDbType.NVarChar,  50),
                new SqlParameter("@pwd",     SqlDbType.NVarChar,  50),
                new SqlParameter("@nicheng", SqlDbType.NVarChar,  50),
                new SqlParameter("@img",     SqlDbType.NVarChar, 200),
                new SqlParameter("@name",    SqlDbType.NVarChar,  50),
                new SqlParameter("@pudate",  SqlDbType.NVarChar,  50),
                new SqlParameter("@yqm",     SqlDbType.NVarChar,  50),
                new SqlParameter("@syMoney", SqlDbType.Money,      8),
                new SqlParameter("@syJf",    SqlDbType.Int, 4)
            };

            parameters[0].Value = model.phone;
            parameters[1].Value = model.pwd;
            parameters[2].Value = model.nicheng;
            parameters[3].Value = model.img;
            parameters[4].Value = model.name;
            parameters[5].Value = model.pudate;
            parameters[6].Value = model.yqm;
            parameters[7].Value = model.syMoney;
            parameters[8].Value = model.syJf;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <System.Model.t_custom> DataTableToList(DataTable dt)
        {
            List <System.Model.t_custom> modelList = new List <System.Model.t_custom>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                System.Model.t_custom model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new System.Model.t_custom();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.phone   = dt.Rows[n]["phone"].ToString();
                    model.pwd     = dt.Rows[n]["pwd"].ToString();
                    model.nicheng = dt.Rows[n]["nicheng"].ToString();
                    model.img     = dt.Rows[n]["img"].ToString();
                    model.name    = dt.Rows[n]["name"].ToString();
                    model.pudate  = dt.Rows[n]["pudate"].ToString();
                    model.yqm     = dt.Rows[n]["yqm"].ToString();
                    if (dt.Rows[n]["syMoney"].ToString() != "")
                    {
                        model.syMoney = decimal.Parse(dt.Rows[n]["syMoney"].ToString());
                    }
                    if (dt.Rows[n]["syJf"].ToString() != "")
                    {
                        model.syJf = int.Parse(dt.Rows[n]["syJf"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Esempio n. 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(System.Model.t_custom model)
 {
     return(dal.Update(model));
 }
Esempio n. 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(System.Model.t_custom model)
 {
     return(dal.Add(model));
 }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string   res        = "";
                JsonData jsonResult = new JsonData();
                try
                {
                    string phone = Request["phone"] != null?Utility.Helper.Checkstr(Request["phone"]) : "";

                    string authcode = Request["authcode"] != null?Utility.Helper.Checkstr(Request["authcode"]) : "";

                    string pushtype = Request["pushtype"] != null?Utility.Helper.Checkstr(Request["pushtype"]) : "";

                    string token = Request["token"] != null?Utility.Helper.Checkstr(Request["token"]) : "";

                    #region 登录

                    //log.setlog("", phone + " " + authcode + "  " + pushtype + " " + token);

                    if (!string.IsNullOrEmpty(phone) && !string.IsNullOrEmpty(authcode))
                    {
                        //判断是否有用户

                        string memberid = "";

                        string strwhere = " phone='" + phone + "' ";


                        string authcodeSession = Session["authcode"] as string;


                        string vcodewhere = " verificationMode ='" + phone + "' and  code='" + authcode + "' and edate> '" + System.DateTime.Now + "' ";

                        List <System.Model.verification_code> vc = _bll.vcbll.GetModelList(vcodewhere);

                        if (vc.Count > 0)
                        {
                            //if (!string.IsNullOrEmpty(authcodeSession))
                            //{
                            List <System.Model.t_custom> tclist = _bll.tcbll.GetModelList(strwhere);

                            if (tclist.Count > 0)
                            {
                                //有 直接登录 添加登录日志

                                memberid = tclist[0].id.ToString();

                                System.Model.t_login_log tll = new System.Model.t_login_log();
                                tll.phone    = phone;
                                tll.authcode = authcode;
                                tll.pudate   = System.DateTime.Now;
                                _bll.tllbll.Add(tll);
                            }
                            else
                            {
                                //无 添加用户 登录 添加登录日志
                                System.Model.t_custom tc = new System.Model.t_custom();
                                tc.img     = "";
                                tc.name    = "";
                                tc.nicheng = "";
                                tc.phone   = phone;
                                tc.pudate  = System.DateTime.Now.ToString();
                                tc.pwd     = "";
                                tc.syJf    = 0;
                                tc.syMoney = 0;
                                tc.yqm     = Utility.Helper.rnds(6);
                                _bll.tcbll.Add(tc);

                                List <System.Model.t_custom> tclist1 = _bll.tcbll.GetModelList(strwhere);

                                if (tclist1.Count > 0)
                                {
                                    memberid = tclist1[0].id.ToString();

                                    System.Model.t_login_log tll = new System.Model.t_login_log();
                                    tll.phone    = phone;
                                    tll.authcode = authcode;
                                    tll.pudate   = System.DateTime.Now;
                                    _bll.tllbll.Add(tll);
                                }
                            }


                            #region 判断token是否有用

                            if (!string.IsNullOrEmpty(pushtype) && !string.IsNullOrEmpty(token))
                            {
                                addpushtoken(memberid, pushtype, token);
                            }
                            #endregion

                            strwhere = " customId='" + memberid + "' and device='" + pushtype + "'  ";
                            List <System.Model.apush_token> at = _bll.atbll.GetModelList(strwhere);
                            int ispush = 0;
                            if (at.Count > 0)
                            {
                                ispush = at[0].isstartusing;
                            }


                            jsonResult["res"]      = (int)MyEnum.ResultEnum.成功;
                            jsonResult["msg"]      = "登录成功";
                            jsonResult["memberid"] = memberid;
                            jsonResult["phone"]    = phone;
                            jsonResult["ispust"]   = ispush;
                            jsonResult["code"]     = "";
                        }
                        else
                        {
                            jsonResult["res"]      = (int)MyEnum.ResultEnum.失败;
                            jsonResult["msg"]      = "登录失败";
                            jsonResult["memberid"] = "";
                            jsonResult["code"]     = "验证码失效";
                        }
                    }
                    else
                    {
                        jsonResult["res"]      = (int)MyEnum.ResultEnum.失败;
                        jsonResult["msg"]      = "登录失败";
                        jsonResult["memberid"] = "";
                        jsonResult["code"]     = "参数缺失";
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    jsonResult["result"] = (int)MyEnum.ResultEnum.系统错误;
                    jsonResult["msg"]    = "服务器繁忙,请稍后再试";
                    jsonResult["code"]   = ex.Message;
                }
                res = JsonMapper.ToJson(jsonResult);
                res = MyString.UnicodeToString(res);
                Response.Write(res);
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string   res        = "";
                JsonData jsonResult = new JsonData();
                try
                {
                    string memberid = _bll.getUserToke(Utility.Helper.gerString(Request["memberid"]));

                    if (!string.IsNullOrEmpty(memberid))
                    {
                        //判断是否有用户



                        System.Model.t_custom tclist = _bll.tcbll.GetModel(Utility.Helper.gerInt(memberid));

                        if (tclist != null)
                        {
                            string strwhere = " customId='" + memberid + "'  ";
                            List <System.Model.apush_token> at = _bll.atbll.GetModelList(strwhere);
                            int ispush = 0;
                            if (at.Count > 0)
                            {
                                ispush = at[0].isstartusing;
                            }

                            jsonResult["res"]      = (int)MyEnum.ResultEnum.成功;
                            jsonResult["msg"]      = "登录成功";
                            jsonResult["memberid"] = memberid;
                            jsonResult["phone"]    = tclist.phone;
                            jsonResult["ispust"]   = ispush;
                            jsonResult["code"]     = "";
                        }
                        else
                        {
                            jsonResult["res"]      = (int)MyEnum.ResultEnum.失败;
                            jsonResult["msg"]      = "未找到用户";
                            jsonResult["memberid"] = "";
                            jsonResult["code"]     = "用户信息有误";
                        }
                    }
                    else
                    {
                        jsonResult["res"]      = (int)MyEnum.ResultEnum.失败;
                        jsonResult["msg"]      = "登录失败";
                        jsonResult["memberid"] = "";
                        jsonResult["code"]     = "参数缺失";
                    }
                }
                catch (Exception ex)
                {
                    jsonResult["result"] = (int)MyEnum.ResultEnum.系统错误;
                    jsonResult["msg"]    = "服务器繁忙,请稍后再试";
                    jsonResult["code"]   = ex.Message;
                }
                res = JsonMapper.ToJson(jsonResult);
                res = MyString.UnicodeToString(res);
                Response.Write(res);
            }
        }