private void AddMainType(object sender, RoutedEventArgs e) { if (TextBoxMainType.Text.Length > 0) { string name = TextBoxMainType.Text; Main_type MainItem = new Main_type { Name = name }; Sub_type defaultSubItem = new Sub_type { Name = name }; App.APPDB.Main_type.InsertOnSubmit(MainItem); try { APPDB.SubmitChanges(); defaultSubItem.Pid = MainItem.Id; APPDB.Sub_type.InsertOnSubmit(defaultSubItem); APPDB.SubmitChanges(); MainTypeList.Add(MainItem); } catch (Exception ex) { MessageBox.Show("数据保存失败"); } } this.Focus(); }
private void listPickerSubType_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listPickerSubType.ItemsSource == null) { return; } Sub_type item = listPickerSubType.SelectedItem as Sub_type; sTypeId = item.Id; }
private void DeleSubType(object sender, RoutedEventArgs e) { Sub_type subTypeItem = (Sub_type)(sender as Button).Tag; if (SubTypeList.Count == 1) { subTypeItem.Name = "默认" + App.MainTypeName; } else { //APPDB.Sub_type.DeleteOnSubmit(subTypeItem); subTypeItem.Delete = 1; SubTypeList.Remove(subTypeItem); } APPDB.SubmitChanges(); this.Focus(); }
private void AddSubTypeClick(object sender, RoutedEventArgs e) { if (TextBoxSubType.Text.Length > 0) { string name = TextBoxSubType.Text; Sub_type SubTypeItem = new Sub_type{Name = name,Pid=pid}; APPDB.Sub_type.InsertOnSubmit(SubTypeItem); try { APPDB.SubmitChanges(); SubTypeList.Add(SubTypeItem); } catch (Exception ex) { MessageBox.Show("数据库错误,请尝试重新安装应用。"); } TextBoxSubType.Text = ""; this.Focus(); } }
private void AddSubTypeClick(object sender, RoutedEventArgs e) { if (TextBoxSubType.Text.Length > 0) { string name = TextBoxSubType.Text; Sub_type SubTypeItem = new Sub_type { Name = name, Pid = pid }; APPDB.Sub_type.InsertOnSubmit(SubTypeItem); try { APPDB.SubmitChanges(); SubTypeList.Add(SubTypeItem); } catch (Exception ex) { MessageBox.Show("数据库错误,请尝试重新安装应用。"); } TextBoxSubType.Text = ""; this.Focus(); } }
private void AddMainType(object sender, RoutedEventArgs e) { if (TextBoxMainType.Text.Length > 0) { string name = TextBoxMainType.Text; Main_type MainItem = new Main_type { Name=name}; Sub_type defaultSubItem = new Sub_type { Name = name }; App.APPDB.Main_type.InsertOnSubmit(MainItem); try { APPDB.SubmitChanges(); defaultSubItem.Pid = MainItem.Id; APPDB.Sub_type.InsertOnSubmit(defaultSubItem); APPDB.SubmitChanges(); MainTypeList.Add(MainItem); } catch (Exception ex) { MessageBox.Show("数据保存失败"); } } this.Focus(); }
partial void DeleteSub_type(Sub_type instance);
partial void UpdateSub_type(Sub_type instance);
partial void InsertSub_type(Sub_type instance);
partial void DeleteSub_type(Sub_type instance);
partial void UpdateSub_type(Sub_type instance);
partial void InsertSub_type(Sub_type instance);