当前位置: 首页>>代码示例>>C#>>正文


C# BathDBDataContext.Refresh方法代码示例

本文整理汇总了C#中YouSoftBathGeneralClass.BathDBDataContext.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# BathDBDataContext.Refresh方法的具体用法?C# BathDBDataContext.Refresh怎么用?C# BathDBDataContext.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YouSoftBathGeneralClass.BathDBDataContext的用法示例。


在下文中一共展示了BathDBDataContext.Refresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: order_auto_add_thread

        //自动滚项目
        private void order_auto_add_thread()
        {
            while (true)
            {
                try
                {
                    var dc = new BathDBDataContext(connectionString);
                    TransactionOptions transOptions = new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted };
                    using (new TransactionScope(TransactionScopeOption.Required, transOptions))
                    {
                        var all_menus = dc.Menu.Where(x => x.addAutomatic);
                        var menus = all_menus.Select(x => x.name).ToList();//需要自动续费的项目名称
                        var orders = dc.Orders.Where(x => menus.Contains(x.menu) && !x.paid && x.deleteEmployee == null &&
                            x.stopTiming == null);
                        var seats = dc.Seat.Where(x => x.status == 2 || x.status == 6 || x.status == 7);
                        seats = seats.Where(x => x.ordering == null || !x.ordering.Value);
                        seats = seats.Where(x => x.paying == null || !x.paying.Value);
                        foreach (var seat in seats)
                        {
                            var seat_orders = orders.Where(x => x.text == seat.text);
                            var add_menus = seat_orders.Select(x => x.menu).Distinct();
                            foreach (var add_menu in add_menus)
                            {
                                var add_orders = seat_orders.Where(x => x.menu == add_menu && (x.priceType == null || x.priceType != "停止消费"));
                                if (add_orders.Count() == 0)
                                    continue;

                                var max_time = add_orders.Max(x => x.inputTime);
                                var max_order = add_orders.OrderByDescending(x => x.inputTime).FirstOrDefault();
                                if (max_order == null || max_order.priceType == "每小时")
                                    continue;

                                var the_menu = all_menus.FirstOrDefault(x => x.name == add_menu);
                                double menu_time = the_menu.timeLimitHour.Value * 60 + the_menu.timeLimitMiniute.Value;
                                if ((the_menu.timeLimitType == null || the_menu.timeLimitType == "限时长") &&
                                    (DateTime.Now - max_order.inputTime).TotalMinutes < menu_time)
                                    continue;
                                else if ((the_menu.timeLimitType != null && the_menu.timeLimitType == "限时间"))
                                {
                                    DateTime dt = DateTime.Parse(DateTime.Now.ToLongDateString() + " "
                                        + the_menu.timeLimitHour.ToString() + ":"
                                        + the_menu.timeLimitMiniute.ToString() + ":00");

                                    DateTime dt_st = DateTime.Parse(DateTime.Now.ToLongDateString() + " 8:00:00");

                                    if (!(max_order.inputTime <= dt_st && DateTime.Now >= dt))
                                        continue;
                                }

                                if (the_menu.addType == "按项目单位")
                                {
                                    Orders new_order = new Orders();
                                    new_order.menu = max_order.menu;
                                    new_order.text = max_order.text;
                                    new_order.systemId = seat.systemId;
                                    new_order.number = 1;
                                    new_order.money = the_menu.price;
                                    new_order.technician = max_order.technician;
                                    new_order.techType = max_order.techType;
                                    new_order.inputTime = DateTime.Now;
                                    new_order.inputEmployee = "电脑加收";
                                    new_order.paid = false;

                                    //如果这个检查手牌的状态在进SeatExpenseForm之前,但是subitchanges在进SeatExpenseForm之后,
                                    //那么dgvExpense将会看不到超时浴资
                                    dc.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, seat);
                                    if ((seat.status == 2 || seat.status == 6 || seat.status == 7) &&
                                        (seat.paying == null || !seat.paying.Value) &&
                                        (seat.ordering == null || !seat.ordering.Value))
                                    {
                                        dc.Orders.InsertOnSubmit(new_order);
                                    }
                                }
                                else if (the_menu.addType == "按时间")
                                {
                                    Orders new_order = new Orders();
                                    new_order.menu = max_order.menu;
                                    new_order.text = max_order.text;
                                    new_order.systemId = seat.systemId;
                                    new_order.number = 1;
                                    new_order.priceType = "每小时";
                                    new_order.money = Convert.ToDouble(the_menu.addMoney);
                                    new_order.technician = max_order.technician;
                                    new_order.techType = max_order.techType;
                                    new_order.inputTime = DateTime.Now;
                                    new_order.inputEmployee = "电脑加收";
                                    new_order.paid = false;

                                    dc.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, seat);
                                    if ((seat.status == 2 || seat.status == 6 || seat.status == 7) &&
                                        (seat.paying == null || !seat.paying.Value) &&
                                        (seat.ordering == null || !seat.ordering.Value))
                                    {
                                        dc.Orders.InsertOnSubmit(new_order);
                                        //dc.SubmitChanges();
                                    }
                                }
                            }
                        }
//.........这里部分代码省略.........
开发者ID:huaminglee,项目名称:yousoftbath,代码行数:101,代码来源:MainForm.cs


注:本文中的YouSoftBathGeneralClass.BathDBDataContext.Refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。