Exemplo n.º 1
0
        /// <summary>
        /// 选择风场
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbWindFieldName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbWindFieldName.SelectedItem == null)
            {
                return;
            }
            if ((string)cmbWindFieldName.SelectedItem == "风场名称")
            {
                //展示所有的风场名字
                DisplayNameOfWindField();
                return;
            }

            AllWindField windField = AllWindFieldDAL.GetWindFieldByName((string)cmbCompanyName.SelectedItem, (string)cmbWindFieldName.SelectedItem);

            if (windField == null)
            {
                txtDisplay.Text = "没有查到该风场的信息...";
                return;
            }
            txtDisplay.Text = "业主名称:" + windField.CompanyName
                              + "\n风场名称:" + windField.WindFieldName
                              + "\n详细地址:" + windField.Province + windField.City + windField.DetailAddress
                              + "\n风机数量:" + windField.FanCount + " 台"
                              + "\n风机类型:" + windField.FanType
                              + "\n风机型号:" + windField.FanModelNumber
                              + "\n风机高度:" + windField.FanHeight + " 米"
                              + "\n测风仪型号:" + windField.AnemoscopeModelNumber
                              + "\n信号模式:" + windField.SignalKind;
        }
Exemplo n.º 2
0
        //选择省份
        private void cmbProvince_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbProvince.SelectedItem == null)
            {
                return;
            }
            if ((string)cmbProvince.SelectedItem == "全国范围")
            {
                //清空城市列表
                cmbCity.ItemsSource = null;
                //加载全国范围的公司
                LoadCompany("全国范围", companyArray);
                //清空风场列表
                cmbWindFieldName.ItemsSource = null;
                return;
            }
            //选中的省份改变时,获取对应城市信息,并加载到城市列表中
            //获取选中的省份名称
            string selectedProvince = cmbProvince.SelectedItem.ToString();

            //根据选中的省份名称去数据库查询包含的城市
            string[] citys = AllWindFieldDAL.GetCityOfProvince(selectedProvince);
            cmbCity.ItemsSource = citys;//加载城市名称
            //加载选中省份的公司名称
            string[] companys = AllWindFieldDAL.GetCompanyOfProvince(selectedProvince);
            LoadCompany(selectedProvince, companys);//记载该省份的公司名到下拉列表
        }
Exemplo n.º 3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            baseGrid.Visibility         = Visibility.Visible;
            addCompanyGrid.Visibility   = Visibility.Hidden;
            addWindFieldGrid.Visibility = Visibility.Hidden;

            //获得所有公司名称
            string[] province = AllWindFieldDAL.GetCompanyName();
            cmbCompanyName.ItemsSource   = province;
            cmbCompanyName.SelectedIndex = 0;
        }
