Beispiel #1
0
        public void handler(IResponder responder)
        {
            string dateStr = SJSRequest.GetString("Date");

            DateTime dt = DateTime.Now;

            if (string.IsNullOrEmpty(dateStr) == false)
            {
                dt = Convert.ToDateTime(dateStr);
            }

            IList <Bookingshop> list;

            if (User.IsAdministrator(PageUtils.Utype))
            {
                list = BookingshopManager.GetBookingshop(dt);
            }
            else
            {
                list = BookingshopManager.GetBookingshop(dt, false);
            }

            string json = PageUtils.TranformJSON(list);

            responder.WriteSuccessed(json);
        }
Beispiel #2
0
        public void handler(IResponder responder)
        {
            Bookingshop bookingshop = new Bookingshop();

            bookingshop.Bookingid   = SJSRequest.GetInt("Bookingid", 0);
            bookingshop.Bookingname = SJSRequest.GetString("Bookingname");
            bookingshop.Shopid      = SJSRequest.GetInt("Shopid", 0);
            bookingshop.Shopname    = SJSRequest.GetString("Shopname");
            bookingshop.Uid         = PageUtils.AccountID;
            bookingshop.Realname    = PageUtils.RealName.Trim();
            bookingshop.Isover      = false;
            //bookingshop.Begintime = DateTime.Now;// DateTime.UtcNow;

            if (bookingshop.Bookingid <= 0)
            {
                responder.WriteErroredMsg("预订参数错误!");
                return;
            }

            if (bookingshop.Shopid <= 0)
            {
                responder.WriteErroredMsg("店铺参数错误!");
                return;
            }

            Booking booking = BookingManager.GetBooking(bookingshop.Bookingid);

            if (booking == null)
            {
                responder.WriteErroredMsg("此预订不存在,无法加入!");
                return;
            }

            if (booking.Isbooking == false)
            {
                responder.WriteErroredMsg("此预订已结束,无法加入!");
                return;
            }

            Bookingshop confirm = BookingshopManager.GetBookingshop(bookingshop.Bookingid, bookingshop.Shopid, bookingshop.Uid);

            if (confirm != null)
            {
                responder.WriteErroredMsg("此店铺已存在于" + bookingshop.Bookingname + "的店铺列表,无法再次加入预订!");
                return;
            }

            bookingshop.Begintime = booking.Bookingtime;

            int rlt = BookingshopManager.AddBookingshop(bookingshop);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("店铺预订加入失败,数据库写入不成功!");
                return;
            }

            responder.WriteSuccessedMsg("加入预订成功!");
        }
Beispiel #3
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Shop shop = ShopManager.GetShop(id);

            if (shop == null)
            {
                responder.WriteErroredMsg("此店铺不存在,无法删除!");
                return;
            }

            int hasBookingCount = BookingshopManager.GetBookingshop(shop.Id, false, true);

            if (hasBookingCount > 0)
            {
                responder.WriteErroredMsg("此店铺正在接受预订,无法删除!");
                return;
            }

            using (DbTransaction trans = DbHelper.BeginTransaction())
            {
                bool writeError = false;
                try
                {
                    int rlt = ShopManager.DelShop(id, trans);

                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("店铺删除失败,数据库更新不成功!");
                        return;
                    }

                    TradeManager.DelTrade(id, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    if (writeError == false)
                    {
                        responder.WriteErroredMsg("店铺删除失败,程序异常!");
                    }
                    return;
                }
            }

            responder.WriteSuccessedMsg("店铺删除成功!");
        }
Beispiel #4
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Booking booking = BookingManager.GetBooking(id);

            if (booking == null)
            {
                responder.WriteErroredMsg("不存在此预订, 无法结束预订!");
                return;
            }

            if (booking.Isbooking == false)
            {
                responder.WriteErroredMsg("此预订已经结束,无法重复结束!");
                return;
            }

            if (booking.Uid != PageUtils.AccountID)
            {
                responder.WriteErroredMsg("没有权限结束其他人的预订!");
                return;
            }

            booking.Isbooking = false;

            int rlt = BookingManager.UpdateBooking(booking);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("结束预订失败,数据库更新不成功!");
                return;
            }

            IList <Bookingshop> list = BookingshopManager.GetBookingshop(booking.Id, true);

            foreach (Bookingshop item in list)
            {
                item.Isover = true;
                BookingshopManager.UpdateBookingshop(item);
            }

            BookingtradeManager.UpdateBookingtrade(booking.Id, !booking.Isbooking);

            responder.WriteSuccessedMsg("结束预订成功!");
        }
