private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { if (DaGrs.ItemsSource == null) { TraveDetailList_Golbal = new ObservableCollection <T_OA_BUSINESSTRIPDETAIL>(); T_OA_BUSINESSTRIPDETAIL buip = new T_OA_BUSINESSTRIPDETAIL(); buip.BUSINESSTRIPDETAILID = Guid.NewGuid().ToString(); buip.STARTDATE = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(1).Day, 8, 30, 0); buip.ENDDATE = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(1).Day, 17, 30, 0); TraveDetailList_Golbal.Add(buip); T_OA_BUSINESSTRIPDETAIL buipd = new T_OA_BUSINESSTRIPDETAIL(); buipd.BUSINESSTRIPDETAILID = Guid.NewGuid().ToString(); buipd.STARTDATE = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(2).Day, 8, 30, 0); buipd.ENDDATE = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(2).Day, 17, 30, 0); TraveDetailList_Golbal.Add(buipd); DaGrs.ItemsSource = TraveDetailList_Golbal; DaGrs.SelectedIndex = 0; } //if (!string.IsNullOrEmpty(Master_Golbal.BUSINESSTRIPID)) //{ // //ctrFile.Load_fileData(Master_Golbal.BUSINESSTRIPID); //} }
/// <summary> /// 查看或审核时用(不显示DataGrid模板中的控件只显示数据) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DaGrss_LoadingRow(object sender, DataGridRowEventArgs e) { T_OA_BUSINESSTRIPDETAIL tmp = (T_OA_BUSINESSTRIPDETAIL)e.Row.DataContext; TextBlock TxtMyCity = DaGridReadOnly.Columns[1].GetCellContent(e.Row).FindName("tbDEPARTURECITY") as TextBlock; TextBlock TxtMyCitys = DaGridReadOnly.Columns[3].GetCellContent(e.Row).FindName("tbTARGETCITIES") as TextBlock; CheckBox IsCheck = DaGridReadOnly.Columns[7].GetCellContent(e.Row).FindName("myChkBox") as CheckBox; CheckBox IsCheckMeet = DaGridReadOnly.Columns[8].GetCellContent(e.Row).FindName("myChkBoxMeet") as CheckBox; CheckBox IsCheckCar = DaGridReadOnly.Columns[9].GetCellContent(e.Row).FindName("myChkBoxCar") as CheckBox; TextBlock TxtComVechile = DaGridReadOnly.Columns[4].GetCellContent(e.Row).FindName("tbComVechileType") as TextBlock; TextBlock TxtComLevel = DaGridReadOnly.Columns[5].GetCellContent(e.Row).FindName("tbComVechileTypeLeve") as TextBlock; Brush tempcomTypeForeBrush; Brush tempcomLevelForeBrush; if (BtnNewButton == true) { TxtMyCitys.Text = string.Empty; //citysStartList_Golbal.Add(tmp.DEPCITY); } else { BtnNewButton = false; } TxtMyCity.Tag = tmp; TxtMyCitys.Tag = tmp; //对默认颜色进行赋值 tempcomTypeForeBrush = TxtComVechile.Foreground; tempcomLevelForeBrush = TxtComLevel.Foreground; ObservableCollection <T_OA_BUSINESSTRIPDETAIL> objs = DaGridReadOnly.ItemsSource as ObservableCollection <T_OA_BUSINESSTRIPDETAIL>; if (formType != FormTypes.New) { if (DaGridReadOnly.ItemsSource != null && TraveDetailList_Golbal != null) { int j = 0; foreach (var TraveDetailRow in objs) { StandardsMethod(j); j++; if (TraveDetailRow.BUSINESSTRIPDETAILID == tmp.BUSINESSTRIPDETAILID) //判断记录的ID是否相同 { if (TxtMyCity != null) //出发城市 { if (TraveDetailRow.DEPCITY != null) { TxtMyCity.Text = GetCityName(TraveDetailRow.DEPCITY); } } if (TxtMyCitys != null)//目标城市 { if (TraveDetailRow.DESTCITY != null) { TxtMyCitys.Text = GetCityName(TraveDetailRow.DESTCITY); } } if (TraveDetailRow.TYPEOFTRAVELTOOLS != null)//交通工具类型 { TxtComVechile.Text = GetTypeName(TraveDetailRow.TYPEOFTRAVELTOOLS); } if (TraveDetailRow.TAKETHETOOLLEVEL != null)//交通工具级别 { TxtComLevel.Text = GetLevelName(TraveDetailRow.TAKETHETOOLLEVEL, GetTypeId(TraveDetailRow.TYPEOFTRAVELTOOLS)); } if (TraveDetailRow.PRIVATEAFFAIR == "1")//私事 { IsCheck.IsChecked = true; } if (TraveDetailRow.GOOUTTOMEET == "1")//外出开会 { IsCheckMeet.IsChecked = true; } if (TraveDetailRow.COMPANYCAR == "1")//公司派车 { IsCheckCar.IsChecked = true; } } else { continue; } if (TxtComVechile != null) { if (TraveDetailRow.TYPEOFTRAVELTOOLS == null) { ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("交通工具有误,请审核不通过"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation); TxtComVechile.Foreground = new SolidColorBrush(Colors.Red); continue; } if (TraveDetailRow.TAKETHETOOLLEVEL == null) { ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("交通工具级别有误,请审核不通过"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation); TxtComLevel.Foreground = new SolidColorBrush(Colors.Red); continue; } //获取交通工具类型 int i = CheckTraveToolStand(TraveDetailRow.TYPEOFTRAVELTOOLS.ToString(), TraveDetailRow.TAKETHETOOLLEVEL.ToString(), Master_Golbal.POSTLEVEL); switch (i) { case 0: //类型超标 TxtComVechile.Foreground = new SolidColorBrush(Colors.Red); TxtComLevel.Foreground = new SolidColorBrush(Colors.Red); break; case 1: //级别超标 TxtComLevel.Foreground = new SolidColorBrush(Colors.Red); break; case 2: //没超标 break; } } } } } }
void btnNew_Click(object sender, RoutedEventArgs e) { if (!CheckIsFinishedCitys()) { return; } BtnNewButton = true; T_OA_BUSINESSTRIPDETAIL NewBussnessTripDetail = new T_OA_BUSINESSTRIPDETAIL(); NewBussnessTripDetail.BUSINESSTRIPDETAILID = Guid.NewGuid().ToString(); if (TraveDetailList_Golbal.Count() > 0) { try { //新的赋值方式,开始城市,开始时间 NewBussnessTripDetail.STARTDATE = TraveDetailList_Golbal[TraveDetailList_Golbal.Count() - 1].ENDDATE; NewBussnessTripDetail.DEPCITY = TraveDetailList_Golbal[TraveDetailList_Golbal.Count() - 1].DESTCITY; //到达城市,时间默认值 NewBussnessTripDetail.DESTCITY = TraveDetailList_Golbal[0].DEPCITY; NewBussnessTripDetail.ENDDATE = TraveDetailList_Golbal[TraveDetailList_Golbal.Count() - 1].ENDDATE.Value.AddDays(1); TraveDetailList_Golbal.Add(NewBussnessTripDetail); //citysStartList_Golbal.Add(NewBussnessTripDetail.DEPCITY); //citysEndList_Golbal.Add(NewBussnessTripDetail.DESTCITY); DaGrs.ItemsSource = TraveDetailList_Golbal; //禁用此记录开始城市选择控件 if (DaGrs.Columns[1].GetCellContent(NewBussnessTripDetail) == null) return; SearchCity myCity = DaGrs.Columns[1].GetCellContent(NewBussnessTripDetail).FindName("txtDEPARTURECITY") as SearchCity; if (myCity != null) { myCity.TxtSelectedCity.Text = SMT.SaaS.FrameworkUI.Common.Utility.GetCityName(NewBussnessTripDetail.DEPCITY); myCity.IsEnabled = false; ((DataGridCell)((StackPanel)myCity.Parent).Parent).IsEnabled = false; } int lastIndex = TraveDetailList_Golbal.Count() - 1; StandardsMethod(lastIndex);//显示选中的城市的出差标准 } catch (Exception ex) { Utility.SetLog(ex.ToString()); } //旧的赋值方式 } }
private void DaGrs_LoadingRow(object sender, DataGridRowEventArgs e) { try { T_OA_BUSINESSTRIPDETAIL tmp = (T_OA_BUSINESSTRIPDETAIL)e.Row.DataContext; ImageButton MyButton_Delbaodao = DaGrs.Columns[10].GetCellContent(e.Row).FindName("myDelete") as ImageButton; SearchCity myCity = DaGrs.Columns[1].GetCellContent(e.Row).FindName("txtDEPARTURECITY") as SearchCity; SearchCity myCitys = DaGrs.Columns[3].GetCellContent(e.Row).FindName("txtTARGETCITIES") as SearchCity; CheckBox IsCheck = DaGrs.Columns[7].GetCellContent(e.Row).FindName("myChkBox") as CheckBox; CheckBox IsCheckMeet = DaGrs.Columns[8].GetCellContent(e.Row).FindName("myChkBoxMeet") as CheckBox; CheckBox IsCheckCar = DaGrs.Columns[9].GetCellContent(e.Row).FindName("myChkBoxCar") as CheckBox; TravelDictionaryComboBox ComVechile = DaGrs.Columns[4].GetCellContent(e.Row).FindName("ComVechileType") as TravelDictionaryComboBox; TravelDictionaryComboBox ComLevel = DaGrs.Columns[5].GetCellContent(e.Row).FindName("ComVechileTypeLeve") as TravelDictionaryComboBox; if (BtnNewButton == true) { myCitys.TxtSelectedCity.Text = string.Empty; //citysStartList_Golbal.Add(tmp.DEPCITY); } else { BtnNewButton = false; } 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; myCity.Tag = tmp; myCitys.Tag = tmp; ComVechile.SelectedIndex = 0; ComLevel.SelectedIndex = 0; //对默认颜色进行赋值 tempcomTypeBorderBrush = ComVechile.BorderBrush; tempcomTypeForeBrush = ComVechile.Foreground; tempcomLevelBorderBrush = ComLevel.BorderBrush; tempcomLevelForeBrush = ComLevel.Foreground; ObservableCollection <T_OA_BUSINESSTRIPDETAIL> objs = DaGrs.ItemsSource as ObservableCollection <T_OA_BUSINESSTRIPDETAIL>; if (formType != FormTypes.New) { int j = 0; if (DaGrs.ItemsSource != null && TraveDetailList_Golbal != null) { foreach (var obje in objs) { StandardsMethod(j); j++; if (obje.BUSINESSTRIPDETAILID == tmp.BUSINESSTRIPDETAILID) //判断记录的ID是否相同 { if (myCity != null) //出发城市 { if (obje.DEPCITY != null) { myCity.TxtSelectedCity.Text = GetCityName(obje.DEPCITY); if (TraveDetailList_Golbal.Count() > 1) { if (j > 1) { //By : Sam //Date: 2011-9-6 //For : 此处之前设置双击的时候还会出现打开状态 myCity.IsEnabled = false; ((DataGridCell)((StackPanel)myCity.Parent).Parent).IsEnabled = false; } } } } if (myCitys != null)//目标城市 { if (obje.DESTCITY != null) { myCitys.TxtSelectedCity.Text = GetCityName(obje.DESTCITY); } } if (obje.PRIVATEAFFAIR == "1")//私事 { IsCheck.IsChecked = true; } if (obje.GOOUTTOMEET == "1")//外出开会 { IsCheckMeet.IsChecked = true; } if (obje.COMPANYCAR == "1")//公司派车 { IsCheckCar.IsChecked = true; } } else { continue; } string dictid = ""; //获取交通工具类型、级别 if (ComVechile != null) { T_SYS_DICTIONARY type = new T_SYS_DICTIONARY(); T_SYS_DICTIONARY level = new T_SYS_DICTIONARY(); type = ComVechile.SelectedItem as T_SYS_DICTIONARY; level = ComLevel.SelectedItem as T_SYS_DICTIONARY; var thd = transportToolStand.FirstOrDefault(); if (type != null) { thd = this.GetVehicleTypeValue(type.DICTIONARYVALUE.ToString()); foreach (T_SYS_DICTIONARY Region in ComVechile.Items) { if (thd != null) { dictid = Region.DICTIONARYID; if (Region.DICTIONARYVALUE.ToString() == tmp.TYPEOFTRAVELTOOLS) { if (transportToolStand.Count() > 0) { ComVechile.SelectedItem = Region; if (thd.TYPEOFTRAVELTOOLS.ToInt32() > Region.DICTIONARYVALUE) { ComVechile.BorderBrush = new SolidColorBrush(Colors.Red); ComVechile.Foreground = new SolidColorBrush(Colors.Red); ComLevel.BorderBrush = new SolidColorBrush(Colors.Red); ComLevel.Foreground = new SolidColorBrush(Colors.Red); } if (thd.TYPEOFTRAVELTOOLS.ToInt32() <= Region.DICTIONARYVALUE) { if (tempcomTypeBorderBrush != null) { ComVechile.BorderBrush = tempcomTypeBorderBrush; } if (tempcomTypeForeBrush != null) { ComVechile.Foreground = tempcomTypeForeBrush; } } break; } } } } } } if (ComLevel != null) { var ents = from ent in ListVechileLevel where ent.T_SYS_DICTIONARY2.DICTIONARYID == dictid select ent; ComLevel.ItemsSource = ents.ToList(); if (ents.Count() > 0) { T_SYS_DICTIONARY type = new T_SYS_DICTIONARY(); T_SYS_DICTIONARY level = new T_SYS_DICTIONARY(); type = ComVechile.SelectedItem as T_SYS_DICTIONARY; level = ComLevel.SelectedItem as T_SYS_DICTIONARY; var thd = transportToolStand.FirstOrDefault(); if (type != null) { thd = this.GetVehicleTypeValue(type.DICTIONARYVALUE.ToString()); } if (thd != null) { foreach (T_SYS_DICTIONARY RegionLevel in ComLevel.Items) { if (RegionLevel.DICTIONARYVALUE.ToString() == tmp.TAKETHETOOLLEVEL) { ComLevel.SelectedItem = RegionLevel; if (thd.TAKETHETOOLLEVEL.ToInt32() <= RegionLevel.DICTIONARYVALUE) { if (tempcomLevelForeBrush != null) { ComLevel.Foreground = tempcomLevelForeBrush; } if (tempcomLevelBorderBrush != null) { ComLevel.BorderBrush = tempcomLevelBorderBrush; } } else { if (thd.TAKETHETOOLLEVEL.ToInt32() > RegionLevel.DICTIONARYVALUE) { ComLevel.BorderBrush = new SolidColorBrush(Colors.Red); ComLevel.Foreground = new SolidColorBrush(Colors.Red); return; } else { if (tempcomLevelForeBrush != null) { ComLevel.Foreground = tempcomLevelForeBrush; } if (tempcomLevelBorderBrush != null) { ComLevel.BorderBrush = tempcomLevelBorderBrush; } } } break; } } } }// ComLevel != null } } } } } catch (Exception ex) { SMT.SAAS.Main.CurrentContext.AppContext.SystemMessage("出差申请DaGrs_LoadingRow异常:" + ex.ToString()); SMT.SAAS.Main.CurrentContext.AppContext.ShowSystemMessageText(); } }