Exemple #1
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);
        }
Exemple #2
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;
            }
        }