public void reloadFoodTableUI(bool isReloadFromServer = false, Action cbAfterReload = null) { if (isReloadFromServer) { RequestManager.getInstance().showLoading(); Action <NetworkResponse> cbSuccessSent = delegate(NetworkResponse networkResponse) { RequestManager.getInstance().hideLoading(); if (!networkResponse.Successful) { WindownsManager.getInstance().showMessageBoxSomeThingWrong(); } else { reloadFoodTableUI(false, cbAfterReload); } }; Action <string> cbError = delegate(string err) { WindownsManager.getInstance().showMessageBoxErrorNetwork(); RequestManager.getInstance().hideLoading(); }; FoodManager.getInstance().getAllFoodFromServerAndUpdate( cbSuccessSent, cbError ); } else { LVFood.Items.Clear(); foreach (KeyValuePair <int, Food> entry in FoodManager.getInstance().FoodList) { if (entry.Value != null) { var foodCell = new FoodCell(entry.Value, this); LVFood.Items.Add(foodCell); var imageId = entry.Value.ImageId ?? default(int); if (entry.Value.ImageId != null && imageId >= 0) { if (ImageManager.getInstance().checkImageExistLocal(imageId)) { ImageManager.getInstance().loadImage(imageId, delegate(byte[] imageData) { foodCell.setImageFood(UtilFuction.ByteToImage(imageData)); }); } else { ImageManager.getInstance().loadImage(imageId, delegate(byte[] imageData) { checkAndSetImageForFoodCell(entry.Value.FoodId, imageId, UtilFuction.ByteToImage(imageData)); }); } } } } cbAfterReload?.Invoke(); } }
private void TextBoxQuantity_TextChanged(object sender, TextChangedEventArgs e) { if (_foodWithOrder == null) { return; } int newQuantity = 0; if (!int.TryParse(TextBoxQuantity.Text, out newQuantity)) { BtnEdit.IsEnabled = false; return; } textBlockTotal.Text = UtilFuction.formatMoney(newQuantity * _foodWithOrder.Food.Price); BtnEdit.IsEnabled = true; if (newQuantity != previousQuantity) { orderInfo.BtnAccept.Visibility = Visibility.Visible; orderInfo.BtnCancel.Visibility = Visibility.Visible; } else { orderInfo.BtnAccept.Visibility = Visibility.Hidden; orderInfo.BtnCancel.Visibility = Visibility.Hidden; } orderInfo.onChangeMoney(); }
public void reloadUI() { if(_table == null) { return; } double currentMoneyOfTable = 0; foreach(KeyValuePair<int, Order> entry in OrderManager.getInstance().OrderList) { if(entry.Value != null && entry.Value.TableId == _table.TableId && (entry.Value.MoneyReceive < entry.Value.BillMoney || entry.Value.BillMoney == 0)) { currentMoneyOfTable += (double)(entry.Value.BillMoney - entry.Value.MoneyReceive); } } TextBlockTableId.Text = "Bàn số " + _table.TableId.ToString(); if (currentMoneyOfTable > 0) { ImageState.Source = (ImageSource)GridParent.FindResource("ImageGreenDot"); TextBlockState.Text = "Đang sử dụng"; TextBlockState.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF18FA00")); TextBlockMoney.Text = UtilFuction.formatMoney((decimal)currentMoneyOfTable) + " VND"; } else { ImageState.Source = (ImageSource)GridParent.FindResource("ImageGrayDot"); TextBlockState.Text = "Chưa sử dụng"; TextBlockState.Foreground = new SolidColorBrush(Colors.White); TextBlockMoney.Text = "Mở bàn"; } }
private void setImageDataAndStoreLocal(int imageId, byte[] imageData) { _imagesData[imageId] = imageData; var image = UtilFuction.ByteToImage(imageData); image.Save(_fullImagePath + imageId.ToString(), ImageFormat.Jpeg); }
public void checkAndAddFoodIdToComboBox(int foodId) { foreach (ComboBoxItem comboData in ComboBoxSelectFood.ComboBoxData.Items) { if ((int)comboData.Tag == foodId) { return; } } var foodData = FoodManager.getInstance().FoodList[foodId]; string txt = foodData.FoodId + " - " + foodData.Name; var imgSrc = (ImageSource)Application.Current.FindResource("ImageDefaultFood"); if (foodData.ImageId != null) { byte[] imgData = null; ImageManager.getInstance().loadImageFromLocal(foodData.ImageId ?? default(int), out imgData); if (imgData != null) { var img = UtilFuction.ByteToImage(imgData); imgSrc = UtilFuction.imageToBitmapSource(img); } } var item = ComboBoxSelectFood.addItem(txt, imgSrc); item.Tag = foodData.FoodId; }
public void reloadListViewOrder(bool isBaseOnFilter) { List <int> listTableId = new List <int>(); double timeFrom = 0; double timeTo = UtilFuction.GetTime(DateTime.Now); if (isBaseOnFilter) { foreach (CheckBox checkBox in LVFilterTable.Items.OfType <CheckBox>()) { if (checkBox.IsChecked == true) { listTableId.Add((int)checkBox.Tag); } } if (listTableId.Count == LVFilterTable.Items.Count) { listTableId.Clear(); } if (CheckBoxFilterDate.IsChecked == true) { if (DatePickerFrom.SelectedDate != null) { timeFrom = UtilFuction.GetTime(DatePickerFrom.SelectedDate.Value) - DatePickerFrom.SelectedDate.Value.TimeOfDay.TotalMilliseconds; } if (DatePickerTo.SelectedDate != null) { timeTo = UtilFuction.GetTime(DatePickerTo.SelectedDate.Value) + (TimeSpan.TicksPerDay / TimeSpan.TicksPerMillisecond - DatePickerFrom.SelectedDate.Value.TimeOfDay.TotalMilliseconds); } if (timeFrom >= timeTo) { timeFrom = 0; timeTo = DateTime.Now.Millisecond; } } } LVOrderInfo.Items.Clear(); foreach (KeyValuePair <int, Order> entry in OrderManager.getInstance().OrderList) { if (entry.Value != null) { if (listTableId.Count > 0 && !listTableId.Contains(entry.Value.TableId)) { continue; } if (UtilFuction.GetTime(entry.Value.CreatedDate) < timeFrom || UtilFuction.GetTime(entry.Value.CreatedDate) > timeTo) { continue; } var orderInfo = new OrderInfo(entry.Value.OrderId, null, this); LVOrderInfo.Items.Add(orderInfo); orderInfo.ExpandOrderInfo.IsExpanded = false; } } }
public void reloadAllUI() { reloadLVOrderWithFood(); var order = OrderManager.getInstance().OrderList[OrderId]; TextBlockHeader.Text = "Order " + OrderId; billMoney = order.BillMoney; BtnAccept.Visibility = Visibility.Hidden; BtnCancel.Visibility = Visibility.Hidden; ComboBoxSelectFood.clear(); foreach (KeyValuePair <int, Food> entry in FoodManager.getInstance().FoodList) { if (entry.Value != null) { bool isContinue = false; foreach (FoodWithOrder foodWithOrder in order.FoodWithOrders) { if (foodWithOrder.FoodId == entry.Value.FoodId) { isContinue = true; } } if (isContinue) { continue; } string txt = entry.Value.FoodId + " - " + entry.Value.Name; var imgSrc = (ImageSource)Application.Current.FindResource("ImageDefaultFood"); if (entry.Value.ImageId != null) { byte[] imgData = null; ImageManager.getInstance().loadImageFromLocal(entry.Value.ImageId ?? default(int), out imgData); if (imgData != null) { var img = UtilFuction.ByteToImage(imgData); imgSrc = UtilFuction.imageToBitmapSource(img); } } var item = ComboBoxSelectFood.addItem(txt, imgSrc); item.Tag = entry.Value.FoodId; } } onChangeMoney(); if (orderHistoryTab != null) { BtnAddFood.Visibility = Visibility.Hidden; TextBlockHeader.Text += (" - " + order.CreatedDate.ToShortDateString()) + " - " + UtilFuction.formatMoney(billMoney) + " VND"; } }
private void setupUI() { if (FoodData == null) { return; } TextBlockName.Text = FoodData.FoodId + " - " + FoodData.Name; TextBlockPrice.Text = UtilFuction.formatMoney(FoodData.Price) + " vnđ"; TextBlockCategory.Text = FoodCategorizeManager.getInstance().FoodCategorizeList[FoodData.FoodCategorizeId].Name; }
private bool loadImageFromLocal(int imageId) { try { var image = Image.FromFile(_fullImagePath + imageId.ToString()); _imagesData[imageId] = UtilFuction.ImageToBinary(image); } catch (Exception ex) { return(false); } return(true); }
public void exportBillAsPdf(string path, Order order) { if (order == null) { return; } try { FileStream fs = new FileStream(path + "\\Order" + order.OrderId.ToString() + ".pdf", FileMode.Create); Document document = new Document(PageSize.A4, 25, 25, 30, 30); PdfWriter writer = PdfWriter.GetInstance(document, fs); document.Open(); string orderStr = "Nhà hàng: " + RestaurantInfoManager.getInstance().Info.Name; orderStr += "\n" + "Số điện thoại: " + RestaurantInfoManager.getInstance().Info.Phone; orderStr += "\n" + "Địa chỉ: " + RestaurantInfoManager.getInstance().Info.Address; orderStr += "\n" + "Thời điểm: " + DateTime.Now.ToString("H:mm:ss dd/MM/yyyy"); orderStr += "\n\n" + " Hóa đơn bán hàng "; foreach (FoodWithOrder foodWithOrder in order.FoodWithOrders) { string strFoodName = foodWithOrder.Food.FoodId + "-" + foodWithOrder.Food.Name; string strQuantity = foodWithOrder.Quantities.ToString(); string strFoodPrice = "x " + UtilFuction.formatMoney(foodWithOrder.Food.Price); orderStr += "\n" + strFoodName + UtilFuction.getSpacesFromQuantityChar(50, strFoodName) + strQuantity + UtilFuction.getSpacesFromQuantityChar(10, strQuantity) + strFoodPrice + UtilFuction.getSpacesFromQuantityChar(10, strFoodPrice); } string totalStr = "TỔNG CỘNG: "; orderStr += "\n\n" + totalStr + UtilFuction.getSpacesFromQuantityChar(70, totalStr) + UtilFuction.formatMoney(order.BillMoney); orderStr += "\n\n\n Nếu quý khách có nhu cầu xuất hóa đơn, \n xin liên hệ với chúng tôi trong ngày."; iTextSharp.text.Font font = null; try { var vini = BaseFont.CreateFont("c:/windows/fonts/aachenb.ttf", BaseFont.IDENTITY_H, true); font = new iTextSharp.text.Font(vini, 14); } catch (Exception ex) { } if (font != null) { document.Add(new Paragraph(18, orderStr, font)); } else { document.Add(new Paragraph(16, orderStr, font)); } document.Close(); fs.Close(); } catch (Exception ex) { } }
public void setImageFood(System.Drawing.Image foodImage) { if (foodImage != null) { ImageFood.Source = UtilFuction.imageToBitmapSource(foodImage); } else { ImageFood.Source = (ImageSource)Application.Current.FindResource("ImageDefaultFood"); } }
public void setupOrderWithFoodUI() { if (_foodWithOrder != null) { textBlockName.Text = _foodWithOrder.Food.Name; TextBoxQuantity.Text = _foodWithOrder.Quantities.ToString(); TextBlockSinglePrice.Text = UtilFuction.formatMoney(_foodWithOrder.Food.Price); textBlockTotal.Text = UtilFuction.formatMoney(_foodWithOrder.Quantities * _foodWithOrder.Food.Price); previousQuantity = _foodWithOrder.Quantities; } }
public void onChangeMoney() { decimal totalMoney = 0; foreach (OrderInfo orderInfo in LVOrderInfo.Items.OfType <OrderInfo>()) { totalMoney += orderInfo.billMoney; } TextBlockTotalAllOrder.Text = "Thành tiền: " + UtilFuction.formatMoney(totalMoney) + " VND"; totalAllOrder = totalMoney; }
private void reloadTotalBill() { decimal totalBill = 0; var ingredientWithImportBillList = new List <IngredientWithImportBill>(); foreach (ImportIngredientCell importIngredientCell in LVIngredient.Items.OfType <ImportIngredientCell>()) { ingredientWithImportBillList.Add(importIngredientCell._ingredientWithImportBill); totalBill += (importIngredientCell._ingredientWithImportBill.SinglePricePerUnit * (decimal)importIngredientCell._ingredientWithImportBill.Quantities); } TextBlockTotal.Text = "Tổng cộng: " + UtilFuction.formatMoney(totalBill) + " VND"; }
public void reloadUI(ImportBill importBillRoot) { _importBill = importBillRoot; TextBoxId.Text = _importBill.ImportBillId.ToString(); TextBoxTime.Text = _importBill.CreatedDate.ToString(); TextBoxTotal.Text = UtilFuction.formatMoney(_importBill.BillMoney); LVIngredient.Items.Clear(); foreach (IngredientWithImportBill ingredient in _importBill.IngredientWithImportBills) { LVIngredient.Items.Add(new ImportIngredientCell(ingredient)); } }
private void checkAndReloadTotal() { decimal price = 0; decimal quantity = 0; if (!decimal.TryParse(TextBoxPrice.Text, out price) || !decimal.TryParse(TextBoxQuantity.Text, out quantity)) { TextBoxTotal.Text = "0"; return; } TextBoxTotal.Text = UtilFuction.formatMoney(price * quantity); }
private void BtnPickImage_Click(object sender, RoutedEventArgs e) { OpenFileDialog o = new OpenFileDialog(); o.Filter = "All Image Files|*.jpeg;*.png;*.jpg|All Files(*.*)|*.*"; if (o.ShowDialog() == true) { try { System.Drawing.Image i = System.Drawing.Image.FromFile(o.FileName); _currentImage = i; ImageFood.Source = UtilFuction.imageToBitmapSource(i); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void reloadUI() { if (_ingredientWithImportBill == null) { TextBlockIngredient.Text = "Error"; TextBlockPrice.Text = "Error"; TextBlockQuantity.Text = "Error"; TextBlockTotal.Text = "Error"; return; } TextBlockIngredient.Text = _ingredientWithImportBill.Ingredient.Name; TextBlockPrice.Text = UtilFuction.formatMoney(_ingredientWithImportBill.SinglePricePerUnit) + " / " + UnitManager.getInstance().UnitList[_ingredientWithImportBill.Ingredient.UnitId].Name; TextBlockQuantity.Text = _ingredientWithImportBill.Quantities.ToString(); TextBlockTotal.Text = UtilFuction.formatMoney((decimal)_ingredientWithImportBill.Quantities * _ingredientWithImportBill.SinglePricePerUnit); }
public void onChangeMoney() { decimal totalBill = 0; foreach (OrderWithFood orderWithFood in listViewOrderWithFood.Items.OfType <OrderWithFood>()) { decimal money = 0; decimal.TryParse(orderWithFood.textBlockTotal.Text, out money); totalBill += money; } TextBlockTotalOrder.Text = "Tổng cộng " + UtilFuction.formatMoney(totalBill); billMoney = totalBill; if (orderTab != null) { orderTab.onChangeMoney(); } }
private void setupUIWithFoodData(Food foodData) { TextBoxId.Text = foodData.FoodId.ToString(); TextBoxName.Text = foodData.Name; TextBoxPrice.Text = foodData.Price.ToString(); _currentImage = null; if (foodData.ImageId != null) { loadingAnim.Visibility = Visibility.Visible; _currentImageId = foodData.ImageId ?? default(int); ImageManager.getInstance().loadImage( _currentImageId, delegate(byte[] imageData) { if (imageData != null && imageData.Length > 0) { ImageFood.Source = UtilFuction.imageToBitmapSource(UtilFuction.ByteToImage(imageData)); } loadingAnim.Visibility = Visibility.Hidden; } ); } else { _currentImageId = -1; ImageFood.Source = (ImageSource)Application.Current.FindResource("ImageDefaultFood"); } ComboBoxCategory.SelectedValue = foodData.FoodCategorizeId; foreach (IngredientWithFood ingredientWithFood in foodData.IngredientWithFoods) { _ingredientsWithFood.Add(new IngredientWithFoodTable() { Id = ingredientWithFood.IngredientId, Name = IngredientManager.getInstance().IngredientList[ingredientWithFood.IngredientId].Name, UnitName = UnitManager.getInstance().UnitList[IngredientManager.getInstance().IngredientList[ingredientWithFood.IngredientId].UnitId].Name, Quantity = ingredientWithFood.Quantities }); } }
private void BtnConfirm_Click(object sender, RoutedEventArgs e) { if (((ComboData)ComboBoxCategory.SelectedItem) == null || String.IsNullOrEmpty(TextBoxName.Text) || String.IsNullOrEmpty(TextBoxPrice.Text)) { WindownsManager.getInstance().showMessageBoxCheckInfoAgain(); return; } if (_currentImage != null) { loadingAnim.Visibility = Visibility.Visible; ImageManager.getInstance().uploadImage( UtilFuction.ImageToBinary(_currentImage), delegate(NetworkResponse result) { if (result.Successful) { int imageId = -1; int.TryParse(result.Data.ToString(), out imageId); _currentImageId = imageId; updateOrCreateFood(); } else { WindownsManager.getInstance().showMessageBoxSomeThingWrong(); loadingAnim.Visibility = Visibility.Hidden; } }, delegate(string fail) { WindownsManager.getInstance().showMessageBoxErrorNetwork(); loadingAnim.Visibility = Visibility.Hidden; } ); } else { updateOrCreateFood(); } }
public void reloadListViewBill(bool isBaseOnFilter) { double timeFrom = 0; double timeTo = UtilFuction.GetTime(DateTime.Now); if (isBaseOnFilter) { if (CheckBoxFilterDate.IsChecked == true) { if (DatePickerFrom.SelectedDate != null) { timeFrom = UtilFuction.GetTime(DatePickerFrom.SelectedDate.Value) - DatePickerFrom.SelectedDate.Value.TimeOfDay.TotalMilliseconds; } if (DatePickerTo.SelectedDate != null) { timeTo = UtilFuction.GetTime(DatePickerTo.SelectedDate.Value) + (TimeSpan.TicksPerDay / TimeSpan.TicksPerMillisecond - DatePickerFrom.SelectedDate.Value.TimeOfDay.TotalMilliseconds); } if (timeFrom >= timeTo) { timeFrom = 0; timeTo = DateTime.Now.Millisecond; } } } LVBill.Items.Clear(); foreach (KeyValuePair <int, ImportBill> entry in ImportBillManager.getInstance().ImportBillList) { if (entry.Value != null) { if (UtilFuction.GetTime(entry.Value.CreatedDate) < timeFrom || UtilFuction.GetTime(entry.Value.CreatedDate) > timeTo) { continue; } var billCell = new ImportHistoryCell(entry.Value); LVBill.Items.Add(billCell); } } }
private void setupUI() { var foodId = _foodDetailId; var categorizeNames = new List <ComboData>(); foreach (KeyValuePair <int, FoodCategorize> entry in FoodCategorizeManager.getInstance().FoodCategorizeList) { if (entry.Value != null) { categorizeNames.Add(new ComboData() { Id = entry.Key, Value = entry.Value.Name }); } } ComboBoxCategory.ItemsSource = categorizeNames; ComboBoxCategory.DisplayMemberPath = "Value"; ComboBoxCategory.SelectedValuePath = "Id"; var ingredientsName = new List <ComboData>(); foreach (KeyValuePair <int, Ingredient> entry in IngredientManager.getInstance().IngredientList) { if (entry.Value != null) { ingredientsName.Add(new ComboData() { Id = entry.Key, Value = entry.Value.Name }); } } ComboBoxIngredient.ItemsSource = ingredientsName; ComboBoxIngredient.DisplayMemberPath = "Value"; ComboBoxIngredient.SelectedValuePath = "Id"; if (foodId != Constant.ID_CREATE_NEW) { var foodData = FoodManager.getInstance().FoodList[foodId]; setupUIWithFoodData(foodData); BtnConfirm.Content = "Sửa"; Title = "Sửa chi tiết món"; TextBlockTile.Text = "Sửa chi tiết món"; TextBlockId.Visibility = Visibility.Visible; TextBoxId.Visibility = Visibility.Visible; BtnCopy.Visibility = Visibility.Collapsed; ComboBoxFoodCopy.Visibility = Visibility.Collapsed; } else { foreach (KeyValuePair <int, Food> entry in FoodManager.getInstance().FoodList) { if (entry.Value != null) { string txt = entry.Value.FoodId + " - " + entry.Value.Name; var imgSrc = (ImageSource)Application.Current.FindResource("ImageDefaultFood"); if (entry.Value.ImageId != null) { byte[] imgData = null; ImageManager.getInstance().loadImageFromLocal(entry.Value.ImageId ?? default(int), out imgData); if (imgData != null) { var img = UtilFuction.ByteToImage(imgData); imgSrc = UtilFuction.imageToBitmapSource(img); } } var item = ComboBoxFoodCopy.addItem(txt, imgSrc); item.Tag = entry.Value.FoodId; } } } }
private UserInfo load() { var filePath = getFilePath(); return(UtilFuction.ReadFromBinaryFile <UserInfo>(filePath)); }
private void calculateAndReloadChart() { var rp = ReportManager.getInstance().ReportModel; var orders = ReportManager.getInstance().ReportModel.payOrders.ToList(); Dictionary <string, int> valuesByTimes = new Dictionary <string, int>(); ChartTime chartTime = ChartTime.ChartByHourse; if (rp.startDate == rp.endDate) //gio { chartTime = ChartTime.ChartByHourse; for (int i = 0; i < 24; i++) { valuesByTimes[i.ToString()] = 0; } } else if ((rp.endDate - rp.startDate).TotalDays >= 735) // nam { chartTime = ChartTime.ChartByYear; for (int i = rp.startDate.Year; i <= rp.endDate.Year; i++) { valuesByTimes[i.ToString()] = 0; } } else if ((rp.endDate - rp.startDate).TotalDays >= 24) // thang { chartTime = ChartTime.ChartByMonth; for (int i = rp.startDate.Year; i <= rp.endDate.Year; i++) { for (int j = 1; j <= 12; j++) { var month = new DateTime(i, j, 1); var monthTs = UtilFuction.GetTime(month); var startTs = UtilFuction.GetTime(rp.startDate) - TimeSpan.TicksPerDay * 31 * 10000; var endTs = UtilFuction.GetTime(rp.endDate); if (startTs <= monthTs && endTs >= monthTs) { valuesByTimes[j.ToString("D2") + '/' + i.ToString()] = 0; } } } } else //ngay { chartTime = ChartTime.ChartByDate; for (int i = rp.startDate.Year; i <= rp.endDate.Year; i++) { for (int j = 1; j <= 12; j++) { var totalDay = DateTime.DaysInMonth(i, j); for (int z = 1; z <= totalDay; z++) { var day = new DateTime(i, j, z); var dayTs = UtilFuction.GetTime(day); var startTs = UtilFuction.GetTime(rp.startDate); var endTs = UtilFuction.GetTime(rp.endDate); if (startTs <= dayTs && endTs >= dayTs) { valuesByTimes[z.ToString("D2") + '/' + j.ToString("D2")] = 0; } } } } } while (orders.Count > 0) { var frontOrder = orders[0]; switch (chartTime) { case ChartTime.ChartByHourse: { valuesByTimes[frontOrder.CreatedDate.TimeOfDay.Hours.ToString()] += 1; break; } case ChartTime.ChartByDate: { valuesByTimes[frontOrder.CreatedDate.ToString("dd/MM")] += 1; break; } case ChartTime.ChartByMonth: { valuesByTimes[frontOrder.CreatedDate.ToString("MM/yyyy")] += 1; break; } case ChartTime.ChartByYear: { valuesByTimes[frontOrder.CreatedDate.ToString("yyyy")] += 1; break; } } orders.RemoveAt(0); } List <KeyValuePair <string, int> > MyValue = new List <KeyValuePair <string, int> >(); foreach (KeyValuePair <string, int> entry in valuesByTimes) { MyValue.Add(new KeyValuePair <string, int>(entry.Key, entry.Value)); } //List<KeyValuePair<string, int>> MyValue = new List<KeyValuePair<string, int>>(); //MyValue.Add(new KeyValuePair<string, int>("Administration", 20)); //MyValue.Add(new KeyValuePair<string, int>("Management", 36)); //MyValue.Add(new KeyValuePair<string, int>("Development", 89)); //MyValue.Add(new KeyValuePair<string, int>("Support", 270)); //MyValue.Add(new KeyValuePair<string, int>("Sales", 140)); LineChart1.DataContext = MyValue; }
private RestaurantInfo load() { var filePath = getFilePath(); return(UtilFuction.ReadFromBinaryFile <RestaurantInfo>(filePath)); }
private void save(RestaurantInfo restaurantInfo) { var filePath = getFilePath(); UtilFuction.WriteToBinaryFile <RestaurantInfo>(filePath, restaurantInfo); }
private void save(UserInfo userInfo) { var filePath = getFilePath(); UtilFuction.WriteToBinaryFile <UserInfo>(filePath, userInfo); }
public void reloadUI() { TextBlockBillId.Text = "Hóa đơn #" + importBill.ImportBillId.ToString(); TextBlockTime.Text = importBill.CreatedDate.ToShortDateString(); TextBlockMoney.Text = UtilFuction.formatMoney(importBill.BillMoney); }
public void exportBillAsPdf(string path, Order order) { if (order == null) { return; } try { FileStream fs = new FileStream(path + "\\Order" + order.OrderId.ToString() + ".pdf", FileMode.Create); Document document = new Document(PageSize.A4, 25, 25, 30, 30); PdfWriter writer = PdfWriter.GetInstance(document, fs); document.Open(); string orderStr = "Nhà hàng: " + RestaurantInfoManager.getInstance().Info.Name; orderStr += "\n" + "Số điện thoại: " + RestaurantInfoManager.getInstance().Info.Phone; orderStr += "\n" + "Địa chỉ: " + RestaurantInfoManager.getInstance().Info.Address; orderStr += "\n" + "Thời điểm: " + DateTime.Now.ToString("H:mm:ss dd/MM/yyyy"); orderStr += "\n\n" + " Hóa đơn bán hàng "; var index = 1; foreach (FoodWithOrder foodWithOrder in order.FoodWithOrders) { string strFoodName = index + "-" + foodWithOrder.Food.Name; string strQuantity = foodWithOrder.Quantities.ToString(); string strFoodPrice = "x " + UtilFuction.formatMoney(foodWithOrder.Food.Price); orderStr += "\n" + strFoodName + UtilFuction.getSpacesFromQuantityChar(50, strFoodName) + strQuantity + UtilFuction.getSpacesFromQuantityChar(10, strQuantity) + strFoodPrice + UtilFuction.getSpacesFromQuantityChar(10, strFoodPrice); index++; } orderStr += "\n ========================================================================"; string totalStr = "TỔNG CỘNG: "; orderStr += "\n\n" + totalStr + UtilFuction.getSpacesFromQuantityChar(70, totalStr) + UtilFuction.formatMoney(order.BillMoney); //orderStr += "\n\n\n Nếu quý khách có nhu cầu xuất hóa đơn, \n xin liên hệ với chúng tôi trong ngày."; string appFolderPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); iTextSharp.text.Font font = null; try { string fontPath = Path.Combine(Directory.GetParent(appFolderPath).Parent.FullName, "Resource/Font/VT323-Regular.ttf"); var vini = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, true); font = new iTextSharp.text.Font(vini, 14); } catch (Exception ex) { } if (font != null) { document.Add(new Paragraph(18, orderStr, font)); } else { document.Add(new Paragraph(16, orderStr, font)); } document.Close(); fs.Close(); } catch (Exception ex) { Console.Write(ex.Message); } }