protected void Button5_Click(object sender, EventArgs e)
    {
        int delcount = 0;

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cb = (CheckBox)(GridView1.Rows[i].Cells[0].FindControl("CheckBox1"));
            if (cb.Checked)
            {
                DataCopy dc = new DataCopy();
                dc           = new DAL.DataCopyDAO().getCopyById(GridView1.DataKeys[i].Value.ToString());
                dc.CopyState = "已恢复";
                DAL.DataCopyDAO dd = new DAL.DataCopyDAO();
                dd.updateCopy(dc);
                new Warehouse.Tools.AddSysLog().addlog("1", "数据恢复", "修改");
                delcount++;
            }
        }
        if (delcount != 0)
        {
            Response.Write("<script>alert('成功恢复" + delcount + "条数据')</script>");
            refresh();
        }
        else
        {
            Response.Write("<script>alert('请选择您要恢复的数据(一次只能恢复一页的数据)')</script>");
        }
    }
Beispiel #2
0
    protected void Button9_Click(object sender, EventArgs e)
    {
        add.Visible    = false;
        search.Visible = true;

        DataCopy daco;

        if (TextBox5.Text.Trim() != "")
        {
            daco = new DAL.DataCopyDAO().getCopyByName(TextBox5.Text.Trim());
            if (dc == null)
            {
            }
            else
            {
                dc.Clear();
                dc.Add(daco);
            }
        }
        else
        {
            dc = new Warehouse.Controllor.DataRecovery_Controllor().getDataCopy();
        }

        //datacontract();
        GridView1.DataSource = dc;
        GridView1.DataBind();
        refreEmpty();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        bool success = new DAL.DataCopyDAO().deleteCopyById(GridView1.DataKeys[e.RowIndex].Value.ToString());

        if (success)
        {
            new Warehouse.Tools.AddSysLog().addlog("1", "数据恢复", "删除");
            ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true);
        }
        else
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true);
        }
        refresh();
    }
 protected void Button2_Click(object sender, EventArgs e)
 {
     if (TextBox1.Text.Trim() != "")
     {
         List <DataCopy> dcc = new List <DataCopy>();
         DataCopy        dc  = new DAL.DataCopyDAO().getCopyByUserId(TextBox1.Text.Trim());
         if (dc != null)
         {
             dcc.Add(dc);
         }
         GridView1.DataSource = dcc;
         GridView1.DataBind();
         refreEmpty();
     }
     else
     {
         GridView1.DataSource = dcs;
         GridView1.DataBind();
         refreEmpty();
     }
 }
Beispiel #5
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "reup")
        {
            int            xy  = Convert.ToInt32(e.CommandArgument);
            Model.Position pos = new DAL.PositionDAO().getPositionByNum(GridView1.Rows[xy].Cells[1].Text);
            add.Visible    = false;
            search.Visible = false;

            Button      btn = sender as Button;
            GridViewRow row = GridView1.Rows[xy];
            SysUser     s   = new DAL.SysUserDAO().getUserByNum(row.Cells[2].Text);
        }
        else if (e.CommandName == "deletee")
        {
            int    x        = Convert.ToInt32(e.CommandArgument);
            string dataid   = GridView1.Rows[x].Cells[1].Text;
            string dataname = GridView1.Rows[x].Cells[2].Text;
            bool   yy       = new DAL.DataCopyDAO().deleteCopyById(dataid);
            if (yy)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true);
                try
                {
                    File.Delete(@"~/DataPackage/" + dataname + ".mdf");
                }
                catch
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败,未找到文件!');", true);
                }
                dc = new Warehouse.Controllor.DataRecovery_Controllor().getDataCopy();
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true);
            }
        }
        refresh();
    }
Beispiel #6
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (!FileUpload1.HasFile)
        {
            Label2.Text = "请选择文件!";
        }
        else
        {
            if (TextBox1.Text.Trim() == "")
            {
                Label9.Text = "请输入数据包类型!";
            }
            else
            {
                string   filename = FileUpload1.PostedFile.FileName;
                FileInfo fi       = new FileInfo(filename);
                String   name     = fi.Name;
                string   type     = fi.Extension;
                if (FileUpload1.HasFile)
                {
                    string extension = System.IO.Path.GetExtension(filename);
                    if (extension.ToLower() != ".mdf")
                    {
                        //ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert('只允许mdf!');", true);
                        Label2.Text = "只允许mdf!";
                    }
                    else
                    {
                        if (new DAL.DataCopyDAO().HaveSameDataCopyName(Path.GetFileNameWithoutExtension(filename)))
                        {
                            //Response.Write("<script>alert('数据包名字重复,请更换数据包或更改数据包名字!')</script>");
                            Label2.Text = "数据包名字重复!";
                        }
                        else
                        {
                            DataCopy dc = new DataCopy();
                            //dc.DataName = TextBox1.Text.Trim();

                            dc.DataName     = Path.GetFileNameWithoutExtension(filename);
                            dc.CopyTime     = DateTime.Now;
                            dc.CopySize     = int.Parse(FileUpload1.PostedFile.ContentLength.ToString().Trim());
                            dc.CopyType     = TextBox1.Text.Trim();
                            dc.CopyState    = "未恢复";
                            dc.CopyLocation = Path.GetFullPath(FileUpload1.PostedFile.FileName);
                            int i = dc.CopyLocation.Length;
                            dc.SysUser = new DAL.SysUserDAO().getUserById("123");
                            bool success = new DAL.DataCopyDAO().addCopy(dc);
                            if (success)
                            {
                                new Warehouse.Tools.AddSysLog().addlog("1", "数据备份", "添加");

                                string savepath = Server.MapPath("~/DataPackage");
                                FileUpload1.PostedFile.SaveAs(savepath + "//" + name);
                                add.Visible    = false;
                                search.Visible = true;
                                clea();
                                refresh();
                                ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');", true);
                            }
                        }
                    }
                }
            }
        }
    }