Frog Frog Recommended: Oven User Management System

xiaoxiao2021-03-06  112

Frog Frog Recommended: Oven User Management System

Because the code is more, just post, add the user's code, I separate the representation layer and the business logic layer, establish a CLS_USER class separately to manage the user, including add, delete, modify the user The method, as well as the fields of accessing the user's name, password, permissions, etc. Separately do the principle of multi-layer architecture, I have not made DAL layers alone because I plan to change the database later.

There are several drop-down list controls in the front of the front desk, I am separately binding with the hash table and DATATABLE, and it is a tip.

In the class of business logic I use the output parameters of the method, you can use it by the way.

First post display code? Pay attention to the DataTextField and DataValuefield properties of the DROPDOWNLIST control

Add_User.aspx

<% @ Page language = "c #" codebehind = "adduser.aspx.cs" autoeventwireup = "false" inherits = "oa.admin.users.adduser"%>%>%>

adduser </ title></p> <p><meta content = "false" Name = "vs_snaptogrid"></p> <p><meta content = "Microsoft Visual Studio .NET 7.1" Name = "Generator"></p> <p><meta content = "c #" Name = "code_language"></p> <p><meta content = "javascript" name = "vs_defaultclientscript"></p> <p><meta content = "http://schemas.microsoft.com/intellisense/ie5" Name = "vs_targetschema"></p> <p><Link href = "../../ style / wawa.css" type = "text / css" rel = "stylesheet"></p> <p></ HEAD></p> <p><body ms_positioning = "flowlayout"></p> <p><form id = "form1" method = "post" runat = "server"></p> <p><Table ID = "Table1" Cellspacing = "1" Cellpadding = "1" width = "500" border = "1"></p> <p><Tr></p> <p><TD align = "left" colspan = "3"></p> <p><P align = "center"> <font face = "Song"> </ font> <font face = "Song"> Add User </ font> </ p> </ td></p> <p></ TR></p> <p><Tr></p> <p><TD Style = "Height: 16PX"></p> <p><P align = "right"> <font face = "Song"> User Name: </ font> </ p></p> <p></ Td></p> <p><TD Style = "Height: 16px" Align = "Left"></p> <p><P align = "left"> <font face = "Song"> <ask: textbox id = "user_name" runat = "server"> </ asp: textbox> </ font> </ p></p> <p></ Td></p> <p><TD Style = "Height: 16PX"> <font face = "Song"></p> <p><P align = "left"> <asp: requiredfieldvalidator id = "RequiredFieldValidator1" runat = "server" ControlToValidate = "User_Name" ErrorMessage = "User name can not be empty"> </ asp: requiredfieldvalidator> </ P></p> <p></ Font></p> <p></ Td></p> <p></ TR></p> <p><Tr></p> <p><TD></p> <p><P align = "right"> <font face = "Song"> password: </ font> </ p></p> <p></ Td></p> <p><TD align = "left"></p> <p><P align = "left"> <font face = "Song"> <ask: textbox id = "user_psw" runat = "server" textmode = "password"> </ asp: textbox> </ font> </ p></p> <p></ Td></p> <p><TD></p> <p><P align = "left"> <asp: requiredfieldvalidator id = "RequiredFieldValidator2" runat = "server" ControlToValidate = "User_Psw" ErrorMessage = "password is not blank"> </ asp: requiredfieldvalidator> </ P></p> <p></ Td></p> <p></ TR></p> <p><Tr></p> <p><TD Style = "Height: 17px"> <p align = "right"> <font face = "Song"> User type: </ font> </ p></p> <p></ Td></p> <p><TD Style = "Height: 17px" Align = "Left"></p> <p><P align = "left"> <font face = "Song"> <ask: DROPDOWNLIST ID = "user_flag" runat = "server" DataTextField = "key" DataValuefield = "value"> </ asp: dropdownlist> </ font > </ P></p> <p></ Td></p> <p><TD Style = "Height: 17px"></p> <p><P align = "right"> <font face = "Song body"> </ font> </ p></p> <p></ Td></p> <p></ TR></p> <p><Tr></p> <p><TD></p> <p><P align = "right"> <font face = "Song body"> Unit Name: </ font> </ p></p> <p></ Td></p> <p><TD align = "left"></p> <p><P align = "left"> <font face = "Song"> <ask: textbox id = "user_danwei" runat = "server"> </ asp: textbox> </ font> </ p></p> <p></ Td></p> <p><TD></p> <p><P align = "left"> <asp: requiredfieldvalidator id = "RequiredFieldValidator3" runat = "server" ControlToValidate = "User_DanWei" ErrorMessage = "unit name can not be blank"> </ asp: requiredfieldvalidator> </ P></p> <p></ Td></p> <p></ TR></p> <p><Tr></p> <p><TD></p> <p><P align = "right"> <font face = "体"> Region: </ font> </ p></p> <p></ Td></p> <p><TD align = "left"></p> <p><P align = "left"> <ask = "user_address" runat = "server" datatextfield = "s2" DataValuefield = "S1"> </ asp: DropdownList> </ p> </ td></p> <p><TD></p> <p><P align = "right"> </ p></p> <p></ Td></p> <p></ TR></p> <p><Tr></p> <p><TD Style = "Height: 17px"></p> <p><P align = "right"> <font face = "Song body"> User description: </ font> </ p></p> <p></ Td></p> <p><TD Style = "Height: 17px" Align = "Left"> <ask: TextBox ID = "User_Shuoming" runat = "server" textmode = "multiline"> </ asp: textbox> </ td></p> <p><TD style = "HEIGHT: 17px"> <asp: requiredfieldvalidator id = "RequiredFieldValidator4" runat = "server" ControlToValidate = "User_ShuoMing" ErrorMessage = "user instructions can not be empty"> </ asp: requiredfieldvalidator> </ TD></p> <p></ TR></p> <p><Tr></p> <p><TD> </ td></p> <p><TD align = "left"> <ask = "Button1" runat = "server" text = "Add User"> </ asp: button> </ td></p> <p><TD> <font face = "Song"> </ font> </ td></p> <p></ TR></p> <p></ Table></p> <p></ form></p> <p></ body></p> <p></ Html></p> <p>Post the background encoding class of this file:</p> <p>Add_User.aspx.cs</p> <p>Using system;</p> <p>Using system.collections;</p> <p>Using system.componentmodel;</p> <p>Using system.data;</p> <p>Using system.drawing;</p> <p>Using system.Web;</p> <p>Using system.Web.SessionState;</p> <p>Using system.Web.ui;</p> <p>Using system.Web.ui.webcontrols;</p> <p>Using system.Web.ui.htmlcontrols;</p> <p>Namespace OA.Admin.Users</p> <p>{</p> <p>/// <summary></p> <p>/// AdduSer's summary description.</p> <p>/// </ summary></p> <p>Public class adduser: system.web.ui.page</p> <p>{</p> <p>Protected system.Web.ui.WebControls.RequidFieldValidator RequiredFieldValidator1;</p> <p>Protected system.Web.ui.WebControls.RequidFieldValidator RequiredFieldValidator2;</p> <p>Protected system.Web.ui.WebControls.RequidFieldValidator RequiredFieldValidator3;</p> <p>protected system.web.ui.webcontrols.textbox user_name;</p> <p>protected system.web.ui.webcontrols.textbox user_psw;</p> <p>Protected system.Web.ui.webcontrols.dropdownlist user_flag;</p> <p>protected system.web.ui.webcontrols.textbox user_danwei;</p> <p>Protected system.web.ui.webcontrols.dropdownlist user_address;</p> <p>protected system.web.ui.webcontrols.textbox user_shuoming;</p> <p>protected system.web.ui.webcontrols.button button1;</p> <p>Protected system.Web.ui.WebControls.RequidFieldValidator RequiredFieldValidator4;</p> <p>Private Void Page_Load (Object Sender, System.EventArgs E)</p> <p>{</p> <p>User_flag.datasource = HT_USER_FLAG ();</p> <p>User_flag.databind ();</p> <p>ListItem Li = new ListItem ();</p> <p>li.value = "0";</p> <p>Li.Text = "System Administrator";</p> <p>User_flag.Items.insert (0, Li);</p> <p>User_address.dataSource = dt_user_address ();</p> <p>User_address.databind ();</p> <p>/ / Place the user code here to initialize the page</p> <p>}</p> <p>Icollection ht_user_flag ()</p> <p>{</p> <p>Hashtable ht = new hashtable ();</p> <p>HT.Add ("Hall Leaders", "1");</p> <p>HT.Add ("Provincial Lawyers Association", "2");</p> <p>HT.Add ("Provincial Lawyers", "3");</p> <p>HT.Add ("City Lawyers Association", "4");</p> <p>HT.ADD ("City Lawyers", "5");</p> <p>HT.Add ("Provincial Limited Law Firm", "6");</p> <p>Return HT;</p> <p>}</p> <p>ICollection DT_USER_ADDRESS ()</p> <p>{</p> <p>// It is actually tied to such a TEXT and VALUE values.</p> <p>DataTable DT = New DataTable ();</p> <p>// DATAROW DR;</p> <p>DataRow [] Dr = New DataRow [6];</p> <p>Dt.columns.Add (New Datacolumn ("S1", TypeOf (String)))</p> <p>Dt.Columns.Add (New Datacolumn ("S2", TypeOf (String)))); DR [0] = DT.NEWROW ();</p> <p>DR [0] ["S1"] = "Shijiazhuang";</p> <p>DR [0] ["s2"] = "Shijiazhuang";</p> <p>Dt.Rows.Add (DR [0]);</p> <p>DR [1] = DT.NEWROW ();</p> <p>DR [1] ["S1"] = "Baoding";</p> <p>DR [1] ["S2"] = "Baoding";</p> <p>Dt.Rows.Add (DR [1]);</p> <p>DR [2] = DT.NEWROW ();</p> <p>DR [2] ["s1"] = "Xingtai";</p> <p>DR [2] ["S2"] = "Xingtai";</p> <p>Dt.Rows.Add (DR [2]);</p> <p>DR [3] = DT.NEWROW ();</p> <p>DR [3] ["S1"] = "Zhangjiakou";</p> <p>DR [3] ["s2"] = "Zhangjiakou";</p> <p>Dt.Rows.Add (DR [3]);</p> <p>DR [4] = DT.NEWROW ();</p> <p>DR [4] ["S1"] = "Hengshui";</p> <p>DR [4] ["S2"] = "Hengshui";</p> <p>Dt.Rows.Add (DR [4]);</p> <p>DR [5] = DT.NEWROW ();</p> <p>DR [5] ["S1"] = "Zhangzhou";</p> <p>DR [5] ["S2"] = "Zhangzhou";</p> <p>Dt.Rows.Add (DR [5]);</p> <p>DataView DV = New DataView (DT);</p> <p>Return DV;</p> <p>}</p> <p>#Region web form designer generated code</p> <p>Override protected void oninit (Eventargs E)</p> <p>{</p> <p>//</p> <p>// Codegen: This call is necessary for the ASP.NET Web Form Designer.</p> <p>//</p> <p>InitializationComponent ();</p> <p>Base.onit (E);</p> <p>}</p> <p>Private vidinitiRizeComponent ()</p> <p>{</p> <p>This.Button1.click = new system.eventhandler (this.button1_click);</p> <p>This.Load = New System.EventHandler (this.page_load);</p> <p>}</p> <p>#ndregion</p> <p>Private void Button1_Click (Object Sender, System.Eventargs E)</p> <p>{</p> <p>String msg;</p> <p>Oa.cls.cls_user user = new oa.cls.cls_user ();</p> <p>User.user_name = user_name.text.toString ();</p> <p>User.user_psw = user_psw.text.toString ();</p> <p>User.user_flag = user_flag.selecteditedItem.Value.toString ();</p> <p>User.user_danwei = user_danwei.text.tostring ();</p> <p>User.user_address = user_address.selectedItem.Value.toString ();</p> <p>User.user_shuoming = user_shuoming.text.toString ();</p> <p>User.Adduser (OUT MSG))</p> <p>{</p> <p>Response.write ("<script> alert ('" msg "); location.href =' adduser.aspx '; </ script>");</p> <p>Else {</p> <p>Response.write ("No successful success <BR> error message:" msg "<br> SQL statement" user.sql);</p> <p>}</p> <p>}</p> <p>}</p> <p>}</p> <p>Finally, the source code of the user managed by the user I wrote:</p> <p>Using system;</p> <p>Using system.data.sqlclient;</p> <p>Using system.configuration;</p> <p>Namespace OA.CLS</p> <p>{</p> <p>/// <summary></p> <p>/// CLS_USER's summary description.</p> <p>/// </ summary></p> <p>Public Class CLS_USER</p> <p>{</p> <p>Public CLS_USER ()</p> <p>{</p> <p>MyConn = new SqlConnection (String) configurationSettings.appsettings ["connString"]); / / Connect Database</p> <p>MyConn.open (); // Open</p> <p>}</p> <p>Public string user_name; // username</p> <p>Public string user_psw; // user password</p> <p>Public string user_flag; // User permissions</p> <p>Public string user_danwei; // User Unit</p> <p>Public string user_address; // user address</p> <p>Public string user_shuoming; // User Description</p> <p>Private sqlconnection myconn;</p> <p>Public String SQL;</p> <p>Public Bool AddUser (Out String MSG)</p> <p>{</p> <p>// User Add</p> <p>sql = "insert into [Web_User] (User_Name, User_Psw, User_Flag, User_DanWei, User_Address, User_ShuoMing) values ​​( '" User_Name "', '" User_Psw "'," User_Flag ", '" User_DanWei "', ' " User_address ", '" user_shuoming ") ";</p> <p>Sqlcommand cmd = new SQLCOMMAND (SQL, MyConn);</p> <p>Msg = "User Add success";</p> <p>Try</p> <p>{</p> <p>cmd.executenonquery ();</p> <p>Return True;</p> <p>}</p> <p>Catch (SQLEXCEPTION EXC)</p> <p>{</p> <p>Msg = exc.Message;</p> <p>Return False;</p> <p>}</p> <p>Finally</p> <p>{</p> <p>MyConn.close ();</p> <p>}</p> <p>}</p> <p>Public bool edituser ()</p> <p>{</p> <p>Return True;</p> <p>}</p> <p>Public bool deluser ()</p> <p>{</p> <p>Return True;</p> <p>}</p> <p>}</p> <p>}</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-125859.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="125859" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.045</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'RLVl2RsaBsRdeCsevC_2FO_2FgTsjIPfJtfsuTRaJbQ7HkIbB4FuEtztpHpw2OE47bPirUH3ixXuxpN_2FMkdEUUwC6g_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>