private void InsertCustomerPriceClickExecute() { if (NewCustomerPrice <= 0) { MessageBox.Show("設定的客戶單價不正確!!"); return; } bool newDefaultPriceSuccess = false; if (SelectedCustomerCheckBillSheet.DefaultPrice == 0) { List <AccountTextile> accountTextile = new List <AccountTextile>() { new AccountTextile { FactoryID = SelectedCustomerCheckBillSheet.F_01, ItemID = SelectedCustomerCheckBillSheet.I_01, ItemName = SelectedCustomerCheckBillSheet.I_03, DefaultPrice = Convert.ToInt32(SelectedCustomerCheckBillSheet.Price) } }; newDefaultPriceSuccess = AccountSystemModule.InsertDefaultPrice(accountTextile); } IEnumerable <AccountTextile> accountTextiles = AccountSystemModule.GetAccountTextile(); CustomerTextilePrice customerTextilePrice = new CustomerTextilePrice { AccountTextileID = accountTextiles.Where(w => w.FactoryID == SelectedCustomerCheckBillSheet.F_01 && w.ItemID == SelectedCustomerCheckBillSheet.I_01).FirstOrDefault().AccountTextileID, AccountCustomerID = SelectedTrashCustomer.CARD_NO, Price = NewCustomerPrice }; if (!AccountSystemModule.GetCustomerTextilePrice(SelectedCustomerCheckBillSheet.C_01).Any(a => a.AccountTextileID == SelectedCustomerCheckBillSheet.AccountTextileID)) { bool success = AccountSystemModule.InsertCustomerTextilePrice(customerTextilePrice); if (success) { bool updateTrashSystemsuccess = UpdateTrashSystemPrice(SelectedCustomerCheckBillSheet, NewCustomerPrice); if (updateTrashSystemsuccess) { DisplayUpdate(newDefaultPriceSuccess, NewCustomerPrice); MessageBox.Show("新增客戶單價成功!"); } else { MessageBox.Show("帳務系統新增失敗!!", "錯誤!", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("新增失敗!!", "錯誤!", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("已設定過該客戶的布種單價,請使用更新單價功能!!"); } }
public DefaultPriceViewModel() { IEnumerable <TrashItem> trashItemList = TrashModule.GetTrashItems(); IEnumerable <AccountTextile> accountTextileList = AccountSystemModule.GetAccountTextile(); IEnumerable <AccountTextile> accountTextiles = from trashItems in trashItemList join accountTextile in accountTextileList on new { x1 = trashItems.F_01, x2 = trashItems.I_01 } equals new { x1 = accountTextile.FactoryID, x2 = accountTextile.ItemID } into leftjoin from trashItemListLeft in leftjoin.DefaultIfEmpty() select new AccountTextile { ItemID = trashItems.I_01, FactoryID = trashItems.F_01, ItemName = trashItems.I_03, DefaultPrice = trashItemListLeft == null ? 0 : trashItemListLeft.DefaultPrice }; AccountTextiles = new ObservableCollection <AccountTextile>(accountTextiles); }
private void ButtonUpdateDefaultPriceClickExecute() { if (AccountTextileList.Count() == 0) { MessageBox.Show("未選取要新增的布種!", "錯誤!", MessageBoxButton.OK, MessageBoxImage.Error); return; } bool success = AccountSystemModule.InsertDefaultPrice(AccountTextileList); if (success) { MessageBox.Show("新增成功!"); } else { MessageBox.Show("新增失敗!", "錯誤!", MessageBoxButton.OK, MessageBoxImage.Error); } AccountTextileList.Clear(); }
private void ComboBoxCustomerSelectionChangedExecute() { if (priviousTrashCustomer == SelectedTrashCustomer && priviousCheckBillDate.ToString("yyyy/MM") == CheckBillDate.ToString("yyyy/MM")) { return; } if (SelectedTrashCustomer == null) { return; } ; priviousTrashCustomer = SelectedTrashCustomer; priviousCheckBillDate = CheckBillDate; List <TrashCustomerShipped> invoSubList = new List <TrashCustomerShipped>(TrashModule.GetInvoSub(CheckBillDate) .Where(w => w.C_01 == SelectedTrashCustomer.CARD_NO)); IEnumerable <AccountTextile> accountTextiles = AccountSystemModule.GetAccountTextile(); IEnumerable <CustomerTextilePrice> customerTextilePrices = AccountSystemModule.GetCustomerTextilePrice(SelectedTrashCustomer.CARD_NO); IEnumerable <CustomerCheckBillSheet> customerCheckBillSheets = AccountSystemModule.GetCheckBillSheet(accountTextiles, customerTextilePrices, invoSubList).OrderBy(o => o.IN_DATE).ThenBy(t => t.Time); CustomerCheckBillSheets = new ObservableCollection <CustomerCheckBillSheet>(customerCheckBillSheets); OnPropertyChanged("CustomerCheckBillSheets"); }
private void UpdateCustomerPriceClickExecute() { if (UpdateCustomerPrice <= 0) { MessageBox.Show("欲更新的單價設定錯誤!!"); return; } if (SelectedCustomerCheckBillSheets == null) { MessageBox.Show("未選擇欲更新的布種!"); return; } if (SelectedCustomerCheckBillSheets.Where(w => w.CustomerPrice == 0).Count() > 0) { MessageBox.Show("此客戶的布種尚未設定單價!!"); return; } int successUpdateCustomerTextilePriceCount = 0; List <CustomerCheckBillSheet> UpdateCustomerTextilePriceError = new List <CustomerCheckBillSheet>(); List <CustomerCheckBillSheet> UpdateTrashSystemPriceError = new List <CustomerCheckBillSheet>(); foreach (CustomerCheckBillSheet item in SelectedCustomerCheckBillSheets) { bool success = AccountSystemModule.UpdateCustomerTextilePrice(item, UpdateCustomerPrice); if (success) { successUpdateCustomerTextilePriceCount++; item.CustomerPrice = UpdateCustomerPrice; } else { UpdateCustomerTextilePriceError.Add(item); } } if (successUpdateCustomerTextilePriceCount == SelectedCustomerCheckBillSheets.Count()) { int successUpdateTrashSystemPriceCount = 0; foreach (var item in SelectedCustomerCheckBillSheets) { bool updateTrashSystemsuccess = UpdateTrashSystemPrice(item, UpdateCustomerPrice); if (updateTrashSystemsuccess) { successUpdateTrashSystemPriceCount++; } else { UpdateTrashSystemPriceError.Add(item); } } if (successUpdateTrashSystemPriceCount == SelectedCustomerCheckBillSheets.Count()) { DisplayUpdate(successUpdateCustomerTextilePriceCount == SelectedCustomerCheckBillSheets.Count(), UpdateCustomerPrice); MessageBox.Show("更新客戶單價成功!"); } else { MessageBox.Show("帳務系統更新失敗!!", "錯誤!", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("更新失敗!!\n" + string.Join("\n", UpdateCustomerTextilePriceError.Select(s => s.I_03)), "錯誤!", MessageBoxButton.OK, MessageBoxImage.Error); } }