Beispiel #5
0
        public void handler(IResponder responder)
        {
            int bookingId = SJSRequest.GetInt("Bookingid", 0);

            //if (bookingId <= 0)
            //{
            //    responder.WriteErroredMsg("请求参数错误!");
            //    return;
            //}

            IList <Bookingshop> list = BookingshopManager.GetBookingshop(bookingId, true);

            string json = PageUtils.TranformJSON(list);

            responder.WriteSuccessed(json);
        }
Beispiel #6
0
        public void handler(IResponder responder)
        {
            string dateStr = SJSRequest.GetString("Date");

            DateTime dt = DateTime.Now;

            if (string.IsNullOrEmpty(dateStr) == false)
            {
                dt = Convert.ToDateTime(dateStr);
            }
            //IList<Bookingshop> list = BookingshopManager.GetBookingshop(dt, PageUtils.AccountID);
            IList <Bookingshop> list = BookingshopManager.GetBookingshop(dt, 0);

            string json = PageUtils.TranformJSON(list);

            responder.WriteSuccessed(json);
        }
Beispiel #7
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Trade trade = TradeManager.GetTrade(id);

            if (trade == null)
            {
                responder.WriteErroredMsg("此菜单不存在,无法修改!");
                return;
            }

            int hasBookingCount = BookingshopManager.GetBookingshop(trade.Shopid, false, true);

            if (hasBookingCount > 0)
            {
                responder.WriteErroredMsg("此店铺正在接受预订,无法修改此菜单!");
                return;
            }

            trade.Tradename  = SJSRequest.GetString("Tradename");
            trade.Tradevalue = SJSRequest.GetFloat("Tradevalue", 0);

            if (string.IsNullOrEmpty(trade.Tradename))
            {
                responder.WriteErroredMsg("菜单名称不能为空!");
                return;
            }

            int rlt = TradeManager.UpdateTrade(trade);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("菜单修改失败,数据库更新不成功!");
                return;
            }

            responder.WriteSuccessedMsg("修改菜单成功!");
        }
Beispiel #8
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Shop shop = ShopManager.GetShop(id);

            if (shop == null)
            {
                responder.WriteErroredMsg("此店铺不存在,无法修改!");
                return;
            }

            int hasBookingCount = BookingshopManager.GetBookingshop(shop.Id, false, true);

            if (hasBookingCount > 0)
            {
                responder.WriteErroredMsg("此店铺正在接受预订,无法修改!");
                return;
            }

            shop.Shopname = SJSRequest.GetString("Shopname");
            shop.Phone    = SJSRequest.GetString("Phone");

            if (string.IsNullOrEmpty(shop.Shopname))
            {
                responder.WriteErroredMsg("店铺名称不能为空!");
                return;
            }

            int rlt = ShopManager.UpdateShop(shop);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("店铺修改失败,数据库更新不成功!");
                return;
            }

            responder.WriteSuccessedMsg("修改店铺成功!");
        }
