Esempio n. 1
0
        protected void gdvOrder_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //得到单位编号
            string rowToDelete = this.gdvOrder.DataKeys[e.RowIndex].Values[0].ToString();
            //转换为整数
            int ID = Convert.ToInt32(rowToDelete);

            QPS.NEW.BLL.Orderform   Border = new QPS.NEW.BLL.Orderform();
            QPS.NEW.Model.Orderform morder = Border.GetModel(ID);
            morder.IsDelete = 1;
            Border.Update(morder);
            gdvOrder.DataSource = databind();
            gdvOrder.DataBind();
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            orderid = Convert.ToInt32(Request.QueryString["id"]);
            QPS.NEW.BLL.Orderform   Border = new QPS.NEW.BLL.Orderform();
            QPS.NEW.Model.Orderform Morder = Border.GetModel(orderid);
            QPS.NEW.BLL.Users       u      = new QPS.NEW.BLL.Users();
            QPS.NEW.BLL.Room        r      = new QPS.NEW.BLL.Room();
            int roomid = (int)Morder.Roomid;
            int userid = (int)Morder.Userid;

            txfRoomName.Value = r.GetModel(roomid).Name;
            txfUserName.Value = u.GetModel(userid).Username;
            //txfBeverageCost.Text =Border.GetModel(orderid).Beveragecost.ToString();
            txfOrderId.Value = orderid.ToString();
        }
Esempio n. 3
0
 protected void btnCreate_Click(object sender, EventArgs e)
 {
     try
     { //转换为整数
         int ID = Convert.ToInt32(orderid);
         QPS.NEW.BLL.Orderform   Border = new QPS.NEW.BLL.Orderform();
         QPS.NEW.Model.Orderform order  = Border.GetModel(ID);
         order.Beveragecost = Convert.ToDecimal(txfBeverageCost.Text);
         if (Border.Update(order))
         {
             Response.Write("<script>alert('订单修改成功!')</script>");
             Response.Write("<script>window.close()</script>");
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('订单修改失败!')</script>");
     }
 }
Esempio n. 4
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. 5
0
        public bool Update(QPS.NEW.Model.Orderform model)
        {
            bool res = false;

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

            if (model.Id == -999)
            {
                return(false);
            }

            if (model.Id != -999)
            {
                filedName[Count] = "Id";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.Id);
                Count++;
            }
            if (model.OrderNumber != null)
            {
                filedName[Count] = "OrderNumber";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.OrderNumber);
                Count++;
            }
            if (model.StartTime != null)
            {
                filedName[Count] = "StartTime";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.StartTime);
                Count++;
            }
            if (model.endTime != null)
            {
                filedName[Count] = "endTime";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.endTime);
                Count++;
            }
            if (model.Userid != -999)
            {
                filedName[Count] = "Userid";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.Userid);
                Count++;
            }
            if (model.Roomid != -999)
            {
                filedName[Count] = "Roomid";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.Roomid);
                Count++;
            }
            if (model.RoomType != null)
            {
                filedName[Count] = "RoomType";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.RoomType);
                Count++;
            }
            if (model.Beveragecost != null)
            {
                filedName[Count] = "Beveragecost";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.Beveragecost);
                Count++;
            }
            if (model.IsDelete != -999)
            {
                filedName[Count] = "IsDelete";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.IsDelete);
                Count++;
            }
            if (model.IsValidity != null)
            {
                filedName[Count] = "IsValidity";
                paramName[Count] = "@" + filedName[Count];
                sqlParams[Count] = new SqlParameter(paramName[Count], model.IsValidity);
                Count++;
            }

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Orderform set ");
            for (int i = 1; i < Count; i++)    // i begin with 0 !!!
            {
                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. 6
0
        public QPS.NEW.Model.Orderform GetModel(int Id)
        {
            QPS.NEW.Model.Orderform orderform = null;

            DataTable dt = sqlHelper_.GetDataTable(
                "select * from Orderform where Id=@id",
                CommandType.Text,
                new System.Data.SqlClient.SqlParameter[]
            {
                new SqlParameter("@id", Id)
            }
                );

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

                orderform.Id          = Convert.ToInt32(dt.Rows[0]["Id"]);
                orderform.OrderNumber = dt.Rows[0]["OrderNumber"].ToString();
                if (dt.Rows[0]["StartTime"] == DBNull.Value)
                {
                    orderform.StartTime = null;
                }
                else
                {
                    orderform.StartTime = Convert.ToDateTime(dt.Rows[0]["StartTime"]);
                }

                if (dt.Rows[0]["endTime"] == DBNull.Value)
                {
                    orderform.endTime = null;
                }
                else
                {
                    orderform.endTime = Convert.ToDateTime(dt.Rows[0]["endTime"]);
                }

                orderform.Userid = Convert.ToInt32(dt.Rows[0]["Userid"]);


                orderform.Roomid = Convert.ToInt32(dt.Rows[0]["Roomid"]);

                if (dt.Rows[0]["RoomType"] == DBNull.Value)
                {
                    orderform.RoomType = null;
                }
                else
                {
                    orderform.RoomType = Convert.ToInt32(dt.Rows[0]["RoomType"]);
                }

                if (dt.Rows[0]["Beveragecost"] == DBNull.Value)
                {
                    orderform.Beveragecost = null;
                }
                else
                {
                    orderform.Beveragecost = Convert.ToDecimal(dt.Rows[0]["Beveragecost"]);
                }

                orderform.IsDelete = Convert.ToInt32(dt.Rows[0]["IsDelete"]);

                if (dt.Rows[0]["IsValidity"] == DBNull.Value)
                {
                    orderform.IsValidity = null;
                }
                else
                {
                    orderform.IsValidity = Convert.ToInt32(dt.Rows[0]["IsValidity"]);
                }
            }

            return(orderform);
        }
