private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            //获取省级列表
            List <Region> response = new ApiImpl().GetRegion("2", "1");

            if (response != null)
            {
                com_province.ItemsSource = response;
            }
        }
        private void WindowX_Loaded(object sender, RoutedEventArgs e)
        {
            ResponseInformationModel response = new ApiImpl().GetInformation();

            if (response != null)
            {
                this.ChargeStandard.Text = Convert.ToString(response.ChargeStandard);
                this.ChargeDays.Text     = Convert.ToString(response.ChargeDays);
            }
        }
        private void GetVillage(ComboBoxModel p)
        {
            VillageCB = null;
            if (p == null)
            {
                return;
            }
            userInfoModel.Street = p.Name;
            List <ComboBoxModel> data = new ApiImpl().GetVillageRegion(p.Id.ToString());

            if (data != null)
            {
                VillageCB = new ObservableCollection <ComboBoxModel>(data);
            }
        }
        private void GetContory(ComboBoxModel p)
        {
            ContoryCB = null;
            StreetCB  = null;
            VillageCB = null;
            if (p == null)
            {
                return;
            }
            userInfoModel.City = p.Name;
            List <ComboBoxModel> data = new ApiImpl().GetCountryRegion(p.Id.ToString());

            if (data != null)
            {
                ContoryCB = new ObservableCollection <ComboBoxModel>(data);
            }
        }
        ///// <summary>
        ///// 自动登录
        ///// </summary>
        //public bool AutomaticLogon { get { return automaticLogon; } set { this.SetProperty(ref this.automaticLogon,value);} }
        ///// <summary>
        ///// 是否记住密码
        ///// </summary>
        //public bool RememberPwd { get { return rememberPwd; } set { this.SetProperty(ref this.rememberPwd, value); } }

        #endregion

        #region 工作方法
        /// <summary>
        /// 用于验证登陆信息
        /// </summary>
        /// <param name="userID"></param>
        /// <returns>
        /// 返回值代表
        /// -6:密码不正确  -5:用户名不正确
        /// -4:密码含有特殊字符 -3:密码不能为空
        /// -2:用户名不能为空
        /// -1:数据库未连接 0:登陆失败
        ///  1:登陆成功  2:
        ///
        /// </returns>
        public int Verification(ref int userID)
        {
            int flag = 0;

            try
            {
                if (string.IsNullOrEmpty(this.userName))
                {
                    flag = -2;
                    return(flag);
                }
                if (string.IsNullOrEmpty(this.userPassword))
                {
                    flag = -3;
                    return(flag);
                }
                else
                {
                    RequestLoginModel request = new RequestLoginModel();
                    request.account  = this.userName;
                    request.password = this.userPassword;

                    ResponseTokenModel response = new ApiImpl().Login(request);
                    if (response != null)
                    {
                        AppConfigMoel.token = response.token;
                        flag = 1;
                    }
                    else
                    {
                        flag = -6;
                    }
                    System.Threading.Thread.Sleep(1500);
                }
                //flag = 1;
                //System.Threading.Thread.Sleep(1500);
                //Console.WriteLine(this.userName + this.userPassword);
            }
            catch (Exception)
            {
                flag = -1;
                //出现错误无视
            }
            return(flag);
        }
 private void UpdatePassWordEvent(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(OldPwd.Password) && !string.IsNullOrEmpty(NewPwd1.Password) && string.IsNullOrEmpty(NewPwd2.Password))
     {
         if (NewPwd2.Password == NewPwd1.Password)
         {
             if (NewPwd1.Password == OldPwd.Password)
             {
                 MessageBox.Show("新密码和旧密码不可以一样,请重新输入");
                 NewPwd1.Password = string.Empty;
                 NewPwd2.Password = string.Empty;
                 OldPwd.Password  = string.Empty;
             }
             else
             {
                 BaseResponseModel baseResponse = new ApiImpl().ResetPwd(OldPwd.Password, NewPwd1.Password);
                 if (baseResponse.code.Equals("200"))
                 {
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show(baseResponse.msg);
                 }
             }
         }
         else
         {
             MessageBox.Show("新密码输入不一致,请重新输入");
             NewPwd1.Password = string.Empty;
             NewPwd2.Password = string.Empty;
         }
     }
     else
     {
         MessageBox.Show("请完整输入信息");
     }
 }
 private void UpdateCahrgeStandardEvent(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(this.ChargeStandard.Text) && !string.IsNullOrEmpty(this.ChargeDays.Text))
     {
         RequestInformationModel request = new RequestInformationModel();
         request.Id             = id;
         request.ChargeStandard = Convert.ToDouble(this.ChargeStandard.Text);
         request.ChargeDays     = Convert.ToInt32(this.ChargeDays.Text);
         BaseResponseModel responseModel = new ApiImpl().UpdateChargeStandar(request);
         if (responseModel.code.Equals("200"))
         {
             this.Close();
         }
         else
         {
             MessageBox.Show("更新失败");
         }
     }
     else
     {
         MessageBox.Show("输入数据有误");
     }
 }
        private void add_btn(object sender, RoutedEventArgs e)
        {
            if (this.userId.Text == String.Empty)
            {
                System.Windows.MessageBox.Show("用户名不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }
            if (this.phone.Text == String.Empty)
            {
                System.Windows.MessageBox.Show("联系方式不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }
            if (this.usertype.SelectedIndex == -1)
            {
                System.Windows.MessageBox.Show("用户类型不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }
            if (this.area.Text == String.Empty)
            {
                System.Windows.MessageBox.Show("供热面积不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }
            if (this.controllerType.SelectedIndex == -1)
            {
                System.Windows.MessageBox.Show("门阀类型不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }
            if (this.controllerCode.Text == String.Empty)
            {
                System.Windows.MessageBox.Show("门阀序列号不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }
            if (this.build.Text == String.Empty)
            {
                System.Windows.MessageBox.Show("楼号不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }
            if (this.unit.Text == String.Empty)
            {
                System.Windows.MessageBox.Show("单元不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }
            if (this.room.Text == String.Empty)
            {
                System.Windows.MessageBox.Show("室不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }
            if (this.com_province.SelectedIndex == -1)
            {
                System.Windows.MessageBox.Show("省份不能为空", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }


            var userId         = this.userId.Text.Trim();
            var phone          = this.phone.Text.Trim();
            var usertype       = this.usertype.SelectedIndex.ToString();
            var area           = this.area.Text.Trim();
            var controllerType = this.controllerType.SelectedIndex.ToString();
            var controllerCode = this.controllerCode.Text.Trim();
            var build          = this.build.Text.Trim();
            var unit           = this.unit.Text.Trim();
            var room           = this.room.Text.Trim();

            ResponseUserInfoModel request = new ResponseUserInfoModel();

            request.name           = userId;
            request.phone          = phone;
            request.userType       = usertype;
            request.area           = area;
            request.controllerType = controllerType;
            request.controllerCode = controllerCode;
            request.build          = build;
            request.unit           = unit;
            request.room           = room;

            request.hourseCode = "1231";
            request.provice    = "浙江";
            request.city       = "杭州";;
            request.county     = "滨江";;
            request.street     = "浦沿";;
            request.village    = "新村";;

            BaseResponseModel response = new ApiImpl().AddUser(request);

            if (response != null && response.code == "200")
            {
                //System.Windows.MessageBox.Show("添加成功", "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                System.Windows.MessageBox.Show(response.msg.ToString(), "系统提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
            }
        }