Esempio n. 1
0
        public QPS.NEW.Model.Integral GetModel(int Id)
        {
            QPS.NEW.Model.Integral integral = null;

            string    strSql = "select UserID,WalletMoney,BankMoney,WalletMoney+BankMoney as TotalMoney from TUserInfo where UserID=@id";
            DataTable dt     = sqlHelper_.GetDataTable(
                strSql,
                CommandType.Text,
                new SqlParameter[]
            {
                new SqlParameter("@id", Id)
            }
                );

            if (dt != null && dt.Rows.Count > 0)
            {
                integral = new Model.Integral();

                integral.UserID      = Convert.ToInt32(dt.Rows[0]["UserID"]);
                integral.BankMoney   = Convert.ToInt32(dt.Rows[0]["BankMoney"]);
                integral.WalletMoney = Convert.ToInt32(dt.Rows[0]["WalletMoney"]);
                integral.TotalMoney  = Convert.ToInt32(dt.Rows[0]["TotalMoney"]);
            }
            return(integral);
        }
Esempio n. 2
0
        //添加
        protected void Button1_Click(object sender, EventArgs e)
        {
            string uid = this.txtId.Text;
            string uname = this.txtName.Text;
            string jf = this.txtJf.Text;

            QPS.NEW.Model.Integral Mgral = new QPS.NEW.Model.Integral();
            //Mgral.UserID = uid;
            //Mgral.Content = Convert.ToInt32(jf);
            //Mgral.CreateTime = DateTime.Now;

            Mgral.UserID = Convert.ToInt32(uid);
            Mgral.TotalMoney = Convert.ToInt32(jf);

            QPS.NEW.BLL.Integral Bin = new QPS.NEW.BLL.Integral();
            int i=Bin.Add(Mgral);
            if (i >= 0)
            {
                Response.Write("<script>alert('积分添加成功!!');window.location.href = 'UserInfo.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('积分添加失败!!');</script>");
            }

        }
Esempio n. 3
0
        //添加
        protected void Button1_Click(object sender, EventArgs e)
        {
            string uid   = this.txtId.Text;
            string uname = this.txtName.Text;
            string jf    = this.txtJf.Text;

            QPS.NEW.Model.Integral Mgral = new QPS.NEW.Model.Integral();
            //Mgral.UserID = uid;
            //Mgral.Content = Convert.ToInt32(jf);
            //Mgral.CreateTime = DateTime.Now;

            Mgral.UserID     = Convert.ToInt32(uid);
            Mgral.TotalMoney = Convert.ToInt32(jf);

            QPS.NEW.BLL.Integral Bin = new QPS.NEW.BLL.Integral();
            int i = Bin.Add(Mgral);

            if (i >= 0)
            {
                Response.Write("<script>alert('积分添加成功!!');window.location.href = 'UserInfo.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('积分添加失败!!');</script>");
            }
        }
