private void InitData()
 {
     try
     {
         string message;
         PurchaseUnits = PharmacyDatabaseService.AllPurchaseUnits(out message)
                         .ToList();
         PurchaseUnits.Insert(0, new PurchaseUnit {
             Id = Guid.Empty, Name = "请您选择..."
         });
         queryModel                = new QueryPurchaseUnitBuyerModel();
         queryModel.OutDateFrom    = TypesDefaultValues.MaxDateTime;
         queryModel.OutDateTo      = TypesDefaultValues.MinDateTime;
         queryModel.BirthdayFrom   = TypesDefaultValues.MaxDateTime;
         queryModel.BirthdayTo     = TypesDefaultValues.MinDateTime;
         queryModel.CreateTimeFrom = TypesDefaultValues.MaxDateTime;
         queryModel.CreateTimeTo   = TypesDefaultValues.MinDateTime;
         queryModel.UpdateTimeFrom = TypesDefaultValues.MaxDateTime;
         queryModel.UpdateTimeTo   = TypesDefaultValues.MinDateTime;
     }
     catch (Exception ex)
     {
         ex = new Exception("初始化数据失败", ex);
         Log.Error(ex);
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void InitData()
        {
            try
            {
                string message;
                switch (RunMode)
                {
                case FormRunMode.Add:
                    Entity              = new PurchaseUnitBuyer();
                    Entity.Birthday     = TypesDefaultValues.MinDateTime;
                    Entity.CreateTime   = DateTime.Now;
                    Entity.CreateUserId = AppClientContext.CurrentUser.Id;
                    Entity.Deleted      = false;
                    Entity.Enabled      = true;
                    Entity.Gender       = "男";
                    Entity.OutDate      = TypesDefaultValues.MaxDateTime;
                    Entity.UpdateTime   = DateTime.Now;
                    Entity.UpdateUserId = AppClientContext.CurrentUser.Id;
                    break;

                case FormRunMode.Edit:
                    break;

                case FormRunMode.Browse:
                    break;

                case FormRunMode.Search:
                    break;

                case FormRunMode.Delete:
                    break;

                default:
                    break;
                }

                //初始化字典数据
                PurchaseUnits = PharmacyDatabaseService.AllPurchaseUnits(out message).ToList();
                PurchaseUnits.Insert(0, new PurchaseUnit {
                    Id = Guid.Empty, Name = "请您选择..."
                });
                Districts = PharmacyDatabaseService.AllDistricts(out message).ToList();
                Districts.Insert(0, new District {
                    Id = Guid.Empty, Name = "请您选择..."
                });
                Genders = new List <ListItem>();
                Genders.Add(new ListItem {
                    ID = "-1", Name = "未知"
                });
                Genders.Add(new ListItem {
                    ID = "1", Name = "男"
                });
                Genders.Add(new ListItem {
                    ID = "0", Name = "女"
                });
                PurchaseLimitTypes = EnumHelper <PurchaseLimitType> .GetMapKeyValues();
            }
            catch (Exception ex)
            {
                ex = new Exception("初始化数据失败", ex);
                Log.Error(ex);
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }