protected void Page_Load(object sender, EventArgs e) { permission(); //获取地区下拉框数据 dsCustom = libraryCollectionBll.getCustomer(); //getData(); custom = Request["custom"]; string action = Request["action"]; string op = Request["op"]; if (op == "change" || op == "paging") { getData(); } if (action == "import") { DataTable dtInsert = new DataTable(); System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); dtInsert = excelToDt(); TimeSpan ts = watch.Elapsed; dtInsert.TableName = "T_LibraryCollection"; //导入的表名 int a = userBll.BulkInsert(dtInsert); watch.Stop(); double minute = ts.TotalMinutes; //计时 string m = minute.ToString("0.00"); if (a > 0) { //int cf = row - a; Session["path"] = null; //清除路径session //Response.Write("导入成功,总数据有" + row+"条,共导入"+a+"条数据"+",共用时:"+ m+"分钟"); Response.Write("导入成功,共导入数据" + a + "条数据"); Response.End(); } else { Session.Remove("path"); //Response.Write("导入失败,总数据有" + row + "条,共导入" + a + "条数据"); Response.Write("导入失败,远程服务器未响应"); Response.End(); } } else if (action == "del") { int custom = Convert.ToInt32(Request["custom"]); Result result = libraryCollectionBll.deleteByCus(custom); if (result == Result.除成功) { Response.Write("删除成功"); Response.End(); } else { Response.Write("删除失败"); Response.End(); } } if (op == "logout") { //删除身份凭证 FormsAuthentication.SignOut(); //设置Cookie的值为空 Response.Cookies[FormsAuthentication.FormsCookieName].Value = null; //设置Cookie的过期时间为上个月今天 Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(-1); } }
protected void Page_Load(object sender, EventArgs e) { permission(); //getData(); string op = Request["op"]; if (op == "paging") { getData(); } if (op == "add") { int regionId; if (user.RoleId.RoleName == "超级管理员") { regionId = int.Parse(Request["regionId"]); } else { regionId = user.ReginId.RegionId; } string shelfName = Request["shelfName"]; string shelfNo = Request["shelfNo"]; Region reg = new Region() { RegionId = regionId }; GoodsShelves shelves = new GoodsShelves() { GoodsShelvesId = shelfNo, ShelvesName = shelfName, RegionId = reg }; int row = shelvesbll.selectByName(shelves); if (row == 0) { Result result = shelvesbll.Insert(shelves); if (result == Result.添加成功) { Response.Write("添加成功"); Response.End(); } else { Response.Write("添加成功"); Response.End(); } } else if (row == 1) { Response.Write("货架编号已存在"); Response.End(); } else if (row == -1) { Response.Write("货架名称已存在"); Response.End(); } else { Response.Write("货架编号,货架名称已存在"); Response.End(); } //Result row = shelvesbll.selectByName(shelves); //if (row == Result.记录不存在) //{ // Result result = shelvesbll.Insert(shelves); // if (result == Result.添加成功) // { // Response.Write("添加成功"); // Response.End(); // } // else // { // Response.Write("添加成功"); // Response.End(); // } //} //else //{ // Response.Write("货架名已存在"); // Response.End(); //} } if (op == "del") { string shelfId = Request["shelfId"]; Result result = isDelete(); if (result == Result.记录不存在) { Result row = shelvesbll.DeleteTrue(shelfId); if (row == Result.除成功) { Response.Write("删除成功"); Response.End(); } else { Response.Write("删除失败"); Response.End(); } } else { Response.Write("已关联引用,无法删除"); Response.End(); } } if (op == "logout") { //删除身份凭证 FormsAuthentication.SignOut(); //设置Cookie的值为空 Response.Cookies[FormsAuthentication.FormsCookieName].Value = null; //设置Cookie的过期时间为上个月今天 Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMonths(-1); } if (op == "import") { DataTable dtInsert = new DataTable(); System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); dtInsert = differentDt(); //赋给新table TimeSpan ts = watch.Elapsed; dtInsert.TableName = "T_GoodsShelves"; //导入的表名 int a = userBll.BulkInsert(dtInsert); watch.Stop(); double minute = ts.TotalMinutes; //计时 string m = minute.ToString("0.00"); int cf = row - a; if (a > 0) { Response.Write("导入成功,总数据有" + row + "条,共导入" + a + "条数据" + ",共用时:" + m + "分钟"); Response.End(); } else { Response.Write("导入失败,总数据有" + row + "条,共导入" + a + "条数据,重复数据有" + cf); Response.End(); } } if (op == "check") { check(); } }