예제 #1
0
        private void skinButton1_Click(object sender, EventArgs e)
        {
            String name = skinTextBox2.Text;

            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("请输入航段名称!");
                return;
            }
            if (string.IsNullOrEmpty(comboBox1.Text))
            {
                MessageBox.Show("请选择起点!");
                return;
            }
            if (string.IsNullOrEmpty(comboBox2.Text))
            {
                MessageBox.Show("请选择终点!");
                return;
            }

            if (string.IsNullOrEmpty(comboBox3.Text))
            {
                MessageBox.Show("请选择类型!");
                return;
            }

            Air_Segment airSegmente = new Air_Segment(0, name, comboBox1.Text, comboBox2.Text, comboBox3.Text, comboBox4.Text);

            if (skinLabel5.Text.Equals("ID"))
            {
                // 插入数据库
                ProfileHelper.Instance.Update("INSERT INTO AirSegment (Id, Name, BeginWayPoint, EndWayPoint, Type, Show) VALUES ( NULL, '" +
                                              airSegmente.Name + "', '" + airSegmente.BeginWayPoint + "', '" + airSegmente.EndWayPoint + "', '" +
                                              airSegmente.Type + "', '" + airSegmente.Show + "')");
            }
            else if (!string.IsNullOrWhiteSpace(skinLabel5.Text))
            {
                // 更新数据库
                ProfileHelper.Instance.Update(
                    "UPDATE AirSegment set " +
                    " Name = '" + airSegmente.Name + "', " +
                    " BeginWayPoint = '" + airSegmente.BeginWayPoint + "', " +
                    " EndWayPoint = '" + airSegmente.EndWayPoint + "', " +
                    " Type = '" + airSegmente.Type + "', " +
                    " Show = '" + airSegmente.Show + "'" +
                    " where ID = " + skinLabel5.Text);

                // 更新后初始化组件
                skinTextBox2.Text = "";
                comboBox1.Text    = "";
                comboBox2.Text    = "";
                comboBox3.Text    = "";
                comboBox4.Text    = "";

                skinButton1.Text = "新增";
            }

            showAllAirSegment();
            airSegment_event(true, 2);
        }
예제 #2
0
        /**
         * 从数据库里面查出所有的数据,展示。
         * */
        private void showAllAirSegment()
        {
            List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM AirSegment");

            airSegmentList.Clear();
            foreach (Dictionary <string, object> dictionary in result)
            {
                int         id            = Convert.ToInt32(dictionary["ID"]);
                String      name          = Convert.ToString(dictionary["Name"]);
                String      beginWayPoint = Convert.ToString(dictionary["BeginWayPoint"]);
                String      endWayPoint   = Convert.ToString(dictionary["EndWayPoint"]);
                String      type          = Convert.ToString(dictionary["Type"]);
                String      show          = Convert.ToString(dictionary["Show"]);
                Air_Segment air_Segment   = new Air_Segment(id, name, beginWayPoint, endWayPoint, type, show);
                airSegmentList.Add(air_Segment);
            }

            this.dataGridView1.DataSource = null;
            if (null != airSegmentList && airSegmentList.Count() > 0)
            {
                this.dataGridView1.DataSource = this.airSegmentList;
            }
        }