Beispiel #9
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Trade trade = TradeManager.GetTrade(id);

            if (trade == null)
            {
                responder.WriteErroredMsg("此菜单不存在,无法删除!");
                return;
            }

            int hasBookingCount = BookingshopManager.GetBookingshop(trade.Shopid, false, true);

            if (hasBookingCount > 0)
            {
                responder.WriteErroredMsg("此店铺正在接受预订,无法删除此菜单!");
                return;
            }

            int rlt = TradeManager.DelTrade(id);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("菜单删除失败,数据库数据更新不成功!");
                return;
            }

            responder.WriteSuccessedMsg("菜单删除成功!");
        }
        public void handler(IResponder responder)
        {
            int          withUid      = SJSRequest.GetInt("WithUid", 0);
            Bookingtrade bookingtrade = new Bookingtrade();

            bookingtrade.Tradeid       = SJSRequest.GetInt("Tradeid", 0);
            bookingtrade.Bookingshopid = SJSRequest.GetInt("Id", 0);
            bookingtrade.Tradecount    = SJSRequest.GetInt("Tradecount", 0);
            //bookingtrade.Remarks = SJSRequest.GetString("Remarks");

            if (bookingtrade.Tradecount <= 0)
            {
                responder.WriteErroredMsg("预订数量只能是正数!");
                return;
            }

            if (bookingtrade.Tradeid <= 0)
            {
                responder.WriteErroredMsg("菜单项请求参数错误!");
                return;
            }

            if (bookingtrade.Bookingshopid <= 0)
            {
                responder.WriteErroredMsg("预订店铺记录请求参数错误!");
                return;
            }

            Bookingshop bookingshop = BookingshopManager.GetBookingshop(bookingtrade.Bookingshopid);

            if (bookingshop == null)
            {
                responder.WriteErroredMsg("此店铺接受预订记录不存在,无法预订!");
                return;
            }

            Booking booking = BookingManager.GetBooking(bookingshop.Bookingid);

            if (booking == null)
            {
                responder.WriteErroredMsg("此预订不存在,无法预订!");
                return;
            }

            if (booking.Isbooking == false && User.IsAdministrator(PageUtils.Utype) == false)
            {
                responder.WriteErroredMsg("此预订已结束,无法预订!");
                return;
            }

            Trade trade = TradeManager.GetTrade(bookingtrade.Tradeid);

            if (trade == null)
            {
                responder.WriteErroredMsg("不存在此菜单项,无法预订!");
                return;
            }

            IList <Bookingtrade> confirmList = BookingtradeManager.GetBookingtrade(bookingshop.Id, trade.Id, true);

            Bookingtrade confirm = null;

            int    uid   = PageUtils.AccountID;
            string rname = PageUtils.RealName;

            for (int i = 0; i < confirmList.Count; i++)
            {
                if (withUid > 0 && withUid == confirmList[i].Uid)
                {
                    confirm = confirmList[i];
                    break;
                }

                if (withUid <= 0 && uid == confirmList[i].Uid)
                {
                    confirm = confirmList[i];
                    break;
                }
            }

            int  rlt   = 0;
            bool isAdd = false;

            using (DbTransaction trans = DbHelper.BeginTransaction())
            {
                bool writeError = false;
                try
                {
                    User      user       = null;
                    Deduction deduction  = new Deduction();
                    int       addedCount = 0;
                    if (confirm != null && (withUid <= 0 || withUid == confirm.Uid))
                    {
                        addedCount = bookingtrade.Tradecount;

                        user = UserManager.GetUser(confirm.Uid, trans);

                        if (user == null)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg("不存在此用户,无法预订!");
                            return;
                        }


                        if (user.Enabled == false)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg(user.Realname + " 处于禁用状态,无法预订!");
                            return;
                        }


                        uid   = user.Uid;
                        rname = user.Realname;

                        deduction.Deductionbalance = user.Balance - confirm.Tradevalue * addedCount;
                        deduction.Deductioncount   = addedCount;
                        deduction.Deductionname    = string.Format("预订{0}", confirm.Tradename);
                        deduction.Deductiontime    = DateTime.Now;
                        deduction.Deductionvalue   = -confirm.Tradevalue * addedCount;
                        deduction.Uid      = confirm.Uid;
                        deduction.Realname = confirm.Realname;
                        deduction.Shopid   = confirm.Shopid;
                        deduction.Shopname = confirm.Shopname;
                        deduction.Remarks  = confirm.Remarks;

                        confirm.Tradecount += addedCount;
                        bookingtrade        = confirm;

                        isAdd = false;
                    }
                    else
                    {
                        if (withUid > 0 && uid != withUid)
                        {
                            user = UserManager.GetUser(withUid, trans);
                        }
                        else
                        {
                            user = UserManager.GetUser(uid, trans);
                        }

                        if (user == null)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg("不存在此用户,无法预订!");
                            return;
                        }


                        if (user.Enabled == false)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg(user.Realname + " 处于禁用状态,无法预订!");
                            return;
                        }


                        if (withUid > 0)
                        {
                            bookingtrade.Proxyid   = uid;
                            bookingtrade.Proxyname = rname;
                            bookingtrade.Remarks  += string.Format("由 {0} 代订", rname.Trim());
                        }

                        uid   = user.Uid;
                        rname = user.Realname;

                        bookingtrade.Bookingid   = booking.Id;
                        bookingtrade.Bookingname = booking.Bookingname;
                        bookingtrade.Handlerid   = bookingshop.Uid;
                        bookingtrade.Handlername = bookingshop.Realname;
                        bookingtrade.Uid         = uid;
                        bookingtrade.Realname    = rname;
                        bookingtrade.Shopid      = bookingshop.Shopid;
                        bookingtrade.Shopname    = bookingshop.Shopname;
                        bookingtrade.Tradename   = trade.Tradename;
                        bookingtrade.Tradevalue  = trade.Tradevalue;
                        bookingtrade.Issettle    = booking.Isbooking == false;
                        bookingtrade.Bookinttime = DateTime.Now;

                        if (booking.Bookingtime.Date.Equals(DateTime.Now.Date) == false)
                        {
                            bookingtrade.Bookinttime = new DateTime(booking.Bookingtime.Date.Ticks);
                            bookingtrade.Bookinttime = bookingtrade.Bookinttime.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second);
                        }

                        addedCount = bookingtrade.Tradecount;
                        deduction.Deductionbalance = user.Balance - trade.Tradevalue * addedCount;
                        deduction.Deductioncount   = addedCount;
                        deduction.Deductionname    = string.Format("预订{0}", bookingtrade.Tradename);
                        deduction.Deductiontime    = DateTime.Now;
                        deduction.Deductionvalue   = -bookingtrade.Tradevalue * addedCount;
                        deduction.Uid      = bookingtrade.Uid;
                        deduction.Realname = bookingtrade.Realname;
                        deduction.Shopid   = bookingtrade.Shopid;
                        deduction.Shopname = bookingtrade.Shopname;
                        deduction.Remarks  = bookingtrade.Remarks;

                        isAdd = true;
                    }

                    rlt = UserManager.UpdateUserBalance(uid, trade.Tradevalue * addedCount, trans);
                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("扣除余额失败,数据库更新不成功!");
                        return;
                    }

                    rlt = DeductionManager.AddDeduction(deduction, trans);
                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("扣款记录失败,数据库写入不成功!");
                        return;
                    }

                    if (isAdd)
                    {
                        rlt = BookingtradeManager.AddBookingtrade(bookingtrade, trans);
                    }
                    else
                    {
                        rlt = BookingtradeManager.UpdateBookingtrade(bookingtrade, trans);
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    if (writeError == false)
                    {
                        responder.WriteErroredMsg("预订失败,程序异常!");
                    }
                    return;
                }
            }

            if (rlt <= 0)
            {
                if (isAdd)
                {
                    responder.WriteErroredMsg("预订失败,数据库写入不成功!");
                }
                else
                {
                    responder.WriteErroredMsg("预订失败,数据库更新不成功!");
                }

                return;
            }

            if (isAdd)
            {
                responder.WriteSuccessedMsg("提交成功,预订项已添加!");
            }
            else
            {
                responder.WriteSuccessedMsg("提交成功,预订项已更新!");
            }
        }
