Esempio n. 1
0
        /**
         * 从数据库里面查出所有的数据,展示。
         * */
        private void showAllAirPort()
        {
            List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM AirPort");

            airPortList.Clear();
            foreach (Dictionary <string, object> dictionary in result)
            {
                String   name     = Convert.ToString(dictionary["Name"]);
                double   lat      = Convert.ToDouble(dictionary["Lat"]);
                double   lang     = Convert.ToDouble(dictionary["Lng"]);
                int      id       = Convert.ToInt32(dictionary["ID"]);
                double   length   = Convert.ToDouble(dictionary["Length"]);
                int      num      = Convert.ToInt16(dictionary["Num"]);
                Air_Port air_Port = new Air_Port(id, name, lat, lang, num, length);
                airPortList.Add(air_Port);
            }

            this.dataGridView1.DataSource = null;
            if (null != airPortList && airPortList.Count() > 0)
            {
                this.dataGridView1.DataSource = this.airPortList;
            }
        }
Esempio n. 2
0
        private void skinButton1_Click(object sender, EventArgs e)
        {
            String name = skinTextBox2.Text;

            if (null == name || name.Length == 0)
            {
                MessageBox.Show("请输入机场名称!");
                return;
            }
            if (null == skinTextBox3.Text || skinTextBox3.Text.Length == 0)
            {
                MessageBox.Show("请输入经纬度!");
                return;
            }
            if (null == skinTextBox4.Text || skinTextBox4.Text.Length == 0)
            {
                MessageBox.Show("请输入经纬度!");
                return;
            }
            if (null == skinTextBox1.Text || skinTextBox1.Text.Length == 0)
            {
                MessageBox.Show("请输入环数!");
                return;
            }
            if (null == skinTextBox5.Text || skinTextBox5.Text.Length == 0)
            {
                MessageBox.Show("请输入环距离!");
                return;
            }

            Air_Port air_Port = new Air_Port(
                0,
                name,
                Convert.ToDouble(skinTextBox3.Text),
                Convert.ToDouble(skinTextBox4.Text),
                Convert.ToInt16(skinTextBox1.Text),
                Convert.ToDouble(skinTextBox5.Text));

            if (skinLabel2.Text.Equals("ID"))
            {
                // 插入数据库
                ProfileHelper.Instance.Update("INSERT INTO AirPort (ID, Name, Lat, Lng, Num, Length) VALUES (NULL, '" +
                                              air_Port.Name + "', " +
                                              air_Port.Lat + ", " +
                                              air_Port.Lng + ", " +
                                              air_Port.Num + ", " +
                                              air_Port.Length + ")");
            }
            else if (!string.IsNullOrWhiteSpace(skinLabel2.Text))
            {
                // 更新数据库
                ProfileHelper.Instance.Update(
                    "UPDATE AirPort set " +
                    " Name = '" + air_Port.Name + "', " +
                    " Lat = " + air_Port.Lat + ", " +
                    " Lng = " + air_Port.Lng + ", " +
                    " Num = " + air_Port.Num + ", " +
                    " Length = " + air_Port.Length +
                    " where ID = " + skinLabel2.Text);

                // 更新后初始化组件
                skinTextBox1.Text = "";
                skinTextBox2.Text = "";
                skinTextBox3.Text = "";
                skinTextBox4.Text = "";
                skinTextBox5.Text = "";
                skinButton1.Text  = "新增";
            }
            showAllAirPort();
            airPort_event(true, 1);
        }