Esempio n. 7
0
        public int Add(QPS.NEW.Model.Orderform model)
        {
            int  res       = 0;
            bool isOrdered = false;

            string strSql =
                "select count(*) from Orderform where Roomid=@roomid and IsDelete=0 and IsValidity=1";
            int num = Convert.ToInt32(
                sqlHelper_.GetSingle(
                    strSql,
                    CommandType.Text,
                    new System.Data.SqlClient.SqlParameter[]
            {
                new System.Data.SqlClient.SqlParameter("@roomid", model.Roomid)
            }
                    )
                );

            if (num > 0)
            {
                isOrdered = true;
            }

            if (num < 0)
            {
                res = -1;
                throw new Exception("Error:查询数据库失败");
            }

            if (isOrdered)
            {
                res = -1;
                throw new Exception("Error:房间已被预定");
            }
            else
            {
                string[]       filedName = new string[50];
                string[]       paramName = new string[50];
                SqlParameter[] sqlParams = new SqlParameter[50];
                int            Count     = 0;


                if (model.OrderNumber != null)
                {
                    filedName[Count] = "OrderNumber";
                    paramName[Count] = "@" + filedName[Count];
                    sqlParams[Count] = new SqlParameter(paramName[Count], model.OrderNumber);
                    Count++;
                }
                if (model.StartTime != null)
                {
                    filedName[Count] = "StartTime";
                    paramName[Count] = "@" + filedName[Count];
                    sqlParams[Count] = new SqlParameter(paramName[Count], model.StartTime);
                    Count++;
                }
                if (model.endTime != null)
                {
                    filedName[Count] = "endTime";
                    paramName[Count] = "@" + filedName[Count];
                    sqlParams[Count] = new SqlParameter(paramName[Count], model.endTime);
                    Count++;
                }
                if (model.Userid != -999)
                {
                    filedName[Count] = "Userid";
                    paramName[Count] = "@" + filedName[Count];
                    sqlParams[Count] = new SqlParameter(paramName[Count], model.Userid);
                    Count++;
                }
                if (model.Roomid != -999)
                {
                    filedName[Count] = "Roomid";
                    paramName[Count] = "@" + filedName[Count];
                    sqlParams[Count] = new SqlParameter(paramName[Count], model.Roomid);
                    Count++;
                }
                if (model.RoomType != null)
                {
                    filedName[Count] = "RoomType";
                    paramName[Count] = "@" + filedName[Count];
                    sqlParams[Count] = new SqlParameter(paramName[Count], model.RoomType);
                    Count++;
                }
                if (model.Beveragecost != null)
                {
                    filedName[Count] = "Beveragecost";
                    paramName[Count] = "@" + filedName[Count];
                    sqlParams[Count] = new SqlParameter(paramName[Count], model.Beveragecost);
                    Count++;
                }
                if (model.IsDelete != -999)
                {
                    filedName[Count] = "IsDelete";
                    paramName[Count] = "@" + filedName[Count];
                    sqlParams[Count] = new SqlParameter(paramName[Count], model.IsDelete);
                    Count++;
                }
                if (model.IsValidity != null)
                {
                    filedName[Count] = "IsValidity";
                    paramName[Count] = "@" + filedName[Count];
                    sqlParams[Count] = new SqlParameter(paramName[Count], model.IsValidity);
                    Count++;
                }



                StringBuilder strSql_bs = new StringBuilder();
                strSql_bs.Append("insert into Orderform(");
                for (int i = 0; i < Count; i++)
                {
                    strSql_bs.Append(filedName[i]);
                    if (i != Count - 1)
                    {
                        strSql_bs.Append(",");
                    }
                }
                strSql_bs.Append(")values(");
                for (int i = 0; i < Count; i++)
                {
                    strSql_bs.Append(paramName[i]);
                    if (i != Count - 1)
                    {
                        strSql_bs.Append(",");
                    }
                }
                strSql_bs.Append(")");



                num = sqlHelper_.ExecuteCommand(
                    strSql_bs.ToString(),
                    CommandType.Text,
                    sqlParams
                    );
                if (num != 1)
                {
                    res = -1;
                    throw new Exception("Error:写入数据库失败");
                }
                else
                {
                    res = 1;
                }
            }


            return(res);
        }