コード例 #1
0
        private void BtnAccountAdd_Click(object sender, RoutedEventArgs e)
        {
            SaverDefaultValue valSaver = new SaverDefaultValue();
            EditValue         wnd      = new EditValue();

            wnd.ShowDialog();
            if (wnd.Value == null)
            {
                return;
            }
            if (wnd.DialogResult == true)
            {
                using (DataModelContainer db = new DataModelContainer())
                {
                    Account val = new Account()
                    {
                        Name = wnd.Value
                    };
                    db.AccountSet.Add(val);
                    db.SaveChanges();
                    cbAccount.ItemsSource  = db.AccountSet.ToList();
                    cbAccount.SelectedItem = val;
                    if (wnd.Default)
                    {
                        valSaver.dic["account"] = db.AccountSet.FirstOrDefault(p => p.Name == wnd.Value).Id;
                        valSaver.Save();
                    }
                }
            }
        }
コード例 #2
0
        private void BtnAccountEdit_Click(object sender, RoutedEventArgs e)
        {
            SaverDefaultValue valSaver = new SaverDefaultValue();

            if (cbAccount.SelectedItem == null)
            {
                return;
            }
            Account   account = cbAccount.SelectedItem as Account;
            EditValue wnd     = new EditValue();

            wnd.Value = account.Name;
            wnd.ShowDialog();
            if (wnd.Value == null)
            {
                return;
            }
            if (wnd.DialogResult == true)
            {
                using (DataModelContainer db = new DataModelContainer())
                {
                    Account val = db.AccountSet.FirstOrDefault(a => a.Id == account.Id);
                    val.Name = wnd.Value;
                    db.SaveChanges();
                    cbAccount.ItemsSource  = db.AccountSet.ToList();
                    cbAccount.SelectedItem = val;
                    if (wnd.Default)
                    {
                        valSaver.dic["account"] = val.Id;
                        valSaver.Save();
                    }
                }
            }
        }
コード例 #3
0
        private void BtnOperationEdit_Click(object sender, RoutedEventArgs e)
        {
            SaverDefaultValue valSaver = new SaverDefaultValue();

            if (cbOperation.SelectedItem == null)
            {
                return;
            }
            OperationName operationName = cbOperation.SelectedItem as OperationName;
            EditValue     wnd           = new EditValue();

            wnd.Value = operationName.Name;
            wnd.ShowDialog();
            if (wnd.Value == null)
            {
                return;
            }
            if (wnd.DialogResult == true)
            {
                using (DataModelContainer db = new DataModelContainer())
                {
                    OperationName val = db.OperationNameSet.FirstOrDefault(a => a.Id == operationName.Id);
                    val.Name = wnd.Value;
                    db.SaveChanges();
                    cbOperation.ItemsSource  = db.OperationNameSet.ToList();
                    cbOperation.SelectedItem = val;
                    if (wnd.Default)
                    {
                        valSaver.dic["operation"] = val.Id;
                        valSaver.Save();
                    }
                }
            }
        }