private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { _oVCard = new ObservableCollection <T_OA_VEHICLECARD>(); T_OA_VEHICLECARD card = new T_OA_VEHICLECARD(); card.INVALIDDATE = DateTime.Today.AddYears(1); card.EFFECTDATE = DateTime.Today; card.CARDTYPE = "公司"; _oVCard.Add(card); dg.ItemsSource = _oVCard; dg.SelectedIndex = 0; }
//根据 回车键,判断 是否新增行,保存修改行 private void TextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (dg.SelectedIndex == _oVCard.Count - 1) { T_OA_VEHICLECARD card = new T_OA_VEHICLECARD(); card.INVALIDDATE = DateTime.Today.AddYears(1); card.EFFECTDATE = DateTime.Today; card.CARDTYPE = "公司"; _oVCard.Add(card); } } }
//获取加载停车卡信息 void Get_VICardCompleted(object sender, Get_VICardCompletedEventArgs e) { _oVCard = e.Result; if (_oVCard == null) _oVCard = new ObservableCollection<T_OA_VEHICLECARD>(); T_OA_VEHICLECARD card = new T_OA_VEHICLECARD(); card.INVALIDDATE = DateTime.Today.AddYears(1); card.EFFECTDATE = DateTime.Today; card.CARDTYPE = "公司"; //_oVCard.Add(card); dg.ItemsSource = _oVCard; dg.SelectedIndex = 0; }
//删除子表 private void Delete_Click(object sender, RoutedEventArgs e) { if (_oVCard.Count > 1) //必须有派车单,司机才能根据派车单提交费用 单 { T_OA_VEHICLECARD i = ((Button)sender).DataContext as T_OA_VEHICLECARD; _oVCard.Remove(i); if (i.VEHICLECARDID != null) //删除已经保存到服务器中的数据 { ObservableCollection <string> o = new ObservableCollection <string>(); o.Add(i.VEHICLECARDID); _VM.Del_VICardAsync(o); RefreshUI(RefreshedTypes.ProgressBar); } } }
//获取加载停车卡信息 void Get_VICardCompleted(object sender, Get_VICardCompletedEventArgs e) { _oVCard = e.Result; if (_oVCard == null) { _oVCard = new ObservableCollection <T_OA_VEHICLECARD>(); } T_OA_VEHICLECARD card = new T_OA_VEHICLECARD(); card.INVALIDDATE = DateTime.Today.AddYears(1); card.EFFECTDATE = DateTime.Today; card.CARDTYPE = "公司"; //_oVCard.Add(card); dg.ItemsSource = _oVCard; dg.SelectedIndex = 0; }
//行加载删除按钮 private void dg_LoadingRow(object sender, DataGridRowEventArgs e) { T_OA_VEHICLECARD tmp = (T_OA_VEHICLECARD)e.Row.DataContext; ImageButton MyButton_Delbaodao = dg.Columns[7].GetCellContent(e.Row).FindName("myDelete") as ImageButton; MyButton_Delbaodao.Margin = new Thickness(0); MyButton_Delbaodao.AddButtonAction("/SMT.SaaS.FrameworkUI;Component/Images/ToolBar/ico_16_delete.png", Utility.GetResourceStr("DELETE")); MyButton_Delbaodao.Tag = tmp; ComboBox cmb = dg.Columns[1].GetCellContent(e.Row).FindName("cmbType") as ComboBox; switch (tmp.CARDTYPE) { case "家里": cmb.SelectedIndex = 1; break; default: cmb.SelectedIndex = 0; break; } }
//根据 回车键,判断 是否新增行,保存修改行 private void TextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) if (dg.SelectedIndex == _oVCard.Count - 1) { T_OA_VEHICLECARD card = new T_OA_VEHICLECARD(); card.INVALIDDATE = DateTime.Today.AddYears(1); card.EFFECTDATE = DateTime.Today; card.CARDTYPE = "公司"; _oVCard.Add(card); } }
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { _oVCard = new ObservableCollection<T_OA_VEHICLECARD>(); T_OA_VEHICLECARD card = new T_OA_VEHICLECARD(); card.INVALIDDATE = DateTime.Today.AddYears(1); card.EFFECTDATE = DateTime.Today; card.CARDTYPE = "公司"; _oVCard.Add(card); dg.ItemsSource = _oVCard; dg.SelectedIndex = 0; }