Esempio n. 4
0
        public int Add(QPS.NEW.Model.Integral model)
        {
            int bankMoney = GetBankMoney(model.UserID) + model.BankMoney;
            int num       = sqlHelper_.ExecuteCommand(
                "update TUserInfo set BankMoney=@bankmoney",
                CommandType.Text,
                new SqlParameter("@bankmoney", bankMoney)
                );

            if (num == 1)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 5
0
        protected void bntUpdate_Click(object sender, EventArgs e)
        {
            string id = Request["ID"].ToString();
            string jifen = this.txtJiFen.Text;

            QPS.NEW.Model.Integral Mro = new QPS.NEW.Model.Integral();
            //Mro.Id = Convert.ToInt32(id);
            //Mro.Content = Convert.ToInt32(jifen);
            Mro.UserID = Convert.ToInt32(id);
            Mro.TotalMoney = Convert.ToInt32(jifen);

            QPS.NEW.BLL.Integral rm = new QPS.NEW.BLL.Integral();
            int i =Convert.ToInt32( rm.UpdateContent(Mro));
            if (i >= -1)
            {
                Response.Write("<script>alert('修改成功!!');window.location.href = 'Jfgl.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败!!');</script>");
            }
        }
Esempio n. 6
0
        protected void bntUpdate_Click(object sender, EventArgs e)
        {
            string id    = Request["ID"].ToString();
            string jifen = this.txtJiFen.Text;

            QPS.NEW.Model.Integral Mro = new QPS.NEW.Model.Integral();
            //Mro.Id = Convert.ToInt32(id);
            //Mro.Content = Convert.ToInt32(jifen);
            Mro.UserID     = Convert.ToInt32(id);
            Mro.TotalMoney = Convert.ToInt32(jifen);

            QPS.NEW.BLL.Integral rm = new QPS.NEW.BLL.Integral();
            int i = Convert.ToInt32(rm.UpdateContent(Mro));

            if (i >= -1)
            {
                Response.Write("<script>alert('修改成功!!');window.location.href = 'Jfgl.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败!!');</script>");
            }
        }
Esempio n. 7
0
        protected void gdvOrder_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            ////得到单位编号
            //string rowUpdate = this.gdvOrder.DataKeys[].Values[0].ToString();
            ////转换为整数
            //int ID = Convert.ToInt32(rowUpdate);
            //QPS.BLL.Orderform Border = new QPS.BLL.Orderform();
            //QPS.Model.Orderform Morder = new QPS.Model.Orderform();
            //Morder.Id = ID;
            //Morder.Beveragecost = (decimal)this.gdvOrder.DataKeys[e.RowIndex].Values[3];
            //Border.Update(Morder);
            //gdvOrder.DataSource = databind();
            //gdvOrder.DataBind();
            string strArgument = e.CommandArgument.ToString();
            if (e.CommandName == "IsValidate")
            {
                string[] Argument = strArgument.Split('|');
                string id = Argument[0].ToString();

                string type = Argument[1].ToString();
                int ok;
                if (type == "0")
                { 
                    ok = 1; 
                }
                else 
                {
                    ok = 0; 
                }

                QPS.NEW.BLL.Orderform Border = new QPS.NEW.BLL.Orderform();
                QPS.NEW.Model.Orderform order = Border.GetModel(Convert.ToInt32(id));
                Border.UpdateType(id,type);
                //订单有效 则加上积分  否则 如果存在积分 则删除
                QPS.NEW.BLL.Integral Bint = new QPS.NEW.BLL.Integral();
                QPS.NEW.Model.Integral Mint = new QPS.NEW.Model.Integral();
                     if (Bint.GetList("OrderId='" + id + "'").Tables[0].Rows.Count > 0)//删除已有积分
                    {
                        Bint.Delete(Convert.ToInt32(Bint.GetList("OrderId='" + id + "'").Tables[0].Rows[0]["Id"]));
                    }
                if (ok == 1)//有效
                {
                    QPS.NEW.BLL.Room Broom = new QPS.NEW.BLL.Room();
                    QPS.NEW.Model.Room r = Broom.GetModel(order.Roomid);
                        //Mint.OrderId = Convert.ToInt32(id);
                        //Mint.RoomId = order.Roomid;
                        Mint.UserID = order.Userid;
                        //Mint.CreateTime = order.StartTime;
                        TimeSpan ts = (TimeSpan)(order.endTime - order.StartTime);
                        Mint.BankMoney = Convert.ToInt32((ts.Hours * (double)r.RoomPrice));
                        if (order.Beveragecost != null)
                        { Mint.BankMoney += (int)order.Beveragecost; }
                        Bint.Add(Mint);
                    }
                }
                gdvOrder.DataSource = databind();
                gdvOrder.DataBind();
            }
Esempio n. 8
0
        public bool Update(QPS.NEW.Model.Integral model)
        {
            bool res = false;

            string[]       filedName = new string[50];
            string[]       paramName = new string[50];
            SqlParameter[] sqlParams = new SqlParameter[50];
            int            Count     = 0;


            if (model.UserID == -999 && model.TotalMoney != -999)
            {
                return(false);
            }

            if (model.UserID != -999)
            {
                filedName[Count] = "UserID";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.UserID);
                Count++;
            }
            int newWalletMoney, newBankMoney;
            int bankMoney   = GetBankMoney(model.UserID);
            int walletMoney = GetWalletMoney(model.UserID);

            if (bankMoney + walletMoney < model.TotalMoney) //增加积分,直接写增加金额到Bank
            {
                newWalletMoney = walletMoney;
                newBankMoney   = model.TotalMoney - walletMoney;
            }
            else // 减少积分
            {
                int reducedMoney = model.TotalMoney - (bankMoney + walletMoney);
                if (bankMoney >= reducedMoney) // 优先操作Bank
                {
                    newBankMoney   = bankMoney - reducedMoney;
                    newWalletMoney = walletMoney;
                }
                else
                {
                    newBankMoney   = 0;
                    newWalletMoney = walletMoney + bankMoney - reducedMoney;
                }
            }


            filedName[Count] = "WalletMoney";
            paramName[Count] = "@" + filedName[Count];
            sqlParams[Count] = new SqlParameter(paramName[Count], newWalletMoney);
            Count++;


            filedName[Count] = "BankMoney";
            paramName[Count] = "@" + filedName[Count];
            sqlParams[Count] = new SqlParameter(paramName[Count], newBankMoney);
            Count++;


            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TUserInfo set ");
            for (int i = 1; i < Count; i++)
            {
                strSql.Append(filedName[i]);
                strSql.Append("=");
                strSql.Append(paramName[i]);
                if (i != Count - 1)
                {
                    strSql.Append(",");
                }
            }
            strSql.Append(" where ");
            strSql.Append(filedName[0] + "=" + paramName[0]);


            int num = Convert.ToInt32(sqlHelper_.ExecuteCommand(
                                          strSql.ToString(),
                                          CommandType.Text,
                                          sqlParams
                                          ));

            if (num != 1)
            {
                res = false;
            }
            else
            {
                res = true;
            }

            return(res);
        }
Esempio n. 9
0
 public bool UpdateContent(QPS.NEW.Model.Integral model)
 {
     return(Update(model));
 }
