Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            permission();
            dsSupplier = bookbll.selectSupplier();
            //获取书号
            BookBasicData bookId = bookbll.getBookNum();

            if (!IsPostBack)
            {
                if (bookId.NewBookNum == "0" || bookId.NewBookNum == null || bookId.NewBookNum.Length < 8)
                {
                    num = "0";
                }
                else
                {
                    num = bookId.NewBookNum;
                }
                ViewState["i"] = num;
            }
            //getData();
            string op = Request["op"];

            if (op == "paging")
            {
                getData();
            }
            if (op == "del")
            {
                string bookNum = Request["bookNum"].ToString();
                Result row     = isDelete();
                if (row == Result.记录不存在)
                {
                    Result result = bookbll.Delete(bookNum);
                    if (result == Result.除成功)
                    {
                        Response.Write("删除成功");
                        Response.End();
                    }
                    else

                    {
                        Response.Write("删除失败");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("此资料已有关联订单,无法删除!");
                    Response.End();
                }
            }
            if (op == "check")
            {
                test();
            }
            if (op == "export")
            {
                excelBook();
            }
            string action = Request["action"];

            if (action == "import")
            {
                differentDt();
                //DataTable dtInsert = new DataTable();
                //System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                //watch.Start();
                //differentDt();
                //except.Columns.Remove("id"); //移除匹配列
                //dtInsert = except; //赋给新table
                //TimeSpan ts = watch.Elapsed;
                //dtInsert.TableName = "T_BookBasicData"; //导入的表名
                //int a = userBll.BulkInsert(dtInsert);
                //watch.Stop();
                //double minute = ts.TotalMinutes; //计时
                //string m = minute.ToString("0.00");
                //if (a > 0)
                //{
                //    int cf = row - a;
                //    BookBasicData bookNum = bookbll.getBookNum();
                //    Result result = bookbll.updateBookNum(last); //更新书号
                //    //Response.Write("导入成功,总数据有" + row + "条,共导入" + a + "条数据" + ",共用时:" + m + "分钟");
                //    Response.Write("导入成功,共导入数据"+a+"条数据,共有重复数据"+cf+"条");
                //    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);
            }
        }