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(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, System.EventArgs e) { int row = dataGridGPRSStation.CurrentRowIndex; if (row == -1) { return; } int id = int.Parse(dataGridGPRSStation[row, 0].ToString()); string name = dataGridGPRSStation[row, 1].ToString(); string team = dataGridGPRSStation[row, 2].ToString(); string addDrag = dataGridGPRSStation[row, 3].ToString(); float area = GetArea(dataGridGPRSStation[row, 4].ToString()); //int.Parse ( dataGridGPRSStation[ row, 4 ].ToString() ); string ip = dataGridGPRSStation[row, 5].ToString(); int grAddr = int.Parse(dataGridGPRSStation[row, 6].ToString()); int xgAddr = int.Parse(dataGridGPRSStation[row, 7].ToString()); string serverIP = dataGridGPRSStation[row, 8].ToString(); string remark = dataGridGPRSStation[row, 9].ToString(); //frmXGStationItem f = new frmXGStationItem(); frmGprsStationItem f = new frmGprsStationItem(); f.AdeState = ADEState.Edit; f.EditId = id; f.StationName = name; f.IpAddress = ip; f.GrAddress = grAddr; f.XgAddress = xgAddr; f.Remark = remark; f.Team = team; f.Area = area; f.AddDrug = addDrag; f.ServerIpAddress = serverIP; if (f.ShowDialog(this) == DialogResult.OK) { // edit gprs station // int grId, xgId; // get grstaion id // bool b = getGrXgID(id, out grId, out xgId); System.Diagnostics.Debug.Assert(b, "read gr xg id"); // update grstation name graddress with id // XGDB.UpdateGrStation(grId, f.StationName, grAddr); // get xgstation id // // update xgstation name xgaddress with xgid // XGDB.UpdateXGStation(xgId, f.StationName, xgAddr); // update gprs station name, ip ,commport, remark ,client // XGDB.UpdateGprsStation(id, f.StationName, f.IpAddress, f.Remark, f.Team, f.AddDrug, f.Area, f.ServerIpAddress, this.GetTeamOrder(f.Team)); LoadXGStationFromDB(); } }