Esempio n. 10
0
        protected void gdvOrder_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            ////得到单位编号
            //string rowUpdate = this.gdvOrder.DataKeys[].Values[0].ToString();
            ////转换为整数
            //int ID = Convert.ToInt32(rowUpdate);
            //QPS.BLL.Orderform Border = new QPS.BLL.Orderform();
            //QPS.Model.Orderform Morder = new QPS.Model.Orderform();
            //Morder.Id = ID;
            //Morder.Beveragecost = (decimal)this.gdvOrder.DataKeys[e.RowIndex].Values[3];
            //Border.Update(Morder);
            //gdvOrder.DataSource = databind();
            //gdvOrder.DataBind();
            string strArgument = e.CommandArgument.ToString();

            if (e.CommandName == "IsValidate")
            {
                string[] Argument = strArgument.Split('|');
                string   id       = Argument[0].ToString();

                string type = Argument[1].ToString();
                int    ok;
                if (type == "0")
                {
                    ok = 1;
                }
                else
                {
                    ok = 0;
                }

                QPS.NEW.BLL.Orderform   Border = new QPS.NEW.BLL.Orderform();
                QPS.NEW.Model.Orderform order  = Border.GetModel(Convert.ToInt32(id));
                Border.UpdateType(id, type);
                //订单有效 则加上积分  否则 如果存在积分 则删除
                QPS.NEW.BLL.Integral   Bint = new QPS.NEW.BLL.Integral();
                QPS.NEW.Model.Integral Mint = new QPS.NEW.Model.Integral();
                if (Bint.GetList("OrderId='" + id + "'").Tables[0].Rows.Count > 0)     //删除已有积分
                {
                    Bint.Delete(Convert.ToInt32(Bint.GetList("OrderId='" + id + "'").Tables[0].Rows[0]["Id"]));
                }
                if (ok == 1)//有效
                {
                    QPS.NEW.BLL.Room   Broom = new QPS.NEW.BLL.Room();
                    QPS.NEW.Model.Room r     = Broom.GetModel(order.Roomid);
                    //Mint.OrderId = Convert.ToInt32(id);
                    //Mint.RoomId = order.Roomid;
                    Mint.UserID = order.Userid;
                    //Mint.CreateTime = order.StartTime;
                    TimeSpan ts = (TimeSpan)(order.endTime - order.StartTime);
                    Mint.BankMoney = Convert.ToInt32((ts.Hours * (double)r.RoomPrice));
                    if (order.Beveragecost != null)
                    {
                        Mint.BankMoney += (int)order.Beveragecost;
                    }
                    Bint.Add(Mint);
                }
            }
            gdvOrder.DataSource = databind();
            gdvOrder.DataBind();
        }
Esempio n. 11
0
        public string getResult(string action)
        {
            switch (action)
            {
            case "register":
                if (validate("register"))
                {
                    Muser.Username = ht["username"].ToString();
                    Muser.Nickname = ht["nickname"].ToString();
                    Muser.Password = ht["password"].ToString();
                    Muser.Sign     = "";
                    Muser.Usertype = 0;
                    if (Buser.Add(Muser) > 0)
                    {
                        return("true");
                    }
                    else
                    {
                        return("false");
                    }
                }
                else
                {
                    return("false");
                }

            case "login":
                if (validate("login"))
                {
                    if (Buser.Denglu(ht["username"].ToString(), ht["password"].ToString()))
                    {
                        Session["username"] = ht["username"].ToString();
                        return("true");
                    }
                    else
                    {
                        return("false");
                    }
                }
                else
                {
                    return("false");
                }

            case "score":
                if (validate("score"))
                {
                    string  uname  = ht["username"].ToString();
                    DataSet dsUser = Buser.GetList("Username='******'");
                    userid = Convert.ToInt32(dsUser.Tables[0].Rows[0]["Id"]);
                    QPS.NEW.Model.Integral u = BInt.GetModel(userid);

                    if (u.TotalMoney == (int)ht["originalscore"])
                    {
                        u.TotalMoney = +(int)ht["score"];
                        if (BInt.Update(u))
                        {
                            return("true");
                        }
                        else
                        {
                            return("fales");
                        }
                    }
                    else
                    {
                        return("false");
                    }
                }
                else
                {
                    return("false");
                }

            case "editpwd":
                if (validate("editpwd"))
                {
                    string  uname  = ht["username"].ToString();
                    DataSet dsUser = Buser.GetList("Username='******'");
                    userid = Convert.ToInt32(dsUser.Tables[0].Rows[0]["Id"]);
                    QPS.NEW.Model.Users u = Buser.GetModel(userid);
                    u.Password = ht["newpassword"].ToString();
                    if (Buser.Update(u))
                    {
                        return("true");
                    }
                    else
                    {
                        return("false");
                    }
                }
                else
                {
                    return("false");
                }

            case "logout":
                if (validate("logout"))
                {
                    if (Session["username"] != null)
                    {
                        Session.Remove("username");
                        return("true");
                    }
                    else
                    {
                        return("false");
                    }
                }
                else
                {
                    return("false");
                }

            default: return("false");
            }
        }