private void checkWorkingAction(EmpLoginList currentEmp, OrderTemp ordertempcurrenttable) { ((MainWindow)Window.GetWindow(this)).b.isTablesDataChange = true; if (currentEmp.Emp.EmpId.Equals(ordertempcurrenttable.EmpId)) { return; } if (ordertempcurrenttable.SubEmpId != null) { string[] subemplist = ordertempcurrenttable.SubEmpId.Split(','); for (int i = 0; i < subemplist.Count(); i++) { if (subemplist[i].Equals("")) { continue; } if (currentEmp.Emp.EmpId.Equals(subemplist[i])) { return; } } ordertempcurrenttable.SubEmpId += currentEmp.Emp.EmpId + ","; _unitofwork.OrderTempRepository.Update(ordertempcurrenttable); _unitofwork.Save(); return; } ordertempcurrenttable.SubEmpId += currentEmp.Emp.EmpId + ","; _unitofwork.OrderTempRepository.Update(ordertempcurrenttable); _unitofwork.Save(); }
private void checkCus() { orderOfFirst = _unitofwork.OrderTempRepository.Get(x => x.TableOwned.Equals(_first.TableId)).First(); orderOfSecond = _unitofwork.OrderTempRepository.Get(x => x.TableOwned.Equals(_second.TableId)).First(); if (orderOfFirst.CusId.Equals("CUS0000001") && orderOfSecond.CusId.Equals("CUS0000001")) { App.Current.Properties["TableOwner"] = "CUS0000001"; this.Close(); } else if (orderOfFirst.CusId.Equals("CUS0000001") && !orderOfSecond.CusId.Equals("CUS0000001")) { App.Current.Properties["TableOwner"] = orderOfSecond.CusId; this.Close(); } else if (!orderOfFirst.CusId.Equals("CUS0000001") && orderOfSecond.CusId.Equals("CUS0000001")) { App.Current.Properties["TableOwner"] = orderOfFirst.CusId; this.Close(); } else { txtMessage.Text = "Who will become owner of table after merged? "; setControl(false); btnFirstCus.Name = orderOfFirst.CusId; btnSecondCus.Name = orderOfSecond.CusId; } }
public Order(string name, OrderTemp temp, float shelfLifeSeconds, float decayRate) { Id = Guid.NewGuid(); Name = name; Temp = temp; ShelfLifeSeconds = shelfLifeSeconds; DecayRate = decayRate; Completed = false; }
public Order(Guid id, string name, OrderTemp temp, float shelfLifeSeconds, float decayRate) { Id = id; Name = name; Temp = temp; ShelfLifeSeconds = shelfLifeSeconds; DecayRate = decayRate; AddedAt = DateTime.Now; Value = shelfLifeSeconds; }
private void loadData() { orderOfFirst = _orderTempList.Where(x => x.TableOwned.Equals(first.TableId)).First(); orderOfSecond = _orderTempList.Where(x => x.TableOwned.Equals(second.TableId)).First(); orderDetailsOfFirst = _orderDetailsTempList.Where(x => x.OrdertempId.Equals(orderOfFirst.OrdertempId)).ToList(); orderDetailsOfSecond = _orderDetailsTempList.Where(x => x.OrdertempId.Equals(orderOfSecond.OrdertempId)).ToList(); chairOrderDetailsOfFirst = orderDetailsOfFirst.GroupBy(x => x.ChairId).Select(a => a.ToList()).ToList(); chairOrderDetailsOfSecond = orderDetailsOfSecond.GroupBy(x => x.ChairId).Select(x => x.ToList()).ToList(); }
public bool HaveFinishedShopSaleOrder() { OrderTemp tempOrder = OrderTemp.GetFinishedOrder(int.Parse(_fields["id"].ToString())); bool ret = true; if (tempOrder._fields["is_paid"].ToString().Equals("0")) { tempOrder.FinishOrder(); ret = false; } return(ret); }
public static OrderTemp GetFinishedOrder(int orderId) { OrderTemp tempOrder = new OrderTemp(); DataTable dt = DBHelper.GetDataTable(" select * from order_online_temp where online_order_id = " + orderId.ToString() + " order by [id] desc"); if (dt.Rows.Count > 0) { tempOrder = new OrderTemp(int.Parse(dt.Rows[0]["id"].ToString())); } dt.Dispose(); return(tempOrder); }
private Orders InsertOrder(OrderTemp orderTemp, int OrderNumber) { Orders Order = new Orders { DateAdd = DateTime.Now, FollowerId = Convert.ToInt32(orderTemp.FollowerId), Text = orderTemp.Text, Number = OrderNumber, Paid = false, BotInfoId = orderTemp.BotInfoId, PickupPoint = orderTemp.PickupPoint, StockUpdate = false }; db.Orders.Add(Order); db.SaveChanges(); return(Order); }
internal void process(Event item, ReceievedMessage receivedMessage, string channelAccessToken, Bot bot) { string userDisplayName = isRock.LineBot.Utility.GetUserInfo(item.source.userId, channelAccessToken).displayName; UserStatus userStatus = new UserStatus(item.source.userId, userDisplayName); userStatus.InitializeByUserID(); PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(item.source.userId); periodOrderTmp.InsertInitialPeriodOrderTmp(); OrderTemp orderTmp = new OrderTemp(item.source.userId); orderTmp.InsertInitialOrderTmp(); ShopTemp shopTemp = new ShopTemp(item.source.userId); shopTemp.InsertInitialShopTemp(); }
public OrderTemp InsertOrderTmp(int FollowerId, int BotId, int?PickupPointId = null, int?AddressId = null, int?PaymentTypeId = null) { try { OrderTemp orderTemp = new OrderTemp { FollowerId = FollowerId, BotInfoId = BotId, PickupPointId = PickupPointId, AddressId = AddressId, PaymentTypeId = PaymentTypeId }; db.OrderTemp.Add(orderTemp); db.SaveChanges(); return(orderTemp); } catch { return(null); } }
/// <summary> /// Добавить адрес доставки к заказу (в таблицу OrderTemp !!!) /// </summary> private void AddAddressToOrderTemp(int AddressId) { OrderTemp OrderTmp = new OrderTemp(); using (MarketBotDbContext db = new MarketBotDbContext()) { OrderTmp = db.OrderTemp.Where(o => o.FollowerId == FollowerId && o.BotInfoId == BotInfo.Id).FirstOrDefault(); if (OrderTmp != null && AddressId > 0) { OrderTmp.AddressId = AddressId; db.SaveChanges(); } if (OrderTmp == null && AddressId > 0) { db.OrderTemp.Add(new OrderTemp { AddressId = Argumetns[0], FollowerId = base.FollowerId, BotInfoId = BotInfo.Id }); db.SaveChanges(); } } }
public SetOrderModeDialog(OrderTemp ordertempTable) { InitializeComponent(); _ordertemp = ordertempTable; }
//ToDo: Need to update the contain in Warehouse database when new order occur private void lvCategory_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (App.Current.Properties["CurrentEmpWorking"] == null) { return; } orderingTable = ((MainWindow)Window.GetWindow(this)).currentTable; orderingChair = ((MainWindow)Window.GetWindow(this)).currentChair; ListBox lbSelected = sender as ListBox; if (orderingTable == null || orderingChair == null) { MessageBox.Show("Chair must be choice!"); return; } orderTempCurrentTable = _unitofwork.OrderTempRepository.Get(x => x.TableOwned.Equals(orderingTable.TableId)).First(); if (orderTempCurrentTable == null) { return; } var item = lbSelected.SelectedItem; if (item != null) { if (orderingTable.IsOrdered == 0) { orderTempCurrentTable.Ordertime = DateTime.Now; orderingTable.IsOrdered = 1; _unitofwork.TableRepository.Update(orderingTable); } OrderDetailsTemp o = new OrderDetailsTemp(); Product it = (Product)lbSelected.SelectedItem; //order for each chair if (orderingChair != null) { var chairorderdetailstemp = _unitofwork.OrderDetailsTempRepository.Get(x => x.ChairId.Equals(orderingChair.ChairId)).ToList(); var foundinchairorderdetailstemp = chairorderdetailstemp.Where(x => x.ProductId.Equals(it.ProductId)).ToList(); // go to warehouse, check and get the ingredient to make product if (!TakeFromWareHouseData(o, it)) { return; } // add a product to order if (foundinchairorderdetailstemp.Count == 0) { o.ChairId = orderingChair.ChairId; o.OrdertempId = orderTempCurrentTable.OrdertempId; o.ProductId = it.ProductId; o.SelectedStats = it.StandardStats; o.Note = ""; o.Quan = 1; o.IsPrinted = 0; o.Discount = it.Discount; _unitofwork.OrderDetailsTempRepository.Insert(o); _unitofwork.Save(); } else { foreach (var order in foundinchairorderdetailstemp) { if (!order.SelectedStats.Equals(it.StandardStats) || !order.Note.Equals("") || order.IsPrinted != 0) { o.ChairId = orderingChair.ChairId; o.OrdertempId = orderTempCurrentTable.OrdertempId; o.ProductId = it.ProductId; o.SelectedStats = it.StandardStats; o.Note = ""; o.Quan = 1; o.IsPrinted = 0; o.Discount = it.Discount; _unitofwork.OrderDetailsTempRepository.Insert(o); _unitofwork.Save(); break; } if (order.SelectedStats.Equals(it.StandardStats) && order.Note.Equals("") && order.IsPrinted == 0) { order.ProductId = it.ProductId; order.Quan++; _unitofwork.OrderDetailsTempRepository.Update(order); _unitofwork.Save(); break; } } } } lbSelected.UnselectAll(); checkWorkingAction(App.Current.Properties["CurrentEmpWorking"] as EmpLoginList, orderTempCurrentTable); ((MainWindow)Window.GetWindow(this)).initProgressTableChair(); ((MainWindow)Window.GetWindow(this)).en.ucOrder.RefreshControl(_unitofwork, orderingTable); ((MainWindow)Window.GetWindow(this)).en.ucOrder.txtDay.Text = orderTempCurrentTable.Ordertime.ToString("dd/MM/yyyy H:mm:ss"); } }
internal static ImagemapMessage MakeMenu(Event item) { // 先做初始化 UserStatus userStatus = new UserStatus(item.source.userId); userStatus.InitializeUserStatusByUserID(); ShopTemp shopTemp = new ShopTemp(item.source.userId); shopTemp.InitializeShopTempByUserID(); shopTemp.DeleteShopItemTempByUserID(); OrderTemp orderTemp = new OrderTemp(item.source.userId); orderTemp.UpdateInitialOrderTemp(); PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(item.source.userId); periodOrderTmp.UpdateInitialPeriodOrderTmp(); ShopListTemp shopListTemp = new ShopListTemp(item.source.userId); shopListTemp.DeleteByUserID(); BuyerTemp buyerTemp = new BuyerTemp(item.source.userId); buyerTemp.DeleteByBuyerID(); // 先做初始化 ImagemapMessage imagemapMessage = new ImagemapMessage(); Uri uri = new Uri("https://i220.photobucket.com/albums/dd130/jung_04/Menu2.png#"); imagemapMessage.baseUrl = uri; imagemapMessage.altText = "這是imagemap"; Size size = new Size(1040, 1040); imagemapMessage.baseSize = size; #region LeftUp isRock.LineBot.ImagemapArea imagemapAreaLeftUp = new isRock.LineBot.ImagemapArea() { x = 0, y = 0, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionLeftUp = new ImagemapMessageAction(); imagemapMessageActionLeftUp.area = imagemapAreaLeftUp; imagemapMessageActionLeftUp.text = "我要進入訂單模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionLeftUp); #endregion #region RightUp isRock.LineBot.ImagemapArea imagemapAreaRightUp = new isRock.LineBot.ImagemapArea() { x = 520, y = 0, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionRightUp = new ImagemapMessageAction(); imagemapMessageActionRightUp.area = imagemapAreaRightUp; imagemapMessageActionRightUp.text = "我要進入個人模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionRightUp); #endregion #region LeftDown isRock.LineBot.ImagemapArea imagemapAreaLeftDown = new isRock.LineBot.ImagemapArea() { x = 0, y = 520, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionLeftDown = new ImagemapMessageAction(); imagemapMessageActionLeftDown.area = imagemapAreaLeftDown; imagemapMessageActionLeftDown.text = "我要進入社團模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionLeftDown); #endregion #region RightDown var actions1 = new List <isRock.LineBot.ImagemapActionBase>(); isRock.LineBot.ImagemapArea imagemapAreaRightDown = new isRock.LineBot.ImagemapArea() { x = 520, y = 520, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionRightDown = new ImagemapMessageAction(); imagemapMessageActionRightDown.area = imagemapAreaRightDown; imagemapMessageActionRightDown.text = "我要進入商店模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionRightDown); #endregion return(imagemapMessage); }
/// <summary> /// Пользователь выбрал методо оплаты /// </summary> /// <returns></returns> private async Task <IActionResult> SelectPaymentMethod() { OrderFunction = new OrderFunction(); int PaymentTypeId = 0; bool TestConnection = false; bool ExistUserName = false; bool ExistTelephone = false; OrderTemp orderTemp = null; ConfigurationBot = GetConfigurationBot(BotInfo.Id); if (Argumetns.Count > 0) { PaymentTypeId = Argumetns[0]; TestConnection = OrderFunction.PaymentTypeTestConnection(PaymentTypeId); } if (TestConnection == false) { await AnswerCallback("Ошибка. Данный способ оплаты недоступен!", true); OrderFunction.Dispose(); return(OkResult); } if (TestConnection) { orderTemp = OrderFunction.AddPaymentMethodToOrderTmp(FollowerId, BotInfo.Id, PaymentTypeId); OrderFunction.Dispose(); } //Данные о выбраном способоне оплаты успешно занесены в БД. //Если в настройках бота включена верификация по номеру телефона, то проверяем указан ли номер телефона у этого пользователя //Если не указан то просим указать ExistTelephone = FollowerFunction.ExistTelephone(FollowerId); if (orderTemp != null && ConfigurationBot != null && ConfigurationBot.VerifyTelephone && !ExistTelephone) { BotMessage = new RequestPhoneNumberMessage(); await SendMessage(BotMessage.BuildMsg()); } //телефон указан if (orderTemp != null && ConfigurationBot != null && ConfigurationBot.VerifyTelephone && ExistTelephone) { return(await SendOrderTemp()); } //Данные о выбраном способоне оплаты успешно занесены в БД. //Если в настройках бота верификация по телефону отключена, проверяем указан ли у пользователя UserName ExistUserName = FollowerFunction.ExistUserName(FollowerId); if (orderTemp != null && ConfigurationBot != null && !ConfigurationBot.VerifyTelephone && !ExistUserName) { return(await SendUserNameAddedFaq()); } //UserName указан if (orderTemp != null && ConfigurationBot != null && !ConfigurationBot.VerifyTelephone && ExistUserName) { return(await SendOrderTemp()); } return(OkResult); }
internal static string UpdateOrder(int QID, int OID, string userId) { int result = 0; OrderTemp orderTemp; OrderInfo orderInfo; switch (QID) { case 61: orderTemp = new OrderTemp(userId); orderTemp.SelectByUserID(); orderInfo = new OrderInfo(userId); orderInfo.OrderPartitionID = orderTemp.OrderPartitionID; orderInfo.SelectMyOrderTableByOrderPartitionID(); orderInfo.StartTime = orderTemp.StartTime; orderInfo.EndTime = orderTemp.EndTime; switch (orderInfo.OrderStatus) { case "wait": orderInfo.OrderStatus = "wait"; result = orderInfo.UpdateTimeByOrderPartitionIDToMyOrder(); break; case "available": orderInfo.OrderStatus = "wait"; result = orderInfo.UpdateTimeByOrderPartitionIDToMyOrder(); break; case "done": return("此訂單已經結單,無法再改時間囉~"); break; default: break; } // result = orderInfo.UpdateTimeByOrderPartitionIDToMyOrder(); break; case 161: orderTemp = new OrderTemp(userId); orderTemp.ClubIDSelectByUserID(); orderTemp.SelectByUserID(); orderInfo = new OrderInfo(orderTemp.ClubID); orderInfo.OrderPartitionID = orderTemp.OrderPartitionID; orderInfo.SelectClubOrderTableByOrderPartitionID(); orderInfo.StartTime = orderTemp.StartTime; orderInfo.EndTime = orderTemp.EndTime; switch (orderInfo.OrderStatus) { case "wait": orderInfo.OrderStatus = "wait"; result = orderInfo.UpdateTimeByOrderPartitionIDTOClubOrder(); break; case "available": orderInfo.OrderStatus = "wait"; result = orderInfo.UpdateTimeByOrderPartitionIDTOClubOrder(); break; case "done": return("此訂單已經結單,無法再改時間囉~"); break; default: break; } // result = orderInfo.UpdateTimeByOrderPartitionIDTOClubOrder(); break; default: break; } if (result > 0) { orderTemp = new OrderTemp(userId); orderTemp.UpdateInitialOrderTemp(); return("修改成功"); } else { return("修改失敗"); } }
// 參數postbackData是藏在button裡,經由postback傳進來的 // 參加社團和退出社團需要clubID,建立社團需要ClubName internal static string CommunicateClubInfo(string userId, int QID, int OID, string postbackData, string channelAccessToken) { UserStatus userStatus; ClubInfo clubInfo; switch (QID) { case 91: switch (OID) { case 3: try { clubInfo = new ClubInfo(userId, postbackData, ""); // 這裡的postbackData是clubID clubInfo.InsertClubInfoToSQL(); OrderInfo orderInfo = new OrderInfo(postbackData); //ClubID List <OrderInfo> list = orderInfo.CheckClubOrderByUserID(); string CheckMessage = "成功加入社團"; foreach (OrderInfo item in list) { if (item.OrderStatus == "available") { CheckMessage = "成功加入社團~~\n此社團有訂單正在推播中~~\n可以直接點選上面選項直接訂購喔~~"; // isRock.LineBot.Utility.PushMessage(userId, CheckMessage, channelAccessToken); OrderTemp orderTemp = new OrderTemp(userId); orderTemp.OrderPartitionID = item.OrderPartitionID; orderTemp.UpdateOrderPartitionIDByUserID(); string JasonMessage = FlexMaker.MakeSearchingItem(QID, OID, userId); isRock.LineBot.Utility.PushMessagesWithJSON(userId, JasonMessage, channelAccessToken); userStatus = new UserStatus(userId, 0, 0); userStatus.UpdateByUserID(); } // return CheckMessage; } userStatus = new UserStatus(userId, 0, 0); userStatus.UpdateByUserID(); return(CheckMessage); } catch (Exception e) { return("加入社團失敗,或是已加入社團"); } default: break; } break; case 92: switch (OID) { case 3: clubInfo = new ClubInfo(userId, postbackData); // 這裡的postbackData是clubName clubInfo.InsertClubInfoToSQL(); userStatus = new UserStatus(userId, 0, 0); userStatus.UpdateByUserID(); isRock.LineBot.Utility.PushMessage(userId, clubInfo.ClubID, channelAccessToken); return("你的社團已經建立嘍~~\n上方是你的社團參加碼~\n將此參加碼分享給要參加此社團的人~"); default: break; } break; case 102: switch (OID) { case 2: clubInfo = new ClubInfo(userId, postbackData, ""); clubInfo.DeleteClubInfoToSQL(); userStatus = new UserStatus(userId, 0, 0); userStatus.UpdateByUserID(); return(MessageMaker.MakeLeaveClubMessage(userId, QID, OID, postbackData)); default: break; } break; default: break; } return("資料庫溝通失敗"); }
internal static string MakeSearchingItem(int QIDnow, int OIDnow, string UserID) { // 從OrderTemp裡面拿到OrderPartitionID OrderTemp orderTemp = new OrderTemp(UserID); orderTemp.SelectByUserID(); // 用OrderPartitionID去找到ShopID,再用ShopID找到ShopItem OrderInfo orderInfo = new OrderInfo(UserID); orderInfo.OrderPartitionID = orderTemp.OrderPartitionID; string OrderPartitionIDSplitted = orderTemp.OrderPartitionID.Substring(0, 2); switch (OrderPartitionIDSplitted) { case "MO": // MyOrder orderInfo.SelectMyOrderTableByOrderPartitionID(); break; case "CO": // ClubOrder orderInfo.SelectClubOrderTableByOrderPartitionID(); break; default: break; } //NextHelper nextHelper = new NextHelper(QIDnow, OIDnow); //QuestionDetail questionDetailNext = nextHelper.GetNext(); //PreviousHelper previousHelper = new PreviousHelper(QIDnow, OIDnow); //QuestionDetail questionDetailPrevious = previousHelper.GetPrevious(); //CancelHelper cancelHelper = new CancelHelper(QIDnow, OIDnow); //QuestionDetail questionDetailCancel = cancelHelper.GetCancel(); ShopItem shopItem = new ShopItem(orderInfo.ShopID); List <ShopItem> myshopItems = shopItem.SelectByMyShopID(); List <ShopItem> bossshopItems = shopItem.SelectByBossShopID(); List <ShopItem> clubshopItems = shopItem.SelectByClubShopID(); ShopInfo shopInfo = new ShopInfo(); shopInfo.ShopID = orderInfo.ShopID; string OrderShopName; ShopImage shopImage = new ShopImage(orderInfo.ShopID); List <string> BossShopimagesUris = shopImage.SelectImageByShopID(); //抓出該商店的圖片 ShuffleImage(BossShopimagesUris); //隨機洗亂 ///// string DefaultUri = "https://i220.photobucket.com/albums/dd130/jung_04/GJ.gif"; //Flex圖片超連結 int ButtonControl = 4; //設定Button數量 ///// int ButtonCount = 0; //控制Button數量 FlexPushOrderMenu flexPushOrderMenu = new FlexPushOrderMenu(); if (myshopItems.Count > 0) { shopInfo.SelectMyShopNameByShopID(); OrderShopName = shopInfo.ShopName; int BubbleCount = 0; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(DefaultUri)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.StartTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 foreach (ShopItem item in myshopItems) { if (ButtonCount >= ButtonControl) { ButtonCount = 0; BubbleCount++; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(DefaultUri)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 } flexPushOrderMenu.contents.contents[BubbleCount].footer.contents.Add(new FlexPushOrderMenu.OrderButton(item.shopItem, item.ShopItemPrice)); flexPushOrderMenu.contents.contents[BubbleCount].footer.contents[ButtonCount].action.data = DateTime.Now.Add((orderInfo.EndTime - orderInfo.StartTime).Add(new TimeSpan(0, -5, 0)))//主程式檢查按鈕有效時間為5分鐘 + "," + 9999 + "," + 2 + "," + orderInfo.OrderPartitionID + "," + item.shopItem + "," + item.ShopItemPrice; ButtonCount++; } } if (bossshopItems.Count > 0) { if (bossshopItems.Count >= BossShopimagesUris.Count * ButtonControl) { int NeedAddcount = bossshopItems.Count - BossShopimagesUris.Count; for (int i = 0; i <= NeedAddcount; i++) { BossShopimagesUris.Add(BossShopimagesUris[i]); } } shopInfo.SelectBossShopNameByShopID(); OrderShopName = shopInfo.ShopName; int BubbleCount = 0; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(BossShopimagesUris[0])); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 foreach (ShopItem item in bossshopItems) { if (ButtonCount >= ButtonControl) { ButtonCount = 0; BubbleCount++; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(BossShopimagesUris[BubbleCount])); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 } flexPushOrderMenu.contents.contents[BubbleCount].footer.contents.Add(new FlexPushOrderMenu.OrderButton(item.shopItem, item.ShopItemPrice)); flexPushOrderMenu.contents.contents[BubbleCount].footer.contents[ButtonCount].action.data = DateTime.Now.Add((orderInfo.EndTime - orderInfo.StartTime).Add(new TimeSpan(0, -5, 0)))//主程式檢查按鈕有效時間為5分鐘 + "," + 9999 + "," + 2 + "," + orderInfo.OrderPartitionID + "," + item.shopItem + "," + item.ShopItemPrice; ButtonCount++; } } if (clubshopItems.Count > 0) { shopInfo.SelectClubShopNameByShopID(); OrderShopName = shopInfo.ShopName; int BubbleCount = 0; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(DefaultUri)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 foreach (ShopItem item in clubshopItems) { if (ButtonCount >= ButtonControl) { ButtonCount = 0; BubbleCount++; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(DefaultUri)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 } flexPushOrderMenu.contents.contents[BubbleCount].footer.contents.Add(new FlexPushOrderMenu.OrderButton(item.shopItem, item.ShopItemPrice)); flexPushOrderMenu.contents.contents[BubbleCount].footer.contents[ButtonCount].action.data = DateTime.Now.Add((orderInfo.EndTime - orderInfo.StartTime).Add(new TimeSpan(0, -5, 0)))//主程式檢查按鈕有效時間為5分鐘 + "," + 9999 + "," + 2 + "," + orderInfo.OrderPartitionID + "," + item.shopItem + "," + item.ShopItemPrice; ButtonCount++; } } JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var json = JsonConvert.SerializeObject(flexPushOrderMenu, settings); return("[" + json + "]"); }
/// <summary> /// Удалить заказ из временной таблицы OrderTemp /// </summary> /// <param name="orderTemp"></param> /// <returns></returns> private int DeleteTempOrder(OrderTemp orderTemp) { db.OrderTemp.Remove(orderTemp); return(db.SaveChanges()); }
//method kiem tra sau khi start employee -> order private void checkCurrentEmp(EmpLoginList currentEmp, Rectangle rec, Entities.Table founded, OrderTemp ordertempcurrenttable) { if (App.Current.Properties["CurrentEmpWorking"] == null) { return; } currentEmp = App.Current.Properties["CurrentEmpWorking"] as EmpLoginList; if (currentEmp != null) { if (ordertempcurrenttable != null) { ordertempcurrenttable.EmpId = currentEmp.Emp.EmpId; _unitofwork.OrderTempRepository.Update(ordertempcurrenttable); _unitofwork.Save(); } navigateToOrder(currentEmp, rec, founded); return; } }
private static string GetConfirmText(int QID, int OID, string UserIDorClubIDorOrderID) { OrderInfo orderInfo; switch (QID) { case 52: orderInfo = new OrderInfo(); orderInfo.OrderID = UserIDorClubIDorOrderID; orderInfo.SelectMyOrderNameByOrderID(); return($"確定要刪除:{orderInfo.OrderName} 嗎???"); case 61: switch (OID) { case 2: OrderTemp orderTemp = new OrderTemp(UserIDorClubIDorOrderID); orderTemp.SelectByUserID(); return($"請確認將開單時間修改為:{orderTemp.StartTime.ToString("yyyy-MM-dd HH:mm")},結單時間修改為:{orderTemp.EndTime.ToString("yyyy-MM-dd HH:mm")} 嗎???"); default: break; } break; case 102: switch (OID) { case 1: ClubInfo clubInfo = new ClubInfo(); clubInfo.ClubID = UserIDorClubIDorOrderID; // 這裡用ClubID return($"確定離開 {clubInfo.SelectByClubid()[0].ClubName} 嗎???"); default: break; } break; case 152: orderInfo = new OrderInfo(); orderInfo.OrderID = UserIDorClubIDorOrderID; orderInfo.SelectClubOrderNameByOrderID(); return($"確定要刪除:{orderInfo.OrderName} 嗎???"); case 161: switch (OID) { case 2: OrderTemp orderTemp = new OrderTemp(UserIDorClubIDorOrderID); orderTemp.SelectByUserID(); return($"請確認將開單時間修改為:{orderTemp.StartTime.ToString("yyyy-MM-dd HH:mm")},結單時間修改為:{orderTemp.EndTime.ToString("yyyy-MM-dd HH:mm")} 嗎???"); default: break; } break; case 171: switch (OID) { case 7: ShopTemp shopTemp = new ShopTemp(UserIDorClubIDorOrderID); // 這裡用UserID shopTemp.GetMyShopTempInfoFromSQL(); List <ShopTemp> shopItems = shopTemp.GetShopItemTempFromSQL(); string confirmText1 = $"請確認建立商店資訊:" + $"商店名稱:{shopTemp.ShopName}," + $"商店電話:{shopTemp.ShopPhone}," + $"商店地址:{shopTemp.ShopAddress},商店品項:"; string confirmText2 = ""; for (int i = 0; i < shopItems.Count; i++) { confirmText2 += $"{shopItems[i].ShopItem}({shopItems[i].ShopItemPrice} TWD) "; } return(confirmText1 + confirmText2); default: break; } break; case 201: switch (OID) { case 3: return($"確定建立嗎???"); default: break; } break; case 211: switch (OID) { case 3: return($"要繼續選擇商店嗎???"); default: break; } break; case 231: switch (OID) { case 3: ShopInfo shopInfo = new ShopInfo(); shopInfo.ShopID = UserIDorClubIDorOrderID; shopInfo.SelectMyShopNameByShopID(); if (shopInfo.ShopName != null) { return($"確定將此訂單商店換成 {shopInfo.ShopName} 嗎???"); } else { List <ShopInfo> shopInfos = shopInfo.BossShopSelectShopNameByShopid(); return($"確定將此訂單商店換成 {shopInfos[0].ShopName} 嗎???"); } default: break; } return(""); case 241: switch (OID) { case 3: return($"確定建立嗎???"); default: break; } break; case 251: switch (OID) { case 3: return($"要繼續選擇商店嗎???"); default: break; } break; case 261: switch (OID) { case 3: ShopInfo shopInfo = new ShopInfo(); shopInfo.ShopID = UserIDorClubIDorOrderID; shopInfo.SelectMyShopNameByShopID(); if (shopInfo.ShopName != null) { return($"確定將此訂單商店換成 {shopInfo.ShopName} 嗎???"); } else { List <ShopInfo> shopInfos = shopInfo.BossShopSelectShopNameByShopid(); return($"確定將此訂單商店換成 {shopInfos[0].ShopName} 嗎???"); } default: break; } return(""); case 121: switch (OID) { case 5: return("需要繼續修改其他品項嗎?"); default: break; } break; case 271: switch (OID) { case 7: ShopTemp shopTemp = new ShopTemp(UserIDorClubIDorOrderID); // 這裡用UserID shopTemp.GetClubShopTempInfoFromSQL(); List <ShopTemp> shopItems = shopTemp.GetShopItemTempFromSQL(); string confirmText1 = $"請確認建立社團商店資訊:" + $"商店名稱:{shopTemp.ShopName}," + $"商店電話:{shopTemp.ShopPhone}," + $"商店地址:{shopTemp.ShopAddress},商店品項:"; string confirmText2 = ""; for (int i = 0; i < shopItems.Count; i++) { confirmText2 += $"{shopItems[i].ShopItem}({shopItems[i].ShopItemPrice} TWD) "; } return(confirmText1 + confirmText2); default: break; } break; default: break; } return(""); }
internal static string CommunicateOrder(string userId, int QID, int OID, string OrderName, string channelAccessToken) { OrderTemp orderTmp = new OrderTemp(userId); orderTmp.SelectByUserID(); //這裡主要從OrderTmp抓取起始時間跟結束時間,ShopID OrderInfo orderinfo = new OrderInfo(); //準備輸入SQL的資料 switch (QID) //根據QID不同初始化clubOrderAndMyOrder { case 201: orderinfo = new OrderInfo(userId, OrderName); break; case 231: //231只修改shopID orderinfo = new OrderInfo(userId); orderTmp.SelectByUserID(); orderTmp.ShopID = OrderName; //在此處傳進來OrderName是ShopID break; case 241: orderTmp.ClubIDSelectByUserID(); //撈取ClubID orderinfo = new OrderInfo(orderTmp.ClubID, OrderName); break; case 261: orderTmp.ClubIDSelectByUserID(); //撈取ClubID orderinfo = new OrderInfo(orderTmp.ClubID); orderTmp.SelectByUserID(); orderTmp.ShopID = OrderName; //在此處傳進來OrderName是ShopID break; default: break; } orderinfo.StartTime = orderTmp.StartTime; orderinfo.EndTime = orderTmp.EndTime; orderinfo.ShopID = orderTmp.ShopID; if (QID == 201 | QID == 241) { orderinfo.OrderType = "Once"; } else { orderinfo.OrderType = "Period"; } orderinfo.OrderStatus = "wait"; int result = 0; switch (QID) { case 201: orderinfo.OrderPartitionID = "MOO" + orderinfo.OrderID; result = orderinfo.InserMyOrderTableToSQL(); break; case 231: //修改MyOrder訂單店家 orderinfo.OrderPartitionID = orderTmp.OrderPartitionID; result = orderinfo.UpdateShopIDByOrderPartitionIDToMyOrder(); if (result > 0) { return("修改完成"); } else { return("修改失敗"); } break; case 241: orderinfo.OrderPartitionID = "COO" + orderinfo.OrderID; result = orderinfo.InserClubOrderTableToSQL(); if (result > 0) { UserStatus userStatus = new UserStatus(userId); userStatus.InitializeUserStatusByUserID(); orderTmp.UpdateInitialOrderTemp(); orderTmp = new OrderTemp(userId); return("社團訂單建立成功,所有社團成員皆能收到此訂單通知,無須再讓成員加入訂單喔~"); } break; case 261: orderinfo.OrderPartitionID = orderTmp.OrderPartitionID; result = orderinfo.UpdateShopIDByOrderPartitionIDToClubOrder(); if (result > 0) { return("修改完成"); } else { return("修改失敗"); } break; default: break; } if (result > 0) { UserStatus userStatus = new UserStatus(userId); userStatus.InitializeUserStatusByUserID(); orderTmp = new OrderTemp(userId); orderinfo.InsertOrdeUserTable(); orderTmp.UpdateInitialOrderTemp(); isRock.LineBot.Utility.PushMessage(userId, orderinfo.OrderID, channelAccessToken); // string orderCreateMessage = "上面是你的訂單參加碼,可以將此參加碼分享給其他人,讓其他人加入你的訂單喔~"; // isRock.LineBot.Utility.PushMessage(userId, orderCreateMessage, channelAccessToken); return("訂單建立成功喔~~\n上面是你的訂單參加碼,可以將此參加碼分享給其他人,讓其他人加入你的訂單喔~"); } else { return("訂單建立失敗"); } }
internal static bool CommunicateOrderTmp(string userId, int QID, int OID, string seletedDateTimeStatus, string selecteddateTime, string channelAccessToken) { OrderTemp orderTmp = new OrderTemp(userId); DateTime dateTime = Convert.ToDateTime(selecteddateTime); bool BothTimeHasFilledIn = false; string message = ""; if (DateTimeChecker.DateTimeCheckIsEarlierThanNow(dateTime)) { message = "不要選擇過時的時間哦~"; } else { switch (seletedDateTimeStatus) { case "start": //先判斷有沒有比暫存結束時間晚 if (!DateTimeChecker.CompareIsLaterThanEndTime(dateTime, orderTmp)) { orderTmp.StartTime = dateTime; orderTmp.UpdateStartTime(); BothTimeHasFilledIn = orderTmp.CheckBothTimeHasFilledIn(orderTmp); if (!BothTimeHasFilledIn) { message = $"訂單發出時間: {dateTime.ToString("yyyy-MM-dd HH:mm")}"; } else { isRock.LineBot.Utility.PushMessage(userId, $"訂單發出時間: {dateTime.ToString("yyyy-MM-dd HH:mm")}", channelAccessToken); message = "選擇時間完畢!"; } } else { message = "開始時間無法比結束時間晚哦~"; } break; case "end": //先判斷有沒有比暫存結束時間晚 if (!DateTimeChecker.CompareIsEarlierThanStartTime(dateTime, orderTmp)) { orderTmp.EndTime = dateTime; orderTmp.UpdateEndTime(); BothTimeHasFilledIn = orderTmp.CheckBothTimeHasFilledIn(orderTmp); if (!BothTimeHasFilledIn) { message = $"訂單結束時間: {dateTime.ToString("yyyy-MM-dd HH:mm")}"; } else { isRock.LineBot.Utility.PushMessage(userId, $"訂單結束時間: {dateTime.ToString("yyyy-MM-dd HH:mm")}", channelAccessToken); message = "選擇時間完畢!"; } } else { message = "開始時間無法比結束時間晚哦~"; } break; default: break; } } isRock.LineBot.Utility.PushMessage(userId, message, channelAccessToken); return(BothTimeHasFilledIn); }
internal static string CommunicateUserInfo(string userId, int QID, int OID, string postbackData, string channelAccessToken) { UserStatus userStatus; OrderInfo orderInfo; int result; switch (QID) { case 71: switch (OID) { case 3: // 先拿到UserStatus裡面的TempData,上一步存的是OrderID userStatus = new UserStatus(userId); userStatus.SelectByUserID(); // 把資料存進OrderUserTable裡 orderInfo = new OrderInfo(userId); orderInfo.OrderID = userStatus.TempData; result = orderInfo.InsertOrdeUserTable(); if (result > 0) { List <OrderInfo> list = orderInfo.SelectMyOrderByOrderID(); if (list[0].OrderStatus == "available") { string CheckMessage = "成功參加訂單~~\n此訂單正在推播中~~\n可以直接點選上面選項直接訂購喔~~"; // isRock.LineBot.Utility.PushMessage(userId, CheckMessage, channelAccessToken); OrderTemp orderTemp = new OrderTemp(userId); orderTemp.OrderPartitionID = list[0].OrderPartitionID; orderTemp.UpdateOrderPartitionIDByUserID(); string JasonMessage = FlexMaker.MakeSearchingItem(QID, OID, userId); isRock.LineBot.Utility.PushMessagesWithJSON(userId, JasonMessage, channelAccessToken); return(CheckMessage); } else { return("成功參加訂單"); } } else { return("參加訂單失敗"); } default: break; } break; case 82: switch (OID) { case 2: OrderTemp orderTemp = new OrderTemp(userId); orderTemp.SelectByUserID(); orderInfo = new OrderInfo(userId); orderInfo.OrderPartitionID = orderTemp.OrderPartitionID; orderInfo.SelectMyOrderTableByOrderPartitionID(); switch (postbackData) { case "MyOrderPartition": // 刪除我的週期性訂單的其中一筆 result = orderInfo.DeleteMyOrderPartitionByUserIDandOrderPartitionID(); if (result > 0) { return("成功刪除訂單"); } else { return("刪除訂單失敗"); } case "MyOrder": // 刪除完整我的週期性訂單 result = orderInfo.DeleteMyOrderByUserIDandOrderID(); if (result > 0) { return("成功刪除訂單"); } else { return("刪除訂單失敗"); } case "MyOnceOrder": // 刪除一次性我的訂單 result = orderInfo.DeleteMyOrderByUserIDandOrderID(); if (result > 0) { return("成功刪除訂單"); } else { return("刪除訂單失敗"); } default: break; } break; default: break; } break; default: break; } return("資料庫溝通失敗"); }