Exemple #1
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            frmGprsStationItem f = new frmGprsStationItem();

            if (f.ShowDialog(this) == DialogResult.OK)
            {
                string stName  = f.StationName;
                int    gr_addr = f.GrAddress;
                int    xg_addr = f.XgAddress;
//                int cp = f.CommPort;
                int    cp        = 0;
                string remark    = f.Remark;
                int    client    = XGConfig.Default.ClientAorB;
                string ipAddr    = f.IpAddress;
                string team      = f.Team;
                string addDrug   = f.AddDrug;
                float  heatArea  = f.Area;
                string serverIP  = f.ServerIpAddress;
                int    teamOrder = GetTeamOrder(f.Team);


                string insertGprsStationSql = string.Format(
                    @"insert into tbl_gprs_station (name, commport, 
                    client, remark, ip, team, addDrug, heatArea, serverIp, teamorder ) 
                    values( '{0}', {1}, {2}, '{3}', '{4}', '{5}', '{6}', {7}, '{8}', {9})",
                    stName, cp, client, remark, ipAddr, team, addDrug, heatArea, serverIP, teamOrder);

                XGDB.DbClient.ExecuteNonQuery(insertGprsStationSql);
                int gprsStationId = XGDB.QueryLastId("tbl_gprs_station", "gprs_station_id");

                XGStation st = new XGStation(stName, ipAddr, xg_addr);
                st.Tag = gprsStationId;
                XGDB.InsertXGStation(st);

                //int xgStationId = XGDB.QueryLastId("tbl_xgstation","xgstation_id");

                GRStation grSt = new GRStation(stName, gr_addr, ipAddr);
                grSt.Tag = gprsStationId;
                XGDB.InsertGRStation(grSt);
                //int grStationId = XGDB.QueryLastId("tbl_grstation", "grstation_id" );



                LoadXGStationFromDB();
                //XGDB.Resolve();
            }
        }