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 testSetAllSetting() { //Model.ChannelProgram mcp, Model.ElementRelation[] mer,Model.StationRelation[] msr Model.ChannelProgram mcp = new Model.ChannelProgram(); mcp.CP_ID = 170; mcp.DataTypeID = 1; mcp.TimeTypeID = 8; Model.ElementRelation[] mer = new Model.ElementRelation[3]; Model.ElementRelation mer_single1 = new Model.ElementRelation(); mer_single1.ElementID = 1; mer_single1.ElementOrder = 0; Model.ElementRelation mer_single2 = new Model.ElementRelation(); mer_single2.ElementID = 3; mer_single2.ElementOrder = 1; Model.ElementRelation mer_single3 = new Model.ElementRelation(); mer_single3.ElementID = 7; mer_single3.ElementOrder = 2; mer[0] = mer_single1; mer[1] = mer_single2; mer[2] = mer_single3; Model.StationRelation[] msr = new Model.StationRelation[3]; Model.StationRelation msr_single1 = new Model.StationRelation(); msr_single1.SelectID = 172; msr_single1.StationID = 50774; msr_single1.StationOrder = 0; Model.StationRelation msr_single2 = new Model.StationRelation(); msr_single2.SelectID = 30; msr_single2.StationID = 56778; msr_single2.StationOrder = 1; Model.StationRelation msr_single3 = new Model.StationRelation(); msr_single3.SelectID = 512; msr_single3.StationID = 59432; msr_single3.StationOrder = 2; msr[0] = msr_single1; msr[1] = msr_single2; msr[2] = msr_single3; BLL.SettingBLL sbll = new BLL.SettingBLL(); String[] display = new String[5]; display = sbll.setAllSetting(mcp, mer, msr); Label1.Text = display[0] + "/" + display[1] + "/" + display[2] + "/" + display[3] + "/" + display[4]; }
public void testSearchStationInfo2() { Model.StationRelation msr = new Model.StationRelation(); msr.StationID = 54511; msr.StationName = "北xx京"; BLL.DataBLL dbll = new BLL.DataBLL(); Model.StationRelation msr2 = dbll.searchStationInfo2(msr); //Label1.Text = msr2.SelectID + "|" + msr2.StationID + "|" + msr2.StationName + "|" + msr2.StationTableID; }
public void testinsertSetStationsInfoReturnID() { Model.StationRelation msr = new Model.StationRelation(); msr.StationID = 54511; msr.StationName = "beijingReturnID2"; BLL.SettingBLL sbll = new BLL.SettingBLL(); //int done = sbll.setStationsInfo(msr, "insert"); Label1.Text = sbll.insertStationsInfoReturnID(msr).StationTableID.ToString() + "---" + sbll.insertStationsInfoReturnID(msr).SelectID.ToString(); }
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(); }
protected void bSet_Click(object sender, EventArgs e) { int elementCount = lboxDisplaySelected.Items.Count; int stationCount = lboxStationReal.Items.Count; if (trProgram.SelectedNode.Parent != null && elementCount != 0 && stationCount != 0 && ddlTimeType.SelectedValue != "选择数据时段" && ddlDataType.SelectedValue != "选择数据类型") { string[] cpInfo = trProgram.SelectedNode.Value.Split('#'); Model.ChannelProgram mcp = new Model.ChannelProgram(); mcp.CP_ID = Convert.ToInt32(cpInfo[0]); mcp.DataTypeID = Convert.ToInt32(ddlDataType.SelectedValue); mcp.TimeTypeID = Convert.ToInt32(ddlTimeType.SelectedValue); trProgram.SelectedNode.Value = cpInfo[0] + "#" + ddlTimeType.SelectedValue + "#" + ddlDataType.SelectedValue; Model.ElementRelation[] mer = new Model.ElementRelation[elementCount]; Model.StationRelation[] msr = new Model.StationRelation[stationCount]; for (int i = 0; i < elementCount; i++) { Model.ElementRelation merSingle = new Model.ElementRelation(); merSingle.ElementID = Convert.ToInt32(lboxDisplaySelected.Items[i].Value); merSingle.ElementOrder = i; mer[i] = merSingle; } for (int i = 0; i < stationCount; i++) { Model.StationRelation msrSingle = new Model.StationRelation(); string[] stationInfo = lboxStationReal.Items[i].Value.Split('#'); msrSingle.StationID = Convert.ToInt32(stationInfo[0]); msrSingle.SelectID = Convert.ToInt32(stationInfo[1]); msrSingle.StationOrder = i; msr[i] = msrSingle; } string[] setStationResult = sdbll.setAllSetting(mcp, mer, msr); int resultCount = setStationResult.Length; int doneCount = 0; for (int i = 0; i < resultCount; i++) { if (setStationResult[i] == "done") { doneCount++; } } if (doneCount == resultCount) { Response.Write("<script>alert('设置栏目成功!');</script>"); } else { Response.Write("<script>alert('设置栏目失败!');</script>"); } } else { Response.Write("<script>alert('请检查信息是否填充完整!');</script>"); } }
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(); }
public void testSearchStationInfo() { Model.StationRelation msr = new Model.StationRelation(); msr.StationID = 54511; //msr.StationName = "北"; BLL.DataBLL dbll = new BLL.DataBLL(); Model.StationRelation[] msr2 = dbll.searchStationInfo(msr); for (int i = 0; i < msr2.Length; i++) { al.Add(msr2[i]); } }
protected void gvStationInfo_RowDeleting(object sender, GridViewDeleteEventArgs e) { string staName = gvStationInfo.Rows[e.RowIndex].Cells[3].Text; Model.StationRelation msr = new Model.StationRelation(); msr.StationTableID = Convert.ToInt32(gvStationInfo.DataKeys[e.RowIndex].Values[0].ToString()); if (sdbll.setStationsInfo(msr, "delete") == 0) { Response.Write(String.Format("<script language=\"javascript\" type=\"text/javascript\">alert('城市:{0} 删除成功!');</script>", staName)); } else { Response.Write(String.Format("<script language=\"javascript\" type=\"text/javascript\">alert('城市:{0} 删除失败!');</script>", staName)); } btnQuery_Click(sender, e); }
protected void btnAddOper_Click(object sender, EventArgs e) { int cpID = Convert.ToInt32(ddlUserCP_Add.SelectedValue); string cpName = ddlUserCP_Add.SelectedItem.Text; string staID = tbStaID_Add.Text.Trim(); string staName = tbStaName_Add.Text.Trim(); // 检查输入 if (!isValidInt(staID)) { Response.Write("<script>alert('站点编号必须为数字!');</script>"); return; } // 配置操作 Model.StationRelation msr = new Model.StationRelation(); msr.StationID = Convert.ToInt32(staID); msr.StationName = staName; msr.CP_ID = Convert.ToInt32(cpID); int selectID = -1; // 用来接收新添加的站点索引 if (sdbll.addStationInfoWithSetting(msr, out selectID)) { Response.Write(String.Format("<script language=\"javascript\" type=\"text/javascript\">alert('栏目:{0} 城市:{1} 配置成功!');</script>", cpName, staName)); // 定位最新添加的城市 findAddedStation(ddlUserChannel_Add.SelectedValue, ddlUserCP_Add.SelectedValue, selectID); btnAddCancel_Click(sender, e); // 返回到城市列表 } else { Response.Write(String.Format("<script language=\"javascript\" type=\"text/javascript\">alert('栏目:{0} 城市:{1} 配置失败!');</script>", cpName, staName)); } }
protected void btnQuery_Click(object sender, EventArgs e) { Model.StationRelation msr = new Model.StationRelation(); msr.Channel_ID = Convert.ToInt32(ddlUserChannel.SelectedValue); msr.Program_ID = Convert.ToInt32(ddlUserCP.SelectedValue); msr.StationID = tbStaID.Text.Trim() == "" ? -1 : Convert.ToInt32(tbStaID.Text.Trim()); msr.StationName = tbStaName.Text.Trim() == "" ? null : tbStaName.Text.Trim(); msrs = null; if (Session["UserRole"] != null && Session["UserRole"].ToString() == "0") { // 管理员可查询所有栏目的城市列表 msrs = dbll.getStations(null, msr); } else if (Session["UserRole"] != null && Session["UserRole"].ToString() == "1") { // 制片人仅查询所属栏目的城市列表 string userID = Session["UserID"].ToString(); msrs = dbll.getStations(userID, msr); } if (msrs != null && msrs.Length > 0) { lblMessage.Text = ""; headDynRow.Visible = true; } else { lblMessage.Text = "没有查询到任何符合条件的城市!"; headDynRow.Visible = false; } gvStationInfo.DataSource = msrs; gvStationInfo.DataBind(); }
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; } }