⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 windows mobile读取GPS数据
💻 CS
📖 第 1 页 / 共 4 页
字号:
        {
            if (gt_bdz_name.SelectedValue == null)
            {
                MessageBox.Show("请选择变电站选项!");
                return false;
            }
            if (gt_line_name.SelectedValue == null)
            {
                MessageBox.Show("请选择干线线路选项!");
                return false;
            }
            if (gt_subline_name.SelectedValue == null)
            {
                MessageBox.Show("请选择支路选项");
            }
            //检测杆号的合法性
            if (!IsPoleCodeRight(ot))
            {
                return false;
            }
            if (gt_pole_height.SelectedValue == null)
            {
                MessageBox.Show("请选择杆高!");
                return false;
            }
            if (gt_pole_type.SelectedValue == null)
            {
                MessageBox.Show("请选择杆型!");
                return false;
            }
            if (gt_tip_radius.SelectedValue == null)
            {
                MessageBox.Show("请选择梢径!");
                return false;
            }
            if (gt_latitude.TextLength < 0 || gt_longitude.TextLength<0)
            {
                MessageBox.Show("经纬度坐标数据不正确!请确认正确后重试!");
                return false;
            }
            //如果杆号为1并且挂接杆号为空,则提示是否进行挂接
            if (gt_pole_code.Text.Equals("1") && gt_parent_pole.TextLength < 0)
            {
                if (MessageBox.Show("杆号为1,如果该杆塔与上级线路的分支杆相连,请点击‘是’返回并填写上级分支杆杆号后继续!确认该杆塔没有上级线路的点‘否’继续操作!") == DialogResult.Yes)
                {
                    return false;
                }
            }
            return true;
        }
        private bool IsPoleCodeRight(OperType ot)
        {            
            string strSql = "";
            strSql = "select count(*) from pole_tower where bdz_code =" +gt_bdz_name.SelectedValue +" and line_code =" +gt_line_name.SelectedValue +" and subline_code="  + gt_subline_name.SelectedValue +" and pole_code='" +gt_pole_code.Text +"'";
          
            if (ot == OperType.Insert)
            {
                if (GetRecordCount(strSql) > 0)
                {
                    strSql = "select count(*) from pole_tower where bdz_code =" + gt_bdz_name.SelectedValue + " and line_code =" + gt_line_name.SelectedValue + " and subline_code=" + gt_subline_name.SelectedValue;
                    MessageBox.Show("杆号重复,请重新填写正确的杆号!该线路上目前共有"+GetRecordCount(strSql).ToString()+"根杆塔!");
                    return false;
                }
            }
            if (ot == OperType.Update)
            {
                if (GetRecordCount(strSql) < 0)
                {
                    MessageBox.Show("该线路上没有杆号为:"+gt_pole_code.Text+"杆塔,请确认后重试!");
                    return false;
                }
            }
            return true;
        }
        private bool IsLineCrossDataReady()
        {
            if (lc_bdz_name.SelectedValue == null)
            {
                MessageBox.Show("请选择变电站选项!");
                return false;
            }
            if (lc_line_name.SelectedValue == null)
            {
                MessageBox.Show("请选择干线线路选项!");
                return false;
            }
            if (lc_subline_name.SelectedValue == null)
            {
                MessageBox.Show("请选择支路选项");
            }
            if (lc_start_num.TextLength < 0)
            {
                MessageBox.Show("起始杆杆号不能为空!");
                return false;
            }
            if (lc_end_num.TextLength < 0)
            {
                MessageBox.Show("终止杆杆号不能为空!");
                return false;
            }
            if ((Convert.ToInt32(lc_end_num.Text) - Convert.ToInt32(lc_start_num.Text)) != 1)
            {
                MessageBox.Show("起止杆杆号不连续!");
                return false;
            }
            if (lc_cross_span.SelectedValue == null)
            {
                MessageBox.Show("请选择交叉跨越类型!");
                return false;
            }
            if (lc_x1.TextLength < 0 || lc_y1.TextLength < 0)
            {
                MessageBox.Show("第一点坐标不能为空,请重新获取!");
                return false;
            }
            if (lc_x2.TextLength < 0 || lc_y2.TextLength < 0)
            {
                MessageBox.Show("第二点坐标不能为空,请重新获取!");
                return false;
            }

            return true;
        }
        //udpate操作
        private void bdz_save_Click(object sender, EventArgs e)
        {
            int nBdzCode = 0;
            string strSql = "";
            //获取当前记录的bdz_code
            DataRowView drv = (DataRowView)this.bdz_baseBindingSource.Current;
            nBdzCode = (int)drv.Row["bdz_code"];

            MessageBox.Show(nBdzCode.ToString());
            //检验变电站数据合法性
            if (IsBdzDataReady())
            {
                strSql = "Update bdz_base set "
                            +"voltage_level = " +bdz_voltage_level.SelectedValue
                            +",all_capability ='"+bdz_all_capability.Text +"'"
                            +",pmt_num="+Convert.ToInt32(bdz_pmt_num.Text)
                            +",main_capability='"+bdz_main_capability.Text+"'"
                            +",run_date="+bdz_run_date.Value
                            +",x1="+Convert.ToDouble(bdz_x1.Text)+",y1="+Convert.ToDouble(bdz_y1.Text)
                            +",x2="+Convert.ToDouble(bdz_x2.Text)+",y2="+Convert.ToDouble(bdz_y2.Text)
                            +",x3="+Convert.ToDouble(bdz_x3.Text)+",y3="+Convert.ToDouble(bdz_y3.Text)
                            +",x4="+Convert.ToDouble(bdz_x4.Text)+",y4="+Convert.ToDouble(bdz_y4.Text)
                            +",remark='"+bdz_remark.Text+"'"
                            +" where bdz_code = "+ nBdzCode;
                ExcuteSql(strSql);
                MessageBox.Show("当前记录修改成功!");
            }
        }        
        private void sub_modify_Click(object sender, EventArgs e)
        {
            int nSublineCode = 0;
            string strSql = "";
            //获取当前记录的subline_code
            DataRowView drv = (DataRowView)this.bdz_baseBindingSource.Current;
            nSublineCode = (int)drv.Row["subline_code"];

            MessageBox.Show(nSublineCode.ToString());
            //检验支线数据合法性
            if (IsSublineBaseDataReady())
            {
                strSql = "Update subline_base set "
                            //+ "bdz_code = " + sub_bdz_name.SelectedValue
                            //+ ",line_code=" +sub_line_name.SelectedValue
                            + "subline_name='" + sub_subline_name.Text + "'"
                            + "where subline_code = " + nSublineCode;
                ExcuteSql(strSql);
                MessageBox.Show("当前记录修改成功!");
            }
        }
        private void gt_modify_Click(object sender, EventArgs e)
        {
            int nId = 0;
            string strSql = "";
            //获取当前记录的Id
            DataRowView drv = (DataRowView)this.pole_towerBindingSource.Current;
            nId = (int)drv.Row["id"];

            MessageBox.Show(nId.ToString());
            //检验杆塔数据合法性
            if (IsPoleTowerBaseDataReady(OperType.Update))
            {
                strSql = "Update pole_tower set "
                            //+ "bdz_code = " + gt_bdz_name.SelectedValue
                            //+ ",line_code=" + gt_line_name.SelectedValue
                            //+ ",subline_code=" + gt_line_name.SelectedValue
                            //+ ",pole_code='" + gt_pole_code.Text + "'"
                            + "pole_height=" + gt_pole_height.SelectedValue
                            + ",pole_type='" + gt_pole_type.SelectedValue + "'"
                            + ",tip_radius='" + gt_tip_radius.SelectedValue + "'"
                            + ",longitude=" + Convert.ToDouble(gt_longitude.Text)
                            + ",latitude=" + Convert.ToDouble(gt_latitude.Text)
                            + ",cross_type='" + gt_cross_type.SelectedValue + "'"
                            + ",isolation_type='" + gt_isolation_type.SelectedValue + "'"
                            + ",lead_range_model='" + gt_lead_range_model.SelectedValue + "'"
                            + ",lead_model='" + gt_lead_model.SelectedValue + "'"
                            + ",trans_mode='" + gt_trans_mode.SelectedValue + "'"
                            + ",parent_linename='" + gt_parent_linename.Text + "'"
                            + ",parent_pole='" + gt_parent_pole.Text + "'"
                            + ",b_plane_pole=" + Convert.ToInt32(b_plane_poleCheckBox.Checked)
                            + ",b_corner_pole=" +Convert.ToInt32(b_corner_poleCheckBox.Checked)
                            + ",b_bear_pole=" +Convert.ToInt32(b_bear_poleCheckBox.Checked)
                            + ",b_terminal_pole=" +Convert.ToInt32(b_terminal_poleCheckBox.Checked)
                            + ",b_ramus_pole=" +Convert.ToInt32(b_ramus_poleCheckBox.Checked)
                            + ",b_switch=" +Convert.ToInt32(b_switchCheckBox.Checked)
                            + ",b_capacitor=" +Convert.ToInt32(b_capacitorCheckBox.Checked)
                            + ",b_cable=" +Convert.ToInt32(b_cableCheckBox.Checked)
                            + ",remark='" +gt_remark.Text+"'"
                            + "where id = " + nId;
                ExcuteSql(strSql);
                MessageBox.Show("当前记录修改成功!");
            }
        }        
        private void lc_modify_Click(object sender, EventArgs e)
        {
            int nLcCode = 0;
            string strSql = "";
            //获取当前记录的lc_code
            DataRowView drv = (DataRowView)this.line_crossBindingSource.Current;
            nLcCode = (int)drv.Row["lc_code"];

            MessageBox.Show(nLcCode.ToString());
            //检验支线数据合法性
            if (IsLineCrossDataReady())
            {
                strSql = "Update line_cross set "
                            //+ "bdz_code=" + lc_bdz_name.SelectedValue
                            //+ ",line_code=" + lc_line_name.SelectedValue
                            //+ ",subline_code=" + lc_subline_name.SelectedValue
                            //+ ",start_num='" + lc_start_num.Text + "'"
                            //+ ",end_num='" + lc_end_num.Text+ "'"
                            + "cross_span_kind='" + lc_cross_span.SelectedValue.ToString() +"'"
                            + ",x1=" + Convert.ToDouble(lc_x1.Text)
                            + ",y1=" + Convert.ToDouble(lc_y1.Text)
                            + ",x2=" + Convert.ToDouble(lc_x2.Text)
                            + ",y2=" + Convert.ToDouble(lc_y2.Text)
                            + ",remark='" + lc_remark.Text + "'"
                            + "where lc_code = " + nLcCode;
                ExcuteSql(strSql);
                MessageBox.Show("当前记录修改成功!");
            }
        }
        //insert操作
        private void sub_save_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否继续保存该条记录?", "警告:", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.OK)
            {
                return;
            }
            //添加新记录
            if (IsSublineBaseDataReady())
            {
                string strSql = "";
                strSql = "insert into subline_base(bdz_code,line_code,subline_name) values(" + sub_bdz_name.SelectedValue + "," + sub_line_name.SelectedValue + ",'" + sub_subline_name.Text + "')";
                ExcuteSql(strSql);

                this.subline_baseTableAdapter.Fill(qxpdaDataSet.subline_base);
                this.subline_baseBindingSource.ResetBindings(false);
                this.subline_baseBindingSource.MoveLast();
                UpdateButtonState();
                MessageBox.Show("新记录保存成功!");
            }
        }
        private void gt_save_Click(object sender, EventArgs e)
        {
            AddNewPoleTowerRecord();
            //杆号自动加一
            AutoAddPoleCode();
        }
        private void AutoAddPoleCode()
        {
            int nPoleNum = 0;
            nPoleNum = Convert.ToInt32(gt_pole_code.Text) + 1;
            gt_pole_code.Text = nPoleNum.ToString();
        }
        private void gt_fast_save_Click(object sender, EventArgs e)
        {
            AddNewPoleTowerRecord();
            //杆号自动加一
            AutoAddPoleCode();
        }
        private void AddNewPoleTowerRecord()
        {
            if (MessageBox.Show("是否继续保存该条记录?", "警告:", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.OK)
            {
                return;
            }
            //添加新记录
            string strSql = "";
            if (IsPoleTowerBaseDataReady(OperType.Insert))
            {
                strSql = "insert into pole_tower(bdz_code,line_code,subline_code,pole_code,pole_height,pole_type,tip_radius,"
                         + "longitude,latitude,cross_type,isolation_type,lead_range_model,lead_model,"
                         + "trans_mode,parent_linename,parent_pole,b_plane_pole,b_corner_pole,b_bear_pole,"
                         + "b_terminal_pole,b_ramus_pole,b_switch,b_capacitor,b_danger_pole,b_cable,remark) values("
                         + gt_bdz_name.SelectedValue + "," + gt_line_name.SelectedValue + "," + gt_subline_name.SelectedValue + ",'" + gt_pole_code.Text + "',"
                         + gt_pole_height.SelectedValue + ",'" + gt_pole_type.SelectedValue.ToString() + "','" + gt_tip_radius.SelectedValue.ToString() + "',"
                         + Convert.ToDouble(gt_longitude.Text) + "," + Convert.ToDouble(gt_latitude.Text) + ",'" + gt_cross_type.SelectedValue.ToString() + "','" + gt_isolation_type.SelectedValue.ToString() + "','"
                         + gt_lead_range_model.SelectedValue.ToString() + "','" + gt_lead_model.SelectedValue.ToString() + "','" + gt_trans_mode.SelectedValue.ToString() + "','" + gt_parent_linename.Text + "','" + gt_parent_pole.Text + "',"
                         + Convert.ToInt32(b_plane_poleCheckBox.Checked) + "," + Convert.ToInt32(b_corner_poleCheckBox.Checked) + "," + Convert.ToInt32(b_bear_poleCheckBox.Checked) + ","
                         + Convert.ToInt32(b_terminal_poleCheckBox.Checked) + "," + Convert.ToInt32(b_ramus_poleCheckBox.Checked) + "," + Convert.ToInt32(b_switchCheckBox.Checked) + ","
                         + Convert.ToInt32(b_capacitorCheckBox.Checked) + "," + Convert.ToInt32(b_danger_poleCheckBox.Checked) + "," + Convert.ToInt32(b_cableCheckBox.Checked) + ",'"
                         + gt_remark.Text + "')";

                ExcuteSql(strSql);

                this.pole_towerTableAdapter.Fill(qxpdaDataSet.pole_tower);
                this.pole_towerBindingSource.ResetBindings(false);
                this.pole_towerBindingSource.MoveLast();
                UpdateButtonState();
                MessageBox.Show("新杆塔保存成功!当前共有杆塔" + pole_towerBindingSource.Count.ToString() + "根!");
            }

        }      
        private void lc_save_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否继续保存该条记录?", "警告:", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.OK)
            {
                return;
            }
            //添加新记录
            string strSql = "";
            if (IsLineCrossDataReady())
            {
                strSql = "insert into line_cross(bdz_code,line_code,subline_code,start_num,end_num,cross_span_kind,x1,y1,x2,y2,remark) values("
                         + lc_bdz_name.SelectedValue + "," + lc_line_name.SelectedValue + "," + lc_subline_name.SelectedValue + ",'"
                         + lc_start_num.Text + "','" + lc_end_num.Text + "','" + lc_cross_span.SelectedValue + "',"
                         + Convert.ToDouble(lc_x1.Text) + "," + Convert.ToDouble(lc_y1.Text) + "," + Convert.ToDouble(lc_x2.Text) + "," + Convert.ToDouble(lc_y2.Text) + ",'"
                         + lc_remark.Text + "')";
                ExcuteSql(strSql);

                this.line_crossTableAdapter.Fill(qxpdaDataSet.line_cross);
                this.line_crossBindingSource.ResetBindings(false);
                this.line_crossBindingSource.MoveLast();
                UpdateButtonState();
                MessageBox.Show("交叉跨越信息保存成功!当前共有交叉跨越信息" + line_crossBindingSource.Count.ToString() + "条!");
            }
        }
        //delete操作
        private void sub_delete_Click(object sender, EventArgs e)
        {
            int nSublineCode = 0;
            string strSql = "";
            if (MessageBox.Show("是否继续删除该条记录?", "警告:", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.OK)
            {
                return;
            }
            //获取当前记录的bdz_code
            DataRowView drv = (DataRowView)this.subline_baseBindingSource.Current;
            nSublineCode = (int)drv.Row["subline_code"];

            MessageBox.Show(nSublineCode.ToString());

            //删除当前记录
            strSql = "delete from subline_base where subline_code = " + nSublineCode;
            ExcuteSql(strSql);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -