Пример #1
0
 protected void btndelinfo_Click(object sender, EventArgs e)
 {
     HyoaClass.Hyoa_bak Hyoa_bak = new HyoaClass.Hyoa_bak();
     DataTable dt = new DataTable();
     String[] v_uids = this.txtuids.Value.Split(',');
     for (var i = 0; i < v_uids.Length; i++)
     {
         if (v_uids[i] != "")
         {
             //删除附件
             string ls_filepath = "";
             dt = Hyoa_bak.Getdocbydocid(v_uids[i].ToString());
             ls_filepath = Server.MapPath("~/") + "bak/" + dt.Rows[0]["hy_name"].ToString() + ".rar";
             if (System.IO.File.Exists(ls_filepath))
             {
                 System.IO.File.Delete(ls_filepath);
             }
             Hyoa_bak.DOCID = v_uids[i];
             Hyoa_bak.Delete();
         }
     }
     this.txtuids.Value = "";
     DataPlay(System.Int32.Parse(this.curpage.Text));
 }
Пример #2
0
    private void DataPlay(int PageNo)
    {
        //判断当前用户是否有新建删除权限
        HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
        if (Hyoa_global.isHaveRole("Role9999", this.Session["hyuid"].ToString()))
        {
            this.isrole.Value = "1";
            this.tdnewdoc.Visible = true; //新建
            this.tddeldoc.Visible = true; //删除

        }
        else
        {
            this.isrole.Value = "0";
            this.tdnewdoc.Visible = false; //新建
            this.tddeldoc.Visible = false; //删除
        }

        //得到当前页号
        this.curpage.Text = PageNo.ToString();
        HyoaClass.Hyoa_bak Hyoa_bak = new HyoaClass.Hyoa_bak();

        DataTable dt;
        dt = Hyoa_bak.Getdocs();

        DataTable tempTable = dt.Clone();
        for (int i = (PageNo - 1) * System.Int32.Parse(PageSize.Text); i < PageNo * System.Int32.Parse(PageSize.Text); i++)
        {
            if (i > dt.Rows.Count - 1)
                break;

            DataRow dr = tempTable.NewRow();
            for (int j = 0; j < dt.Columns.Count; j++)
            {
                dr[dt.Columns[j].ColumnName] = dt.Rows[i][j];
            }
            tempTable.Rows.Add(dr);
        }

        int TotalRecord = dt.Rows.Count;
        this.sumts.Text = TotalRecord.ToString();
        this.sumts2.Text = TotalRecord.ToString();
        this.ShowTotalRecord.Text = TotalRecord.ToString();
        //计算及显示总页数
        int TotalPage;
        if (TotalRecord < System.Int32.Parse(PageSize.Text))
        {
            TotalPage = 1;
        }
        else
        {
            if (TotalRecord % System.Int32.Parse(PageSize.Text) != 0)
            {
                TotalPage = TotalRecord / System.Int32.Parse(PageSize.Text) + 1;

            }
            else
            {
                TotalPage = TotalRecord / System.Int32.Parse(PageSize.Text);

            }
        }
        this.ShowTotalPage.Text = TotalPage.ToString();
        this.rptlist.DataSource = tempTable;
        this.rptlist.DataBind();
        dt.Clear();
    }
Пример #3
0
    protected void btnbakinfo_Click(object sender, EventArgs e)
    {
        string ls_tip = "备份成功!";
        string SqlStr1 = System.Configuration.ConfigurationManager.AppSettings["HYOA_BAK"].ToString();
        System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(SqlStr1);
        con.Open();
        string ls_path = Server.MapPath("~/") + "bak/";
        string ls_dbname = "";
        string sql = "";
        try
        {
            string ls_today1 = System.DateTime.Now.ToString("yyyyMMdd");
            string ls_today2 = System.DateTime.Now.ToString("yyyyMMddHHmmss");
            //创建今天的文件夹
            string ls_filepath = ls_path + ls_today2 + "/";
            if (!System.IO.Directory.Exists(ls_filepath))
            {
                System.IO.Directory.CreateDirectory(ls_filepath);
            }

            ls_dbname = System.Configuration.ConfigurationManager.AppSettings["HYOA_BAK_BASE"].ToString();
            string ls_filename1 = ls_dbname + "_" + ls_today2 + ".bak' ";
            sql = "BACKUP DATABASE " + ls_dbname + " TO DISK ='" + ls_filepath + ls_filename1;
            System.Data.SqlClient.SqlCommand com1 = new System.Data.SqlClient.SqlCommand(sql, con);
            com1.ExecuteNonQuery();

            ls_dbname = System.Configuration.ConfigurationManager.AppSettings["HYOA_BAK_PRO"].ToString();
            string ls_filename2 = ls_dbname + "_" + ls_today2 + ".bak' ";
            sql = "BACKUP DATABASE " + ls_dbname + " TO DISK ='" + ls_filepath + ls_filename2;
            System.Data.SqlClient.SqlCommand com2 = new System.Data.SqlClient.SqlCommand(sql, con);
            com2.ExecuteNonQuery();

            ls_dbname = System.Configuration.ConfigurationManager.AppSettings["HYOA_BAK_USER"].ToString();
            string ls_filename3 = ls_dbname + "_" + ls_today2 + ".bak' ";
            sql = "BACKUP DATABASE " + ls_dbname + " TO DISK ='" + ls_filepath + ls_filename3;
            System.Data.SqlClient.SqlCommand com3 = new System.Data.SqlClient.SqlCommand(sql, con);
            com3.ExecuteNonQuery();

            //开始压缩文件夹,生成RAR压缩包
            //压缩文件
            PackFiles(ls_filepath.Substring(0, ls_filepath.Length - 1) + ".rar", ls_filepath);
            //删除源文件夹和文件
            System.IO.Directory.Delete(ls_filepath, true);

            //插入数据库记录
            HyoaClass.Hyoa_bak Hyoa_bak = new HyoaClass.Hyoa_bak();
            Hyoa_bak.DOCID = System.Guid.NewGuid().ToString();
            Hyoa_bak.hy_djrid = Session["hyuid"].ToString();
            Hyoa_bak.hy_djrname = Session["hyuname"].ToString();
            Hyoa_bak.hy_djrbmid = Session["hydeptid"].ToString();
            Hyoa_bak.hy_djrbmname = Session["hydeptname"].ToString();
            Hyoa_bak.hy_djsj = System.DateTime.Now.ToString();
            Hyoa_bak.hy_name = ls_today2;
            Hyoa_bak.Insert();
        }
        catch (Exception error)
        {
            ls_tip = "备份失败!";
            //Response.Write(error.Message);
        }
        finally
        {
            con.Close();
            Response.Write("<script>alert('" + ls_tip + "');window.location=window.location.href;</script>");
        }
    }