public static void AddMoney(Money _money) { bool exist = money.Where(cur => cur.currency == _money.currency).Any(); if(!exist) { money.Add(_money); appSetting.Add(new AppSetting { parentId = "000001", primaryCurrency = _money.currency, createAt = DateTime.Now, updateAt = DateTime.Now }); } }
partial void DeleteMoney(Money instance);
partial void UpdateMoney(Money instance);
partial void InsertMoney(Money instance);
private void Button_Click(object sender, RoutedEventArgs e) { string uid = (sender as Button).Uid; if (uid == "CurrencyAdd") { if (ValidateMoney()) { MoneySetup = new Money(); MoneySetup.Id = BranchMoney.Count.ToString(); MoneySetup.parentId = "000001"; MoneySetup.branch = Branch.code; MoneySetup.currency = cbCurrency.SelectedValue.ToString(); MoneySetup.total = decimal.Parse(StartingMoney.Text); MoneySetup.updatedAt = DateTime.Now; MoneySetup.createdAt = DateTime.Now; InitialSetupCollection.AddMoney(MoneySetup); StartingMoney.Clear(); cbCurrency.SelectedIndex = -1; } } else if (uid == "EditRow") { cbCurrency.SelectedItem = cbCurrency.Items.OfType<Currency>().FirstOrDefault(u => u.code == (sender as Button).Content.ToString()); Money _money = BranchMoney.FirstOrDefault(u => u.currency == (sender as Button).Content.ToString()); StartingMoney.Text = _money.total.ToString(); InitialSetupCollection.RemoveMoney(_money); } else if (uid == "RemoveRow") { Money _money = BranchMoney.FirstOrDefault(u => u.currency == (sender as Button).Content.ToString()); InitialSetupCollection.RemoveMoney(_money); } else if (uid == "ItemDownload") { ItemNextButton.Visibility = Visibility.Hidden; ProgCancelItem.Visibility = Visibility.Visible; string path = System.AppDomain.CurrentDomain.BaseDirectory + ITEM_TEMPLATE_EMPTY; if (System.IO.File.Exists(path)) ExportExcel_Item(path); } else if (uid == "ItemUpload") { ItemNextButton.Visibility = Visibility.Hidden; ProgCancelItem.Visibility = Visibility.Visible; OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Filter = "Item Template (.xlsx)|*.xlsx"; openDialog.DefaultExt = ".xlsx"; Nullable<bool> result = openDialog.ShowDialog(); if (result == true) { ProgCancelItem.Visibility = Visibility.Visible; ImportExcel_Item(openDialog.FileName); } } else if (uid == "GoldDownload") { JewelryNextButton.Visibility = Visibility.Hidden; ProgCancelGold.Visibility = Visibility.Visible; string path = System.AppDomain.CurrentDomain.BaseDirectory + GOLD_TEMPLATE_EMPTY; if (System.IO.File.Exists(path)) ExportExcel_Gold(path); } else if (uid == "StoneDownload") { JewelryNextButton.Visibility = Visibility.Hidden; ProgCancelStone.Visibility = Visibility.Visible; string path = System.AppDomain.CurrentDomain.BaseDirectory + STONE_TEMPLATE_EMPTY; if (System.IO.File.Exists(path)) ExportExcel_Stone(path); } else if (uid == "GoldUpload") { JewelryNextButton.Visibility = Visibility.Hidden; ProgCancelGold.Visibility = Visibility.Visible; OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Filter = "Gold Template (.xlsx)|*.xlsx"; openDialog.DefaultExt = ".xlsx"; Nullable<bool> result = openDialog.ShowDialog(); if (result == true) { ProgCancelGold.Visibility = Visibility.Visible; ImportExcel_Gold(openDialog.FileName); } } else if (uid == "StoneUpload") { JewelryNextButton.Visibility = Visibility.Hidden; ProgCancelStone.Visibility = Visibility.Visible; OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Filter = "Stone Template (.xlsx)|*.xlsx"; openDialog.DefaultExt = ".xlsx"; Nullable<bool> result = openDialog.ShowDialog(); if (result == true) { ProgCancelStone.Visibility = Visibility.Visible; ImportExcel_Stone(openDialog.FileName); } } }
public static void RemoveMoney(Money _money) { money.Remove(_money); AppSetting _appSet = appSetting.FirstOrDefault(pc => pc.primaryCurrency == _money.currency); appSetting.Remove(_appSet); }