protected void gvStationInfo_RowUpdating(object sender, GridViewUpdateEventArgs e) { //e.Cancel = true; string tblID = gvStationInfo.DataKeys[e.RowIndex].Values[0].ToString(); string staID = ((TextBox)gvStationInfo.Rows[e.RowIndex].Cells[2].Controls[0]).Text.Trim(); string staName = ((TextBox)gvStationInfo.Rows[e.RowIndex].Cells[3].Controls[0]).Text.Trim(); // 检查输入 if (staID.Equals("") || staName.Equals("") || !isValidInt(staID)) { Response.Write("<script>alert('您的输入有误!');</script>"); return; } Model.StationRelation msr = new Model.StationRelation(); msr.StationTableID = Convert.ToInt32(tblID); msr.StationID = Convert.ToInt32(staID); msr.StationName = staName; if (sdbll.setStationsInfo(msr, "update") == 0) { Response.Write(String.Format("<script language=\"javascript\" type=\"text/javascript\">alert('城市:{0} 更新成功!');</script>", msr.StationName)); } else { Response.Write(String.Format("<script language=\"javascript\" type=\"text/javascript\">alert('城市:{0} 更新失败!');</script>", msr.StationName)); } gvStationInfo.EditIndex = -1; btnQuery_Click(sender, e); }
public void testdeleteSetStationsInfo() { Model.StationRelation msr = new Model.StationRelation(); msr.StationTableID = 683; BLL.SettingBLL sbll = new BLL.SettingBLL(); int done = sbll.setStationsInfo(msr, "delete"); Label1.Text = done.ToString(); }
public void testinsertSetStationsInfo() { Model.StationRelation msr = new Model.StationRelation(); msr.StationID = 54511; //msr.StationName = "new-beijing3"; BLL.SettingBLL sbll = new BLL.SettingBLL(); int done = sbll.setStationsInfo(msr, "insert"); Label1.Text = done.ToString(); }
public void testupdateSetStationsInfo() { Model.StationRelation msr = new Model.StationRelation(); msr.StationID = 55555; msr.StationName = "new-beijingfff"; msr.StationTableID = 682; BLL.SettingBLL sbll = new BLL.SettingBLL(); int done = sbll.setStationsInfo(msr, "update"); Label1.Text = done.ToString(); }
protected void btFromStaFile_Click(object sender, EventArgs e) { if (trProgram.SelectedNode != null && trProgram.SelectedNode.Parent != null) /*二级节点*/ { string path = Server.MapPath("~/Temp/"); string[] files = Directory.GetFiles(path); foreach (string file in files) { File.Delete(file); } string stLine; lboxStationReal.Items.Clear(); if (fuSelectStaFile.HasFile) { string fileExt = System.IO.Path.GetExtension(fuSelectStaFile.FileName); if (fileExt == ".sta") { string dt = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString(); string filename = dt + fileExt; try { fuSelectStaFile.SaveAs(path + filename); } catch (Exception ee) { lb_error.Text = ee.Message + " The file upload Default"; } try { StreamReader srReader = new StreamReader(path + filename, System.Text.Encoding.GetEncoding("gb2312")); stLine = srReader.ReadLine(); while (stLine != null) { if (stLine != "") { Regex regex = new Regex("\\s+"); stLine = regex.Replace(stLine, "#"); string[] newString = stLine.Trim().Split('#'); int stationID = Convert.ToInt32(newString[0].Trim()); string stationName = newString[1].Trim(); Model.StationRelation msr = new Model.StationRelation(); msr.StationName = stationName; msr.StationID = stationID; Model.StationRelation searchStationResult = dbll.searchStationInfo2(msr); if (searchStationResult != null) { ListItem stationImport = new ListItem(); stationImport.Value = searchStationResult.StationID.ToString() + "#" + searchStationResult.StationTableID.ToString(); stationImport.Text = searchStationResult.StationName + "(" + searchStationResult.StationID.ToString() + ")"; lboxStationReal.Items.Add(stationImport); } else { //如果不存在站点,则添加相应站点 if (sdbll.setStationsInfo(msr, "insert") == 0) { Model.StationRelation searchStationResultNew = dbll.searchStationInfo2(msr); if (searchStationResultNew != null) { ListItem stationImportNew = new ListItem(); stationImportNew.Value = searchStationResultNew.StationID.ToString() + "#" + searchStationResultNew.StationTableID.ToString(); stationImportNew.Text = searchStationResultNew.StationName + "(" + searchStationResultNew.StationID.ToString() + ")"; lboxStationReal.Items.Add(stationImportNew); } else { Response.Write("<script>alert('新站点成功插入,但检索失败!');</script>"); } } else { Response.Write("<script>alert('新站点号或名称插入失败!');</script>"); } } } stLine = srReader.ReadLine(); } srReader.Close(); lbPathname.Text = fuSelectStaFile.PostedFile.FileName; lbSelectedCity.Text = "已选城市列表:共" + lboxStationReal.Items.Count + "个城市!"; } catch (Exception Exc) { lb_error.Text = Exc.Message; } } else { lb_error.Text = "只允许导入.sta文件!"; } } else { lb_error.Text = "请选择一个城市列表文件"; } } else { lbShowError.Text = "* 请正确选择需要操作的*栏目*"; lbShowError.Visible = true; } }