功能需求:
1.有部门管理权限的人员进行添加部门基本信息。
2.有部门权限管理的人员查询部门基本信息。
3.有部门权限管理的人员进行修改部门基本信息。
4.在一个页面中实现,使用弹出对话框方式
存储过程:
-- ============================================= ALTER PROCEDURE [dbo].[Department_Add] @DepartmentName nvarchar(50), @Tel1 nvarchar(20), @Tel2 nvarchar(20), @ReMark nvarchar(200) AS BEGIN INSERT INTO Department ( DepartmentName, Tel1, Tel2, ReMark ) VALUES ( @DepartmentName, @Tel1, @Tel2, @ReMark ) --修改部门显示顺序 DECLARE @id int SET @[email protected]@IDENTITY UPDATE Department SET Displayorder [email protected] WHERE [email protected] END
修改:
------------------------------------ ALTER PROCEDURE [dbo].[Department_Update] @DepartmentId int, @DepartmentName nvarchar(50), @Tel1 nvarchar(20), @Tel2 nvarchar(20), @Displayorder int, @ReMark nvarchar(200) AS UPDATE [Department] SET [DepartmentName] = @DepartmentName,[Tel1] = @Tel1,[Tel2] = @Tel2,[Displayorder] = @Displayorder,[ReMark] = @ReMark WHERE [email protected]
前台的页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StockEdit.aspx.cs" Inherits="BioErpWeb.StockSystem.StockEdit" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link href="../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" /> <link href="../Styles/CalenderStyle.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .style1 { width: 100px; } </style> <script src="../JS/CheckUserNames.js" type="text/javascript"></script> <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script type="text/javascript"> var i = 0; $(document).ready(function () { $("#btnaddRow").click(function () { i++; var tr = ‘<tr id="tr‘ + i + ‘"><td><input type="text" name="UserId" id="txtUserName"/></td><td class="style1"><input type="button" value="选择员工" style=" width:100px;" onclick="showDialog()"/></td></tr>‘; $("#caption").before(tr); }); $("#btnDeleteRow").click(function () { var lasttr = $("#tr" + i); lasttr.remove(); i--; }); //验证 $("#btnSubmit").click(function () { var stockname = $("#txtStockName"); if (stockname.val() == ‘‘) { alert("请填写仓库名称"); return false; } var stockaddress = $("#txtAddress"); if (stockaddress.val() == ‘‘) { alert("请填写仓库地址"); return false; } //2011年10月26日9:54:56 完善下拉列表验证 var selectcompany = $("#ddlCompany"); var selectCaption = selectcompany.select(); if (selectCaption.val() == 0) { alert("请选择所属公司"); return false; } var userids = document.getElementsByName("UserId"); for (var j = 0; j < userids.length; j++) { if (userids[j].value == ‘‘ || userids[j].value == ‘请选择‘) { alert("请选择第" + (j + 1) + "行用户编号"); return false; } } return true; }); }); //添加count行 单元格 function addRow(count) { for (var j = 1; j < count; j++) { i++; var tr = ‘<tr id="tr‘ + i + ‘"><td><input type="text" name="UserId" id="txtUserName"/></td><td class="style1"><input type="button" value="选择员工" style=" width:100px;" onclick="showDialog()"/></td></tr>‘; $("#caption").before(tr); } } //给员工控件设置userid function setValues(userids) { // alert(userids); var useridlist = userids.split(‘,‘); var txtuserids = document.getElementsByName("UserId"); for (var j = 0; j < useridlist.length; j++) { txtuserids[j].value = useridlist[j]; } } </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <table class="maintable"> <tr> <td class="titlebar" colspan="2"> <span>仓库信息管理系统</span> </td> </tr> <tr> <td> 库房名称: </td> <td> <asp:TextBox ID="txtStockName" Width="200px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> 库房地址: </td> <td> <asp:TextBox ID="txtAddress" Width="200px" runat="server"></asp:TextBox> </td> </tr> <tr> <td> 所属公司 </td> <td> <asp:DropDownList ID="ddlCompany" Width="200px" runat="server"> </asp:DropDownList> </td> </tr> <tr> <td> 仓库管理员 </td> <td> <table> <tr><td><input type="text" name="UserId" id="txtUserName"/></td><td class="style1"><input type="button" value="选择员工" style=" width:100px;" onclick="showDialog()"/></td></tr> <tr id="caption"><td colspan="2" style=" text-align:right;"><input type="button" id="btnaddRow" value="添加一行" style=" width:100px;"/> <input type="button" value="删除一行" id="btnDeleteRow" style=" width:100px;"/></td></tr> </table> </td> </tr> <tr> <td> 仓库状态 </td> <td> <asp:DropDownList ID="ddlState" runat="server"> <asp:ListItem Value="1">正常</asp:ListItem> <asp:ListItem Value="0">停用</asp:ListItem> </asp:DropDownList> </td> </tr> <tr > <td class="bottomtd" colspan="2"> <asp:Button ID="btnSubmit" runat="server" Text="仓库信息修改" CssClass="submitbutton" onclick="btnSubmit_Click" /> </td> </tr> </table> <br /> </div> </form> </body> </html>
BLL层:
public class DepartMentBLL { /// <summary> /// 添加 /// </summary> /// <param name="de"></param> /// <returns></returns> public int DepartMentAdd(DepartMent de) { SqlParameter[] parameters = { new SqlParameter("@DepartmentName", SqlDbType.NVarChar,50), new SqlParameter("@Tel1", SqlDbType.NVarChar,20), new SqlParameter("@Tel2", SqlDbType.NVarChar,20), new SqlParameter("@ReMark", SqlDbType.NVarChar,200)}; parameters[0].Value = de.DepartmentName; parameters[1].Value = de.Tel1; parameters[2].Value = de.Tel2; parameters[3].Value = de.ReMark; return DataBaseHelper.ExcuteSqlReturnInt("Department_ADD", CommandType.StoredProcedure, parameters); } /// <summary> /// 修改 /// </summary> /// <param name="de"></param> /// <returns></returns> public int DepartMentUpdate(DepartMent de) { SqlParameter[] parameters = { new SqlParameter("@DepartmentId", SqlDbType.Int,4), new SqlParameter("@DepartmentName", SqlDbType.NVarChar,50), new SqlParameter("@Tel1", SqlDbType.NVarChar,20), new SqlParameter("@Tel2", SqlDbType.NVarChar,20), new SqlParameter("@Displayorder", SqlDbType.Int,4), new SqlParameter("@ReMark", SqlDbType.NVarChar,200)}; parameters[0].Value = de.DepartmentId; parameters[1].Value = de.DepartmentName; parameters[2].Value = de.Tel1; parameters[3].Value = de.Tel2; parameters[4].Value = de.Displayorder; parameters[5].Value = de.ReMark; return DataBaseHelper.ExcuteSqlReturnInt("Department_Update", CommandType.StoredProcedure, parameters); } /// <summary> /// 根据ID获取编号 /// </summary> /// <param name="ID"></param> /// <returns></returns> public DepartMent getDepartMentById(string ID) { DepartMent d = new DepartMent(); return null; } }
界面层:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { pagebind(); } } public static int pageindex = 0; public static int pagesize = 10; public static string condition = ""; protected void pagebind() { this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("Department", condition); this.AspNetPager1.PageSize = pagesize; this.GridView1.DataSource = SqlComm.getDataByPageIndex("Department", "*", "DepartmentId", condition, pageindex, pagesize); this.GridView1.DataBind(); } DepartMentBLL debll = new DepartMentBLL(); protected void btnAdd_Click(object sender, EventArgs e) { DepartMent de = new DepartMent(); de.DepartmentName = this.txtDepartMent0.Text; de.ReMark = this.txtReMark.Text; de.Tel1 = this.txtTel10.Text; de.Tel2 = this.txtTel20.Text; if (debll.DepartMentAdd(de) != 0) { pagebind(); } this.Modal_Add.Hide(); } protected void AspNetPager1_PageChanged(object sender, EventArgs e) { pageindex = this.AspNetPager1.CurrentPageIndex - 1; pagebind(); } protected void btnUpdate_Click(object sender, EventArgs e) { } protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "imgEdit") { this.Modal_Update.Show(); } } protected void btnClose1_Click(object sender, EventArgs e) { this.Modal_Update.Hide(); }
时间: 2024-10-14 04:32:24