Beispiel #11
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Booking booking = BookingManager.GetBooking(id);

            if (booking == null)
            {
                responder.WriteErroredMsg("不存在此预订,无法删除!");
                return;
            }

            if (booking.Issettle)
            {
                responder.WriteErroredMsg("此预订已结算,无法删除!");
                return;
            }

            using (DbTransaction trans = DbHelper.BeginTransaction())
            {
                bool writeError = false;
                try
                {
                    int rlt = BookingManager.DelBooking(id, trans);
                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("删除预订失败,数据库更新不成功!");
                        return;
                    }

                    BookingshopManager.DelBookingshop(id, true, trans);

                    IList <Bookingtrade> list = BookingtradeManager.GetBookingtrade(id, trans, true);

                    foreach (Bookingtrade item in list)
                    {
                        User user = UserManager.GetUser(item.Uid, trans);
                        user.Balance = user.Balance + item.Tradevalue * item.Tradecount;

                        rlt = UserManager.UpdateUserBalance(item.Uid, -item.Tradevalue * item.Tradecount, trans);
                        if (rlt <= 0)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg("返还余额失败,数据库更新不成功!");
                            return;
                        }

                        Deduction deduction = new Deduction();
                        deduction.Deductionbalance = user.Balance;
                        deduction.Deductioncount   = -item.Tradecount;
                        deduction.Deductionname    = string.Format("退订{0}(删除预订)", item.Tradename);
                        deduction.Deductiontime    = DateTime.Now;
                        deduction.Deductionvalue   = item.Tradevalue * item.Tradecount;
                        deduction.Uid      = item.Uid;
                        deduction.Realname = item.Realname;
                        deduction.Shopid   = item.Shopid;
                        deduction.Shopname = item.Shopname;
                        deduction.Remarks  = item.Remarks;

                        rlt = DeductionManager.AddDeduction(deduction, trans);

                        if (rlt <= 0)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg("扣款记录失败,数据库写入不成功!");
                            return;
                        }

                        rlt = BookingtradeManager.DelBookingtrade(item.Id, trans);
                        if (rlt <= 0)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg("删除已预订列表失败,数据库更新不成功!");
                            return;
                        }
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    if (writeError == false)
                    {
                        responder.WriteErroredMsg("删除失败,程序异常!");
                    }
                    return;
                }
            }

            responder.WriteSuccessedMsg("预订、此预订接受预订的店铺列表和此预订的预订记录删除成功!");
        }
