Asp.net源码专业站
首页->商务办公->企业资源维护综合管理系统项目源码>>Admins/ChannelManage.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:企业资源维护综合管理系统项目源码
当前文件:文件类型 EnterpriseResource/Admins/ChannelManage.aspx.cs[7K,2009-6-12 11:41:55]打开代码结构图
普通视图
		            
1using System; 2using System.Collections; 3using System.ComponentModel; 4using System.Data; 5using System.Drawing; 6using System.Web; 7using System.Web.SessionState; 8using System.Web.UI; 9using System.Web.UI.WebControls; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12 13namespace Service 14{ 15 /// <summary> 16 /// Summary description for ChannelManage. 17 /// </summary> 18 public partial class ChannelManage : System.Web.UI.Page 19 { 20 21 public String sOperation = ""; 22 public String sLinkName = ""; 23 24 protected void Page_Load(object sender, System.EventArgs e) 25 { 26 if(Session["UserID"] == null) 27 { 28 Response.Redirect("~/Default.aspx"); 29 } 30 else 31 { 32 String sUserRoleName = UserDB.GetUserLoginRole(Int32.Parse(Session["UserID"].ToString())); 33 if(sUserRoleName.IndexOf("Admin") == -1) 34 { 35 Response.Redirect("~/Default.aspx"); 36 } 37 } 38 39 if(!Page.IsPostBack) 40 { 41 BindDirectionData(); 42 43 if(DirectionList.Items.Count > 0) 44 { 45 BindChannelData(Int32.Parse(DirectionList.SelectedValue)); 46 } 47 } 48 49 deleteBtn.Attributes.Add("onclick","return confirm('你确定要删除所选择的问题吗?');"); 50 51 if(Request.Params["LinkID"] != null) 52 { 53 GetLinkName(Request.Params["LinkID"].ToString()); 54 } 55 } 56 57 private void GetLinkName(String sLinkID) 58 { 59 String[] aName = new String[2]; 60 aName = GlobalVarables.GetLinkName(sLinkID); 61 62 if(GlobalVarables.aLinkName.Count > 0) 63 { 64 sOperation = aName[0].ToString(); 65 sLinkName = aName[1].ToString(); 66 } 67 } 68 69 private void BindDirectionData() 70 { 71 DirectionList.Items.Clear(); 72 73 DirectionDB dir = new DirectionDB(); 74 SqlDataReader recd = dir.GetDirections(); 75 76 DirectionList.DataSource = recd; 77 DirectionList.DataTextField = "DirectionName"; 78 DirectionList.DataValueField = "ID"; 79 DirectionList.DataBind(); 80 81 recd.Close(); 82 } 83 84 private void BindChannelData(int nDirectionID) 85 { 86 ChannelList.Items.Clear(); 87 88 ChannelDB channel = new ChannelDB(); 89 SqlDataReader recc = channel.GetChannels(nDirectionID); 90 91 ChannelList.DataSource = recc; 92 ChannelList.DataTextField = "ChannelName"; 93 ChannelList.DataValueField = "ID"; 94 ChannelList.DataBind(); 95 96 recc.Close(); 97 } 98 99 Web Form Designer generated code 120 121 private void MoveEdit_Click(object sender, System.Web.UI.ImageClickEventArgs e) 122 { 123 String commandName = ((ImageButton)sender).CommandName; 124 125 if(ChannelList.SelectedIndex > -1) 126 { 127 switch(commandName) 128 { 129 case "edit": 130 { 131 UpdateChannelName(); 132 133 break; 134 } 135 case "delete": 136 { 137 DeleteChannel(); 138 139 //控制更新Panel的可见性 140 ControlUpdatePanelVisible(); 141 142 break; 143 } 144 default: 145 { 146 //控制更新Panel的可见性 147 ControlUpdatePanelVisible(); 148 149 break; 150 } 151 } 152 if(commandName == "delete") 153 { 154 //重新绑定ChannelList的数据 155 BindChannelData(Int32.Parse(DirectionList.SelectedValue)); 156 } 157 } 158 else 159 { 160 Response.Write("<script>alert(\"请选择你的数据项!\")</script>"); 161 } 162 } 163 164 private void UpdateChannelName() 165 { 166 UpdatePanel.Visible = true; 167 168 ChannelDB channel = new ChannelDB(); 169 SqlDataReader recc = channel.GetSingleChannel(Int32.Parse(ChannelList.SelectedValue)); 170 171 while(recc.Read()) 172 { 173 EditChannelName.Text = recc["ChannelName"].ToString(); 174 } 175 recc.Close(); 176 } 177 178 private void DeleteChannel() 179 { 180 ChannelDB channel = new ChannelDB(); 181 182 try 183 { 184 channel.DeleteChannel(Int32.Parse(ChannelList.SelectedValue)); 185 } 186 catch(Exception ex) 187 { 188 string sRawURL = Request.RawUrl; 189 190 if(sRawURL.IndexOf("?") > -1) 191 { 192 sRawURL = sRawURL.Substring(0,sRawURL.IndexOf("?")); 193 } 194 Response.Redirect("~/ManageSystem/ErrorPage.aspx?ErrorUrl=" + sRawURL + "&ErrorMessage=" + ex.Message.Replace("\n"," ")); 195 } 196 } 197 198 protected void UpdateBtn_Click(object sender, System.EventArgs e) 199 { 200 UpdatePanel.Visible = false; 201 202 ChannelDB channel = new ChannelDB(); 203 204 if(IsExistEqualName(ChannelList,EditChannelName.Text.Trim()) == false) 205 { 206 try 207 { 208 channel.UpdateChannel(Int32.Parse(ChannelList.SelectedValue),EditChannelName.Text.Trim(),Int32.Parse(DirectionList.SelectedValue)); 209 } 210 catch(Exception ex) 211 { 212 string sRawURL = Request.RawUrl; 213 214 if(sRawURL.IndexOf("?") > -1) 215 { 216 sRawURL = sRawURL.Substring(0,sRawURL.IndexOf("?")); 217 } 218 Response.Redirect("~/ManageSystem/ErrorPage.aspx?ErrorUrl=" + sRawURL + "&ErrorMessage=" + ex.Message.Replace("\n"," ")); 219 } 220 221 BindChannelData(Int32.Parse(DirectionList.SelectedValue)); 222 } 223 else 224 { 225 Response.Write("<script>alert(\"添加数据项已经存在,请重新输入!\");</script>"); 226 } 227 } 228 229 protected void AddChannel_Click(object sender, System.EventArgs e) 230 { 231 if(DirectionList.SelectedIndex > -1) 232 { 233 if(ChannelName.Text.Trim().Length > 0) 234 { 235 if(IsExistEqualName(ChannelList,ChannelName.Text.Trim()) == false) 236 { 237 ChannelDB channel = new ChannelDB(); 238 239 try 240 { 241 channel.AddChannel(ChannelName.Text.Trim(),Int32.Parse(DirectionList.SelectedValue)); 242 } 243 catch(Exception ex) 244 { 245 string sRawURL = Request.RawUrl; 246 247 if(sRawURL.IndexOf("?") > -1) 248 { 249 sRawURL = sRawURL.Substring(0,sRawURL.IndexOf("?")); 250 } 251 Response.Redirect("~/ManageSystem/ErrorPage.aspx?ErrorUrl=" + sRawURL + "&ErrorMessage=" + ex.Message.Replace("\n"," ")); 252 } 253 254 //增加成功后,重新绑定数据和清空名称输入框 255 ChannelName.Text = ""; 256 BindChannelData(Int32.Parse(DirectionList.SelectedValue)); 257 } 258 else 259 { 260 Response.Write("<script>alert(\"添加数据项已经存在,请重新输入!\");</script>"); 261 } 262 } 263 else 264 { 265 Response.Write("<script>alert(\"添加数据项不能为空,请重新输入!\");</script>"); 266 } 267 } 268 269 //控制更新Panel的可见性 270 ControlUpdatePanelVisible(); 271 } 272 273 protected void DirectionList_SelectedIndexChanged(object sender, System.EventArgs e) 274 { 275 if(DirectionList.Items.Count > 0) 276 { 277 BindChannelData(Int32.Parse(DirectionList.SelectedValue)); 278 } 279 } 280 281 private void ControlUpdatePanelVisible() 282 { 283 if(UpdatePanel.Visible == true) 284 { 285 UpdatePanel.Visible = false; 286 } 287 } 288 289 private bool IsExistEqualName(ListBox listBox,String addText) 290 { 291 bool isExist = false; 292 if(listBox.Items.Count > 0) 293 { 294 for(int i = 0; i < listBox.Items.Count; i++) 295 { 296 if(listBox.Items[i].Text == addText) 297 { 298 isExist = true; 299 break; 300 } 301 } 302 } 303 return(isExist); 304 } 305 } 306} 307
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:企业资源维护综合管理系统项目源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146