Esempio n. 1
0
 /// <summary>
 /// 初始化农田作物控件
 /// </summary>
 /// <param name="cropData">绑定于种植作物的控件的数据源</param>
 /// <param name="cropInfo">为空时,表示是添加农田信息</param>
 public FieldCropTab(ObservableCollection<Crop> cropData, FieldCrop cropInfo, bool isCreateView = true)
 {
     InitializeComponent();
     _isCreateView = isCreateView;
     _cropInfo = cropInfo;
     esCrop.DataContext = new ExpanderSelectorDataContext(cropData.ToList<object>());
     _cropData = cropData;
     _cropNameList = cropData.Select(c => c.CropName).ToList<string>();
     if (!isCreateView)
     {
         esCrop.DefaultValue = _cropInfo.PlantingCropName;
         dpCreatedDate.Value = _cropInfo.PlantingDate;
         dpHarvestDate.Value = _cropInfo.HarvestDate;
         lpPlantCategory.SelectedIndex = _cropInfo.PlantingMethod.HasValue ? _cropInfo.PlantingMethod.Value : 0;
         txtFieldArea.Text = _cropInfo.PlantingArea.HasValue ? _cropInfo.PlantingArea.Value.ToString() : "0";
     }
 }
Esempio n. 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     _cropDataContext.GetAllCrops((data) =>
     {
         _cropData = data;
         _cropTabIndex++;
         string headerTxt = "作物" + _cropTabIndex;
         var fieldCrop = new FieldCrop();
         var content = new FieldCropTab(_cropData, fieldCrop);
         bodyPiv.Items.Add(new PivotItem
         {
             Header = headerTxt,
             Content = content,
         });
         _fieldCropList.Add(fieldCrop);
         bodyPiv.SelectedIndex = _cropTabIndex;
     });
 }