Exemplo n.º 4
0
        //确认提交新业主
        private void TbtnUploadData_Click(object sender, RoutedEventArgs e)
        {
            if (TtxtCompanyName.Text == string.Empty || TtxtWindFieldName.Text == string.Empty ||
                TtxtTableName.Text == string.Empty || TtxtProvince.Text == string.Empty || TtxtCity.Text == string.Empty)
            {
                MessageBox.Show("必填项不可为空,请填写完整后重试!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            //检测该业主是否已在数据库存在
            int isExistOfCompany = AllWindFieldDAL.IsExistOfCompany(TtxtCompanyName.Text);

            if (isExistOfCompany > 0)
            {
                MessageBox.Show("该业主已经在数据库里存在,无需再次添加!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            //判断输入的数据表名是否在数据库里已经存在
            int isExistOfTable = AllWindFieldDAL.IsExistOfTable(TtxtTableName.Text);

            if (isExistOfTable > 0)
            {
                MessageBox.Show("该数据表名已经在数据库里存在,请更改后重试!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            //创建风场对象
            AllWindField newWindField = new AllWindField();

            newWindField.BranchTableName       = TtxtTableName.Text;
            newWindField.CompanyName           = TtxtCompanyName.Text;
            newWindField.WindFieldName         = TtxtWindFieldName.Text;
            newWindField.Province              = TtxtProvince.Text;
            newWindField.City                  = TtxtCity.Text;
            newWindField.DetailAddress         = TtxtDetailAddress.Text;
            newWindField.FanType               = TtxtFanType.Text;
            newWindField.FanCount              = 0;
            newWindField.FanModelNumber        = TtxtFanModelNumber.Text;
            newWindField.FanHeight             = TtxtFanHeight.Text;
            newWindField.AnemoscopeModelNumber = TtxtAnemoscopeModelNumber.Text;
            newWindField.SignalKind            = TtxtSignalKind.Text;

            //上传数据
            int insertResult = AllWindFieldDAL.InsertData(newWindField);

            if (insertResult <= 0)
            {
                MessageBox.Show("数据提交失败,请检查网络或数据库连接是否正常!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            //创建对应公司的表格
            AllWindFieldDAL.CreateTable(TtxtTableName.Text);
            MessageBox.Show("恭喜您,新业主添加成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
        }
Exemplo n.º 5
0
        //选择城市
        private void cmbCity_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbCity.SelectedItem == null)
            {
                return;
            }
            //获取选择的城市名称
            string selectedCity = cmbCity.SelectedItem.ToString();

            //获取对应省份和城市名称的风场
            string[] companys = AllWindFieldDAL.GetCompanyByProvinceAndCity(cmbProvince.SelectedItem.ToString(), selectedCity);
            LoadCompany(cmbProvince.SelectedItem.ToString() + selectedCity, companys);//加载城市列表
        }
Exemplo n.º 6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //失能对比按钮
            btnAddCompare.IsEnabled = false;
            this.Title = this.CompanyName + "---" + this.WindFieldName + "---第 " + this.FanNumber + " 号风机";
            //获取当前风机的风场信息
            windFieldOfFan = AllWindFieldDAL.GetWindFieldByName(this.CompanyName, this.WindFieldName);
            //获得当前风机的最新数据
            FanPoint fp = FanPointDAL.GetSinglePoint(windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber);



            txtbkDigital.Text = "业主名称:" + windFieldOfFan.CompanyName + "\n"
                                + "风场名称:" + windFieldOfFan.WindFieldName + "\n"
                                + "地址:" + windFieldOfFan.Province + windFieldOfFan.City + windFieldOfFan.DetailAddress + "\n\n"
                                + "-------------------------------\n"
                                + "风机型号:" + windFieldOfFan.FanModelNumber + "\n"
                                + "风机高度:" + windFieldOfFan.FanHeight + "\n"
                                + "测风仪型号:" + windFieldOfFan.AnemoscopeModelNumber + "\n"
                                + "-------------------------------\n"
                                + "经纬度:" + fp.GPS_lng + "E  " + fp.GPS_lat + "N\n"
                                + "风机号:" + fp.FanNumber + "\n"
                                + "风速:" + fp.WindSpeed + "\n"
                                + "风向:" + fp.WindDirection + "\n"
                                + "临时IP:" + fp.TempIp + "\n"
                                + "海拔:" + fp.Elevation + "\n"
                                + "航向:" + fp.Course + "\n"
                                + "航速:" + fp.NavigationalSpeed + "\n"
                                + "温度:" + fp.Temperature + "\n"
                                + "湿度:" + fp.Humidity + "\n"
                                + "气压:" + fp.AirPressure + "\n";



            //预加载省份
            provinceArray = AllWindFieldDAL.GetAllProvince();
            if (provinceArray != null)
            {
                //如果查到了省份,则加载到复选框
                List <string> provinceList = new List <string>();
                provinceList.Add("全国范围");
                provinceList.AddRange(provinceArray);
                cmbProvince.ItemsSource  = provinceList;//加载省份
                cmbProvince.SelectedItem = "全国范围";
            }

            //预加载所有公司名称
            companyArray = AllWindFieldDAL.GetCompanyName();
            LoadCompany("全国范围", companyArray);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 显示风场信息
        /// </summary>
        private void DisplayNameOfWindField()
        {
            //获取选中的公司名字
            string selectedCompany = cmbCompanyName.SelectedItem.ToString();

            if (cmbProvince.SelectedItem.ToString() == "全国范围")
            {
                //获取全国范围对应业主的风场名称
                AllWindField[] windField = AllWindFieldDAL.GetWindFieldNameAndFanCountByCompanyName(selectedCompany);
                if (windField == null)
                {
                    txtDisplay.Text = "该业主还没有接入服务的风场...";
                    return;
                }
                //获取该公司的风机数量
                int fanCount = AllWindFieldDAL.GetFanCountSum(selectedCompany);
                //加载风场下拉列表
                LoadWindFieldName(selectedCompany, "全国范围", "", windField, fanCount);
            }
            else if (cmbProvince.SelectedItem.ToString() != "全国范围" && cmbCity.SelectedItem == null)
            {
                //获取某省份对应业主的风场名称
                AllWindField[] windfield = AllWindFieldDAL.GetWindFieldNameAndFanCountByPlace(cmbProvince.SelectedItem.ToString(), null, cmbCompanyName.SelectedItem.ToString());
                if (windfield == null)
                {
                    txtDisplay.Text = "该业主在" + cmbProvince.SelectedItem.ToString() + "还没有接入服务的风场...";
                    return;
                }
                //获取该公司在该省份的风机数量
                int fanCount = AllWindFieldDAL.GetFanCountSumByPlace(selectedCompany, cmbProvince.SelectedItem.ToString());
                //加载风场下拉列表
                LoadWindFieldName(selectedCompany, cmbProvince.SelectedItem.ToString(), "", windfield, fanCount);
            }
            else if (cmbProvince.SelectedItem.ToString() != "全国范围" && cmbCity.SelectedItem != null)
            {
                //获取某省某市对应业主的风场信息
                //获取某省份对应业主的风场名称
                AllWindField[] windfield = AllWindFieldDAL.GetWindFieldNameAndFanCountByPlace(cmbProvince.SelectedItem.ToString(), cmbCity.SelectedItem.ToString(), cmbCompanyName.SelectedItem.ToString());
                if (windfield == null)
                {
                    txtDisplay.Text = "该业主在" + cmbProvince.SelectedItem.ToString() + cmbCity.SelectedItem.ToString() + "还没有接入服务的风场...";
                    return;
                }
                //获取该公司在该省份的风机数量
                int fanCount = AllWindFieldDAL.GetFanCountSumByPlace(selectedCompany, cmbProvince.SelectedItem.ToString(), cmbCity.SelectedItem.ToString());
                //加载风场下拉列表
                LoadWindFieldName(selectedCompany, cmbProvince.SelectedItem.ToString(), cmbCity.SelectedItem.ToString(), windfield, fanCount);
            }
        }
Exemplo n.º 8
0
        //确认提交新风场
        private void btnUploadData_Click(object sender, RoutedEventArgs e)
        {
            if (cmbCompanyName.SelectedItem == null || txtWindFieldName.Text == string.Empty ||
                txtProvince.Text == string.Empty || txtCity.Text == string.Empty)
            {
                MessageBox.Show("必填项不可为空,请填写完整后重试!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            //检测该风场是否已在数据库存在
            AllWindField awf = AllWindFieldDAL.GetWindFieldByName(cmbCompanyName.SelectedItem.ToString(), txtWindFieldName.Text);

            if (awf != null)
            {
                MessageBox.Show("该风场已经在数据库里存在,请检查风场名是否正确!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            //根据选中的业主名获取公司数据库表名
            string tableName = AllWindFieldDAL.GetTableName(cmbCompanyName.SelectedItem.ToString());
            //创建风场对象
            AllWindField newWindField = new AllWindField();

            newWindField.BranchTableName       = tableName;
            newWindField.CompanyName           = cmbCompanyName.SelectedItem.ToString();
            newWindField.WindFieldName         = txtWindFieldName.Text;
            newWindField.Province              = txtProvince.Text;
            newWindField.City                  = txtCity.Text;
            newWindField.DetailAddress         = txtDetailAddress.Text;
            newWindField.FanType               = txtFanType.Text;
            newWindField.FanCount              = 0;
            newWindField.FanModelNumber        = txtFanModelNumber.Text;
            newWindField.FanHeight             = txtFanHeight.Text;
            newWindField.AnemoscopeModelNumber = txtAnemoscopeModelNumber.Text;
            newWindField.SignalKind            = txtSignalKind.Text;

            //上传数据
            int insertResult = AllWindFieldDAL.InsertData(newWindField);

            if (insertResult <= 0)
            {
                MessageBox.Show("数据提交失败,请检查网络或数据库连接是否正常!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            else
            {
                MessageBox.Show("恭喜您,新风场添加成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
        }
Exemplo n.º 9
0
 //选择风场
 private void cmbWindFieldName_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cmbWindFieldName.SelectedItem == null)
     {
         return;
     }
     if (cmbWindFieldName.SelectedItem.ToString() == "风场名称")
     {
         cmbWindFanNumber.ItemsSource = null;
         return;
     }
     //获得此风机所在的表名 awf.BranchTableName
     windFieldOfCompareFan = AllWindFieldDAL.GetWindFieldByName(cmbCompanyName.SelectedItem.ToString(), cmbWindFieldName.SelectedItem.ToString());
     //获得此风场下的所有风机编号
     int[] fanNumber = FanPointDAL.GetFanNumber(windFieldOfCompareFan.BranchTableName, cmbWindFieldName.SelectedItem.ToString());
     cmbWindFanNumber.ItemsSource = fanNumber;
 }
Exemplo n.º 10
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //预加载省份
            provinceArray = AllWindFieldDAL.GetAllProvince();
            if (provinceArray != null)
            {
                //如果查到了省份,则加载到复选框
                List <string> provinceList = new List <string>();
                provinceList.Add("全国范围");
                provinceList.AddRange(provinceArray);
                cmbProvince.ItemsSource  = provinceList;//加载省份
                cmbProvince.SelectedItem = "全国范围";
            }

            //预加载所有公司名称
            companyArray = AllWindFieldDAL.GetCompanyName();
            LoadCompany("全国范围", companyArray);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 选择公司后的相应操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbCompanyName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbCompanyName.SelectedItem == null)
            {
                return;
            }
            if ((string)cmbCompanyName.SelectedItem == "公司名称")
            {
                cmbWindFieldName.ItemsSource = null;//清空风场选择框的信息
                if (cmbProvince.SelectedItem.ToString() != "全国范围" && cmbCity.SelectedItem == null)
                {
                    //只加载该省包含的公司信息
                    //加载选中省份的公司名称
                    string[] companys = AllWindFieldDAL.GetCompanyOfProvince(cmbProvince.SelectedItem.ToString());
                    txtDisplay.Text = cmbProvince.SelectedItem.ToString() + "接入服务的业主有 " + companys.Length + " 家:\n\n";
                    for (int i = 0; i < companys.Length; i++)
                    {
                        txtDisplay.AppendText(companys[i] + "   ");
                    }
                }
                else if (cmbCity.SelectedItem != null)
                {
                    //加载某省某市的公司信息
                    //获取对应省份和城市名称的风场
                    string[] companys = AllWindFieldDAL.GetCompanyByProvinceAndCity(cmbProvince.SelectedItem.ToString(), cmbCity.SelectedItem.ToString());
                    txtDisplay.Text = cmbProvince.SelectedItem.ToString() + cmbCity.SelectedItem.ToString() + "接入服务的业主有 " + companys.Length + " 家:\n\n";
                    for (int i = 0; i < companys.Length; i++)
                    {
                        txtDisplay.AppendText(companys[i] + "   ");
                    }
                }

                return;
            }


            //选择的公司改变时,展示相应公司的风场名字
            DisplayNameOfWindField();
        }
Exemplo n.º 12
0
        private void loginWork()
        {
            //首先检查数据库连接
            if (LoginDAL.CheckDBConnection() != 0)
            {
                MessageBox.Show("连接失败,请检查网络连接!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                btnLogin.Content = "登录失败";
                return;
            }
            //获取全国的风机数量
            int pointNum = FanPointDAL.GetAllPoints().Count;

            labPointNum.Content = pointNum + " 台";
            //获取全国风场数量
            int windFieldNum = AllWindFieldDAL.GetWindFieldNumber();

            labWindFieldNumber.Content = windFieldNum + "个";
            //获取全国的公司数量
            int companyNum = AllWindFieldDAL.GetCompanyNumber();

            labCompanyNumber.Content = companyNum + " 家";
            initEvent(); //加载地图


            int ErrorTimeSpanMin = 30;//为保证账户安全,设置多次登录错误后的用户需要等待的时间

            if (cbxUserName.Text == "用户名" || pwx.Password == "*#*#*#")
            {
                MessageBox.Show("用户名或密码有误,请重新输入!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                cbxUserName.Focus();
                return;
            }
            User user = LoginDAL.GetAccountByUserName(cbxUserName.Text);//获取当前的用户信息

            if (user == null)
            {
                MessageBox.Show("不存在此用户!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                cbxUserName.Focus();
                return;
            }
            else
            {
                //如果距离上次登录成功已经超过30分钟,则将登录错误次数清零
                if (user.LoginTime != null)
                {
                    DateTime dt = LoginDAL.GetServerTime();                //获取服务器当前时间
                    TimeSpan ts = dt - (DateTime)user.LoginTime;           //获取当前用户最新的上一次登录的时间
                    if (ts.TotalMinutes >= ErrorTimeSpanMin)               //如果用户长时间没登录过,则将以前的登录错误次数清零
                    {
                        LoginDAL.ResetErrorTimesByUserName(user.UserName); //登录错误次数清零
                        user.ErrorTimes = 0;                               //本地记录的登录错误次数清零
                    }
                    else if (user.ErrorTimes >= 3)                         //如果登录错误次数超过了3次,则禁止用户在 ErrorTimeSpanMin 时间内登录(单位/分钟)
                    {
                        MessageBox.Show("登录失败次数过多,请 "
                                        + Math.Ceiling(ErrorTimeSpanMin - ts.TotalMinutes)
                                        + " 分钟后重试!",
                                        "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                }
            }

            string passWord = LoginDAL.GetMD5(pwx.Password);//获取加密后的密码

            if (passWord != user.Password)
            {
                LoginDAL.UpdateErrorTimesByUserName(user.UserName); //登录错误次数+1
                LoginDAL.UpdateLoginTimeByUserName(user.UserName);  //更新登录时间
                MessageBox.Show("密码不正确,请重新输入!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                pwx.Focus();
                return;
            }
            if ((cbxUserName.Text == user.UserName) && (passWord == user.Password))
            {
                //登录成功
                XMLDAL.UpdateUser(cbxUserName.Text, pwx.Password); //将登录成功的用户信息更新到配置文件里
                LoginDAL.UpdateLoginTimeByUserName(user.UserName); //更新登录时间
                LoginDAL.ResetErrorTimesByUserName(user.UserName); //登录错误次数清零

                LoginGrid.Visibility = Visibility.Hidden;
                MainGrid.Visibility  = Visibility.Visible;
            }
            else
            {
                LoginDAL.UpdateErrorTimesByUserName(user.UserName); //登录错误次数+1
                LoginDAL.UpdateLoginTimeByUserName(user.UserName);  //更新登录时间
                MessageBox.Show("登录失败,请重试!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }