Exemplo n.º 1
0
        private void Btn_save_Command(object sender, CommandEventArgs e)
        {
            TextBox box = (TextBox)Page.FindControl("editinput");

            Sqlitehelper.SetConnectionString(MapPath("~/webword.db"), "");
            DataTable table = Sqlitehelper.ExecuteQuery("select user_name,(user_name||'\\'||fileinfo_name||'.doc') as path from user inner join fileinfo on user_id=fileinfo_userid where fileinfo_id=" + e.CommandArgument);

            string opath = MapPath("~/wordsave/") + table.Rows[0]["path"].ToString();

            if (File.Exists(opath))
            {
                string npath0 = MapPath("~/wordsave/") + table.Rows[0]["user_name"].ToString() + "\\" + box.Text + ".doc";
                File.Move(opath, npath0);
            }
            else
            {
                string npath = MapPath("~/wordsave/") + table.Rows[0]["user_name"].ToString() + "\\" + box.Text + ".txt";
                opath = opath.Replace(".doc", ".txt");
                File.Move(opath, npath);
            }



            Sqlitehelper.ExecuteNonQuery("update fileinfo set fileinfo_name='" + box.Text + "' where fileinfo_id=" + e.CommandArgument);
            Response.Redirect("filelist.aspx");
        }
Exemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Sqlitehelper.SetConnectionString(MapPath("~/webword.db"), "");
            string password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox3.Text, "MD5");

            Sqlitehelper.ExecuteNonQuery($"update user set user_password='******' where user_name='{Session["resetinfo"].ToString()}'");
            Session["resetinfo"] = null;
            Response.Redirect("~/logic.aspx");
        }
Exemplo n.º 3
0
        private void Btn_rdelete_Command(object sender, CommandEventArgs e)
        {
            Sqlitehelper.SetConnectionString(MapPath("~/webword.db"), "");
            DataTable table = Sqlitehelper.ExecuteQuery("select user_name,(user_name||'\\'||fileinfo_name||'.doc') as path from user inner join fileinfo on user_id=fileinfo_userid where fileinfo_id=" + e.CommandArgument);
            string    path  = MapPath("~/wordsave/") + table.Rows[0]["path"].ToString();

            if (!File.Exists(path))
            {
                path = path.Replace(".doc", ".txt");
            }
            File.Delete(path);
            Sqlitehelper.ExecuteNonQuery("delete from fileinfo where fileinfo_id=" + e.CommandArgument);

            Response.Redirect(Request.RawUrl);
        }
Exemplo n.º 4
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            Sqlitehelper.SetConnectionString(MapPath("~/webword.db"), "");
            DataTable table  = Sqlitehelper.ExecuteQuery("select * from fileinfo");
            int       i      = table.Rows.Count + 1;
            DataTable table2 = Sqlitehelper.ExecuteQuery("select user_id from user where user_name='" + Session["uid"].ToString() + "'");

            try
            {
                Sqlitehelper.ExecuteNonQuery("insert into fileinfo values(" + i + ",'" + TextBox1.Text + "'," + table2.Rows[0]["user_id"] + " ,1,0)");
            }
            catch
            {
                Response.Write("<script>alert('文件名已经存在!')</script>");
            }

            if (op.Text == "")
            {
                string text = "<!DOCTYPE html>" + CKEditorControl1.Text;
                try
                {
                    Directory.CreateDirectory(MapPath("~/wordsave/") + Session["uid"].ToString());
                    string path = MapPath("~/wordsave/") + Session["uid"].ToString() + "\\" + TextBox1.Text + ".txt";
                    File.WriteAllText(path, text);
                }
                catch
                {
                }
            }
            else
            {
                try
                {
                    Directory.CreateDirectory(MapPath("~/wordsave/") + Session["uid"].ToString());
                    string path = MapPath("~/wordsave/") + Session["uid"].ToString() + "\\" + TextBox1.Text + ".doc";
                    if (FileUpload1.HasFile)
                    {
                        FileUpload1.SaveAs(path);
                    }
                }
                catch
                {
                }
            }
            TextBox1.Text = "";
            op.Text       = "";
            Response.Redirect(Request.RawUrl);
        }