Beispiel #12
0
        public void handler(IResponder responder)
        {
            string dir = System.Web.HttpContext.Current.Server.MapPath(".\\Excels");

            int bookingId = SJSRequest.GetInt("Bookingid", 0);

            if (bookingId <= 0)
            {
                responder.WriteSuccessedMsg("");
                return;
            }

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            MSExcel.Application excel = new MSExcel.Application();

            MSExcel.Workbook wbook = excel.Workbooks.Add(true);

            MSExcel.Worksheet ws = (MSExcel.Worksheet)wbook.Sheets[1];
            ws.Name = "预订报表";
            ws.Select();

            int offsetRow = 1;
            int offsetCol = 1;


            MSExcel.Range r = ws.get_Range(getCell(2 + offsetRow, 1 + offsetCol), Type.Missing);
            r.Select();
            excel.ActiveWindow.FreezePanes = true;


            r = ws.get_Range(getCell(1, 1), getCell(1, 7));
            r.Merge(r.MergeCells);
            r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
            r.VerticalAlignment   = MSExcel.XlVAlign.xlVAlignCenter;
            r.RowHeight           = 25;
            r.Font.Bold           = true;
            r.Font.Size           = 14;
            r.Value2 = "预订报表";


            r = ws.get_Range(getCell(1 + offsetRow, 1 + offsetCol), Type.Missing);
            r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
            r.VerticalAlignment   = MSExcel.XlVAlign.xlVAlignCenter;
            r.ColumnWidth         = 12;
            r.RowHeight           = 25;
            r.Font.Bold           = true;
            r.Value2 = "餐饮店";

            r = ws.get_Range(getCell(1 + offsetRow, 2 + offsetCol), Type.Missing);
            r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
            r.VerticalAlignment   = MSExcel.XlVAlign.xlVAlignCenter;
            r.ColumnWidth         = 26;
            r.Font.Bold           = true;
            r.Value2 = "菜单项";

            r = ws.get_Range(getCell(1 + offsetRow, 3 + offsetCol), Type.Missing);
            r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
            r.VerticalAlignment   = MSExcel.XlVAlign.xlVAlignCenter;
            r.ColumnWidth         = 10;
            r.Font.Bold           = true;
            r.Value2 = "数 量";

            r = ws.get_Range(getCell(1 + offsetRow, 4 + offsetCol), Type.Missing);
            r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
            r.VerticalAlignment   = MSExcel.XlVAlign.xlVAlignCenter;
            r.ColumnWidth         = 10;
            r.Font.Bold           = true;
            r.Value2 = "预订者";

            r = ws.get_Range(getCell(1 + offsetRow, 5 + offsetCol), Type.Missing);
            r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
            r.VerticalAlignment   = MSExcel.XlVAlign.xlVAlignCenter;
            r.ColumnWidth         = 10;
            r.Font.Bold           = true;
            r.Value2 = "签名";

            Dictionary <string, IList <Bookingtrade> > dic = new Dictionary <string, IList <Bookingtrade> >();



            IList <Bookingshop> list = BookingshopManager.GetBookingshop(bookingId, true);

            foreach (Bookingshop bs in list)
            {
                IList <Bookingtrade> tList = BookingtradeManager.GetBookingtrade(bs.Id, 0, 0);
                dic[bs.Shopname.Trim()] = tList;
            }

            string[] keys = new string[dic.Keys.Count];

            dic.Keys.CopyTo(keys, 0);

            int curRow = 2 + offsetRow;

            int startRow = 0;

            double allMoney = 0;

            Booking booking = BookingManager.GetBooking(bookingId);

            if (booking == null)
            {
                responder.WriteSuccessedMsg("");
                return;
            }
            DateTime dt = booking.Bookingtime;

            for (int i = 0; i < keys.Length; i++)
            {
                IList <Bookingtrade> tList = dic[keys[i]];
                startRow = curRow;
                allMoney = 0;
                for (int j = 0; j < tList.Count; j++, curRow++)
                {
                    //r = ws.get_Range(getCell(curRow, 1 + offsetCol), Type.Missing);
                    //r.Value2 = tList[j].Shopname.Trim();

                    r           = ws.get_Range(getCell(curRow, 2 + offsetCol), Type.Missing);
                    r.RowHeight = 18;
                    r.Value2    = tList[j].Tradename.Trim();

                    r = ws.get_Range(getCell(curRow, 3 + offsetCol), Type.Missing);
                    r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
                    r.Value2 = tList[j].Tradecount;

                    r        = ws.get_Range(getCell(curRow, 4 + offsetCol), Type.Missing);
                    r.Value2 = tList[j].Realname.Trim();

                    allMoney = allMoney + tList[j].Tradevalue * tList[j].Tradecount;
                }

                r = ws.get_Range(getCell(startRow, 1 + offsetCol), getCell(curRow - 1, 1 + offsetCol));
                r.Merge(r.MergeCells);
                r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
                r.VerticalAlignment   = MSExcel.XlVAlign.xlVAlignCenter;
                r.Value2 = keys[i];

                r = ws.get_Range(getCell(curRow, 1 + offsetCol), Type.Missing);
                r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignRight;
                r.Font.Bold           = true;
                r.RowHeight           = 18;
                r.Value2 = "总数量:";

                r = ws.get_Range(getCell(curRow, 2 + offsetCol), Type.Missing);
                r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
                r.Font.Bold           = true;
                r.Formula             = "=SUM(" + getCell(startRow, 3 + offsetCol) + ":" + getCell(curRow - 1, 3 + offsetCol) + ")";

                r = ws.get_Range(getCell(curRow, 3 + offsetCol), Type.Missing);
                r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignRight;
                r.Font.Bold           = true;
                r.Value2 = "总 价:";

                r = ws.get_Range(getCell(curRow, 4 + offsetCol), Type.Missing);
                r.HorizontalAlignment = MSExcel.XlHAlign.xlHAlignCenter;
                r.Font.Bold           = true;
                r.Value2 = allMoney;


                curRow++;

                //r = ws.get_Range(getCell(curRow, 1 + offsetCol), getCell(curRow, 4 + offsetCol));
                //r.Merge(r.MergeCells);
                //r.Value2 =
            }

            r = ws.get_Range(getCell(1 + offsetRow, 1 + offsetCol), getCell(curRow - 1, 5 + offsetCol));
            r.Borders.LineStyle = 1;
            //r.Borders.get_Item(MSExcel.XlBordersIndex.xlEdgeTop).LineStyle = MSExcel.XlLineStyle.xlContinuous;

            string str = getCell(1, 1);

            string filename = dt.ToString("yyyyMMdd") + "报表.xlsx";
            string file     = Path.Combine(dir, filename);

            File.Delete(file);

            try
            {
                wbook.SaveAs(file, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, MSExcel.XlSaveAsAccessMode.xlExclusive);
            }
            catch (Exception ex)
            {
                //if (ex.Message.EndsWith("HRESULT:0x800A03EC")) Console.WriteLine("用户拒绝覆盖!");
                //else Console.WriteLine(ex.Message);
            }


            wbook.Close(false);
            excel.Quit();
            //Thread.Sleep(1000);
            responder.WriteSuccessedMsg("/Excels/" + filename);
            //System.Web.HttpContext.Current.Response.Redirect("/Excels/" + filename);

            //FileInfo fi = new FileInfo(file);
            //responder.RWExcelFile(fi);
        }