Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int              gid, roomType, bedType;
            CheckInBLL       ckbll            = new CheckInBLL();
            ServiceOrderBLL  orderBLL         = new ServiceOrderBLL();
            GuestRoomInfoBLL guestRoomInfoBLL = new GuestRoomInfoBLL();

            if (!IsPostBack)
            {
                if (Request.QueryString["uid"] == null)
                {
                    ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "login", "<script>notlogined();</script>");
                    return;
                }
                uid = Request.QueryString["uid"];

                if (ckbll.GetModelList("Uid = " + uid + " and (CheckinStatus = 0 or CheckinStatus = 1 or CheckinStatus = 2)").Count != 0)
                {
                    gid = ckbll.GetModelList("Uid = " + uid + " and (CheckinStatus = 0 or CheckinStatus = 1 or CheckinStatus = 2)")[0].Gid;

                    GuestRoomInfoBLL roomInfoBLL = new GuestRoomInfoBLL();
                    roomType = roomInfoBLL.GetModelList("Gid = " + gid)[0].RoomType;
                    bedType  = roomInfoBLL.GetModelList("Gid = " + gid)[0].BedType;

                    if (roomType == 0)
                    {
                        if (bedType == 0)
                        {
                            Content = "单人房-硬板床-" + gid.ToString();
                        }
                        else
                        {
                            Content = "单人房-软榻床-" + gid.ToString();
                        }
                    }
                    else if (roomType == 1)
                    {
                        if (bedType == 0)
                        {
                            Content = "双人房-硬板床-" + gid.ToString();
                        }
                        else
                        {
                            Content = "双人房-软榻床-" + gid.ToString();
                        }
                    }
                    else if (roomType == 2)
                    {
                        if (bedType == 1)
                        {
                            Content = "总统套房-软榻床-" + gid.ToString();
                        }
                        else
                        {
                            Content = "总统套房-大圆床-" + gid.ToString();
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(Request["postTag"]))
            {
                if (Request["postTag"] == "checkout")
                {
                    uid = Request.QueryString["uid"];

                    bool hasOrder2Cancel = ckbll.GetModelList("Uid = " + uid + " and (CheckinStatus = 0 or CheckinStatus = 1 or CheckinStatus = 2)").Count == 0 ? false : true;
                    if (!hasOrder2Cancel)
                    {
                        Response.Write(-1);
                        Response.End();
                    }

                    bool hasOutTime = ckbll.GetModelList("Uid = " + uid + " and (CheckinStatus = -2 or CheckinStatus = 1 or CheckinStatus = 2)").Count == 0 ? false : true;
                    if (!hasOrder2Cancel)
                    {
                        Response.Write(-1);
                        Response.End();
                    }
                    // 客房状态改为4-需要保洁
                    GuestRoomInfo guestRoom = guestRoomInfoBLL.GetModelList("Gid = " + ckbll.GetModelList("Uid = " + uid + " and (CheckinStatus = 0 or CheckinStatus = 1 or CheckinStatus = 2)")[0].Gid)[0];
                    guestRoom.GStatus = 4;
                    guestRoomInfoBLL.Update(guestRoom);

                    // 修改住房信息订单状态码为-3(用户取消)
                    CheckIn ck = ckbll.GetModelList("Uid = " + uid + " and (CheckinStatus = 0 or CheckinStatus = 1 or CheckinStatus = 2)")[0];
                    ck.CheckinStatus = -3;
                    ckbll.Update(ck);

                    // 修改额外服务订单状态码
                    ServiceOrder svorder = orderBLL.GetModelList("Uid = " + uid + " and (esOrderStatus = 0 or esOrderStatus = 1 or esOrderStatus = 2)")[0];
                    // 如果额外服务还没有提供,那么退房的时候应该取消放货,状态码置为-3
                    if (svorder.esOrderStatus == 0 || svorder.esOrderStatus == 1)
                    {
                        string orderContent = svorder.esOrderContent;
                        if (orderContent != "")
                        {
                            ExServiceBLL esbll = new ExServiceBLL();
                            foreach (string tmp in orderContent.Split(','))
                            {
                                ExService es = esbll.GetModelList("GoodsName = '" + tmp.Split('*')[0] + "'")[0];
                                es.GoodsStock += int.Parse(tmp.Split('*')[1]);
                                esbll.Update(es);
                            }
                        }
                        svorder.esOrderStatus = -3;
                        orderBLL.Update(svorder);
                    }
                    Response.Write(1);
                    Response.End();
                }
            }
        }
Exemple #2
0
        public void ReserveEs(int _uid, long _cid, string GoodsStr, bool firstes)
        {
            // 从前台获取到的物品数据拼接字符串
            string splitGoodsArr = GoodsStr;

            // 将每一组数据从数组中分割出来
            string[]           settleGoodsItem = splitGoodsArr.Split(';');
            string[]           settleGoodsItemInfo;
            List <settleGoods> goodsList = new List <settleGoods>();

            //string[][] goodsInfo = new string[6][];

            // 将每一组的每一个数据从字符串中分割出来
            for (int i = 0; i < settleGoodsItem.Length; i++)
            {
                settleGoodsItemInfo = settleGoodsItem[i].Split(',');
                goodsList.Add(new settleGoods(int.Parse(settleGoodsItemInfo[0]), settleGoodsItemInfo[1], float.Parse(settleGoodsItemInfo[3]), int.Parse(settleGoodsItemInfo[4])));
            }

            int   goodsCount = settleGoodsItem.Length;
            float TotalPrice = 0.0f;

            for (int p = 0; p < goodsCount; p++)
            {
                TotalPrice += (goodsList[p].GoodsPrice * float.Parse(goodsList[p].PurchaseCount.ToString()));
                ExService es = exsBll.GetModel(goodsList[p].GoodsId);
                es.GoodsStock -= goodsList[p].PurchaseCount;
                exsBll.Update(es);
            }

            ServiceOrderBLL orderBLL = new ServiceOrderBLL();
            ServiceOrder    order    = orderBLL.GetModel(
                decimal.Parse(orderBLL.GetList("Uid = " + _uid + " and (esOrderStatus = 0 or esOrderStatus = 1 or esOrderStatus = 2)").Tables[0].Rows[0][0].ToString())
                );

            if (firstes)
            {
                order.esOrderTotalPrice = decimal.Parse(TotalPrice.ToString());
                for (int p = 0; p < goodsCount; p++)
                {
                    if (p != goodsCount - 1)
                    {
                        order.esOrderContent += (goodsList[p].GoodsName + "*" + goodsList[p].PurchaseCount + ",");
                    }
                    else
                    {
                        order.esOrderContent += (goodsList[p].GoodsName + "*" + goodsList[p].PurchaseCount);
                    }
                }
            }
            else
            {
                order.esOrderTotalPrice += decimal.Parse(TotalPrice.ToString());
                string oldesOrderContent = order.esOrderContent;

                if (oldesOrderContent != "")
                {
                    string newOrderContent = string.Empty;
                    // 获取订单内容中已有的Goods信息
                    string[] oldesOrderContentItemInfos = oldesOrderContent.Split(',');
                    int      oldesOrderContentItemCount = oldesOrderContentItemInfos.Length;

                    string[][] oldesOrderGoodsInfos = new string[oldesOrderContentItemCount][];

                    for (int b = 0; b < oldesOrderContentItemCount; b++)
                    {
                        oldesOrderGoodsInfos[b] = oldesOrderContentItemInfos[b].Split('*');
                    }// 此时该订单的已有订单内容已被解析出来

                    List <int> sameItemIndex = new List <int>();

                    // 获取已有订单中,相同Goods的索引
                    for (int n = 0; n < oldesOrderContentItemCount; n++)
                    {
                        for (int p = 0; p < goodsCount; p++)
                        {
                            // 如果该订单已有订单内容中包含新增的此Goods,那么直接将数量+1即可
                            if (goodsList[p].GoodsName == oldesOrderGoodsInfos[n][0])
                            {
                                sameItemIndex.Add(n);
                                break;
                            }
                        }
                    }
                    // 获取到了之前订单内容和新订单中相同Goods老订单中的索引
                    bool isOldSame = false;
                    for (int p = 0; p < oldesOrderContentItemCount; p++)
                    {
                        for (int c = 0; c < sameItemIndex.Count; c++)
                        {
                            if (p == sameItemIndex[c])
                            {
                                isOldSame = true;
                                break;
                            }
                        }
                        if (isOldSame)
                        {
                            for (int k = 0; k < goodsCount; k++)
                            {
                                if (oldesOrderGoodsInfos[p][0] == goodsList[k].GoodsName)
                                {
                                    if (p == oldesOrderContentItemCount - 1)
                                    {
                                        newOrderContent += (oldesOrderGoodsInfos[p][0] + "*" + (goodsList[k].PurchaseCount + int.Parse(oldesOrderGoodsInfos[p][1])));
                                    }
                                    else
                                    {
                                        newOrderContent += (oldesOrderGoodsInfos[p][0] + "*" + (goodsList[k].PurchaseCount + int.Parse(oldesOrderGoodsInfos[p][1])) + ",");
                                    }
                                }
                            }
                            isOldSame = false;
                        }
                        else
                        {
                            if (p == oldesOrderContentItemCount - 1)
                            {
                                newOrderContent += (oldesOrderGoodsInfos[p][0] + "*" + oldesOrderGoodsInfos[p][1]);
                            }
                            else
                            {
                                newOrderContent += (oldesOrderGoodsInfos[p][0] + "*" + oldesOrderGoodsInfos[p][1] + ",");
                            }
                        }
                    }

                    bool hasSame = false;
                    for (int p = 0; p < goodsCount; p++)
                    {
                        for (int k = 0; k < oldesOrderContentItemCount; k++)
                        {
                            if (goodsList[p].GoodsName == oldesOrderGoodsInfos[k][0])
                            {
                                hasSame = true;
                                break;
                            }
                        }
                        if (hasSame)
                        {
                            hasSame = false;
                            continue;
                        }
                        else
                        {
                            newOrderContent += ("," + goodsList[p].GoodsName + "*" + goodsList[p].PurchaseCount);
                        }
                    }

                    order.esOrderContent = newOrderContent;
                }
                else // 之前就是空的订单内容
                {
                    for (int p = 0; p < goodsCount; p++)
                    {
                        if (p != goodsCount - 1)
                        {
                            order.esOrderContent += (goodsList[p].GoodsName + "*" + goodsList[p].PurchaseCount + ",");
                        }
                        else
                        {
                            order.esOrderContent += (goodsList[p].GoodsName + "*" + goodsList[p].PurchaseCount);
                        }
                    }
                }
            }

            bool res1 = orderBLL.Update(order);

            CheckInBLL ckBll   = new CheckInBLL();
            CheckIn    checkin = ckBll.GetModel(_cid);

            checkin.cTotalPrice += decimal.Parse(TotalPrice.ToString());
            bool res2 = ckBll.Update(checkin);

            if (res1 && res2)
            {
                Response.Write(1);
                Response.End();
            }
            else
            {
                Response.Write(-1);
                Response.End();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                gsCount = esbll.GetModelList("").Count;
                if (gsCount % 5 == 0)
                {
                    gsMaxPage = gsCount / 5;
                }
                else
                {
                    gsMaxPage = gsCount / 5 + 1;
                }
            }

            // 页面加载时获取Goods信息
            if (!string.IsNullOrEmpty(Request["postTag"]))
            {
                if (Request["postTag"] == "load")
                {
                    string sqlStrByPage = "select * from (" +
                                          " select ROW_NUMBER() over(order by GoodsID ASC) AS Row, * from ExService) T" +
                                          " where T.Row between 1 and 5";
                    Response.Write(Get_Serialize_Data_FromSql(connectString, sqlStrByPage));
                    Response.End();
                }
            }

            // Ajax分页获取Goods信息
            if (!string.IsNullOrEmpty(Request["postTag"]))
            {
                if (Request["postTag"] == "gsByPage")
                {
                    gsNowPage = int.Parse(Request["gsNowPage"]);
                    StringBuilder sqlPage = new StringBuilder();
                    sqlPage.AppendFormat("select * from (" +
                                         " select ROW_NUMBER() over(order by GoodsID ASC) AS Row, * from ExService) T" +
                                         " where T.Row between {0} and {1}", (gsNowPage - 1) * 5 + 1, gsNowPage * 5);

                    Response.Write(Get_Serialize_Data_FromSql(connectString, sqlPage.ToString()));
                    Response.End();
                }
            }

            // 修改Goods信息
            if (!string.IsNullOrEmpty(Request["postTag"]))
            {
                if (Request["postTag"] == "update")
                {
                    int    gsid    = int.Parse(Request["gsid"]);
                    string gsname  = Request["gsname"];
                    float  gsprice = float.Parse(Request["gsprice"]);
                    int    gsstock = int.Parse(Request["gsstock"]);

                    ExService es = esbll.GetModel(gsid);
                    es.GoodsName  = gsname;
                    es.GoodsPrice = decimal.Parse(gsprice.ToString());
                    es.GoodsStock = gsstock;
                    esbll.Update(es);

                    Response.Write(1);
                    Response.End();
                }
            }

            // 上架或下架Goods信息
            if (!string.IsNullOrEmpty(Request["postTag"]))
            {
                if (Request["postTag"] == "lowershelf")
                {
                    int       gsid    = int.Parse(Request["gsid"]);
                    int       gsstock = int.Parse(Request["gsstock"]);
                    int       tag     = int.Parse(Request["tag"]);
                    ExService es      = esbll.GetModel(gsid);
                    if (tag == 1)
                    {
                        es.GoodsStock = gsstock;
                    }
                    es.GoodsStatus = es.GoodsStatus == 0 ? 1 : 0;
                    esbll.Update(es);

                    Response.Write(1);
                    Response.End();
                }
            }
        }