Exemplo n.º 5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Sqlitehelper.SetConnectionString(MapPath("~/webword.db"), "");
            DataTable table = Sqlitehelper.ExecuteQuery("select * from user where user_name='" + TextBox1.Text + "'");

            if (table.Rows.Count > 0)
            {
                TextBox1.Focus();
                Response.Write("<script>alert('用户名已经存在!')</script>");
            }
            else
            {
                DataTable table1   = Sqlitehelper.ExecuteQuery("select * from user");
                int       i        = table1.Rows.Count + 1;
                string    password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text, "MD5");
                Sqlitehelper.ExecuteNonQuery("insert into user values(" + i + ",'" + TextBox1.Text + "','" + password + "',1,'" + TextBox3.Text + "'," + (DropDownList1.SelectedIndex + 1).ToString() + ")");
                Response.Write("<script>alert('注册成功!');location.href='logic.aspx';</script>");
            }
        }
Exemplo n.º 6
0
 private void Btn_recov_Command(object sender, CommandEventArgs e)
 {
     Sqlitehelper.SetConnectionString(MapPath("~/webword.db"), "");
     Sqlitehelper.ExecuteNonQuery("update fileinfo set fileinfo_delete=0 where fileinfo_id=" + e.CommandArgument);
     Response.Redirect(Request.RawUrl);
 }
Exemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["model"] == null)
     {
         if (Session["uid"] != null)
         {
             Panel  panel, subpel, namepel, clpel;
             Label  label1;
             Button btn_recov, btn_rdelete;
             Sqlitehelper.SetConnectionString(MapPath("~/webword.db"), "");
             string    sql   = "select fileinfo_name,fileinfo_id from user inner join fileinfo on user_id=fileinfo_userid where fileinfo_delete=1 and user_name='" + Session["uid"].ToString() + "'";
             DataTable table = Sqlitehelper.ExecuteQuery(sql);
             foreach (DataRow row in table.Rows)
             {
                 panel            = new Panel();
                 panel.CssClass   = "fileitem";
                 label1           = new Label();
                 subpel           = new Panel();
                 clpel            = new Panel();
                 clpel.CssClass   = "clr";
                 subpel.CssClass  = "subpel";
                 namepel          = new Panel();
                 namepel.CssClass = "namepel";
                 label1.Text      = row["fileinfo_name"].ToString();
                 namepel.Controls.Add(label1);
                 btn_recov                   = new Button();
                 btn_recov.Text              = "还原";
                 btn_recov.CommandArgument   = row["fileinfo_id"].ToString();
                 btn_recov.Command          += new CommandEventHandler(Btn_recov_Command);
                 btn_rdelete                 = new Button();
                 btn_rdelete.Text            = "删除";
                 btn_rdelete.CommandArgument = row["fileinfo_id"].ToString();
                 btn_rdelete.Command        += new CommandEventHandler(Btn_rdelete_Command);
                 subpel.Controls.Add(btn_recov);
                 subpel.Controls.Add(btn_rdelete);
                 panel.Controls.Add(namepel);
                 panel.Controls.Add(subpel);
                 panel.Controls.Add(clpel);
                 div_hszitem.Controls.Add(panel);
             }
         }
     }
     else
     {
         if (Session["uid"] != null)
         {
             Sqlitehelper.SetConnectionString(MapPath("~/webword.db"), "");
             DataTable table = Sqlitehelper.ExecuteQuery("select (user_name||'\\'||fileinfo_name||'.doc') as path from user inner join fileinfo on user_id=fileinfo_userid where fileinfo_delete=1");
             foreach (DataRow row in table.Rows)
             {
                 string path = MapPath("~/wordsave/") + row["path"].ToString();
                 if (File.Exists(path))
                 {
                     File.Delete(path);
                 }
                 else
                 {
                     path = path.Replace(".doc", ".txt");
                     File.Delete(path);
                 }
             }
             Sqlitehelper.SetConnectionString(MapPath("~/webword.db"), "");
             Sqlitehelper.ExecuteNonQuery("delete from fileinfo where fileinfo_delete=1");
         }
     }
 }