Exemplo n.º 1
0
    protected void btndelinfo_sq_Click(object sender, EventArgs e)
    {
        HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
        String[] v_uids = this.txtuids.Value.Split(',');
        string ls_filepath = "";
        if (this.txttableid.Value == "TableVODfwxy" || this.txttableid.Value == "Tableffpdfwht" || this.txttableid.Value == "Tablejdhazfwht" ||
            this.txttableid.Value == "Tablesyyhfwxy" || this.txttableid.Value == "TableDVBazfwdght" || this.txttableid.Value == "TableDVBazfwdght" ||
            this.txttableid.Value == "Tablejwdsjsxy" || this.txttableid.Value == "Tablejwdscsxy" || this.txttableid.Value == "Tablekdjrht" ||
             this.txttableid.Value == "Tablesjcsfwht" || this.txttableid.Value == "Tablesjgdcsfwht" || this.txttableid.Value == "Tablesjtxyyhzxy" ||
              this.txttableid.Value == "Tablezdyht" ||
              this.txttableid.Value == "Tablesyyhfwxy_new" || this.txttableid.Value == "Tableszdsywfwht_new" || this.txttableid.Value == "Tablejwdscsxy_new"
              || this.txttableid.Value == "Tablejwdsjm" || this.txttableid.Value == "Tablesjcsfwht_new" || this.txttableid.Value == "Tablekdjrht_new" ||
              this.txttableid.Value == "Tablesjgdcsfwht_new" || this.txttableid.Value == "Tablesjtxyyhzxy_new" || this.txttableid.Value == "Tableqtht"
            || this.txttableid.Value == "Tablegxhzhht")
        {
            for (var i = 0; i < v_uids.Length; i++)
            {
                if (v_uids[i] != "")
                {
                    string sql = "update hyc_" + txttableid.Value + " set hy_iftx='1',hy_zhtxsj='" + System.DateTime.Now.ToString() + "' where DOCID='" + v_uids[i] + "'";
                    Hyoa_global.ExcuteSQL(sql);

                    //删除文档时将待办事宜删除start
                    HyoaClass.Hyoa_dbsy Hyoa_dbsy = new HyoaClass.Hyoa_dbsy();
                    Hyoa_dbsy.DOCID = v_uids[i];
                    Hyoa_dbsy.Deletebydocid(v_uids[i]);
                    //删除文档时将待办事宜删除end

                    //删除文档对应的hyp_flowhistoryinfo_cl hyp_flowhistoryinfo_cy start   add by xf 20121016
                    HyoaClass.Hyoa_flowhistoryinfo_cl Hyoa_flowhistoryinfo_cl = new HyoaClass.Hyoa_flowhistoryinfo_cl();
                    Hyoa_flowhistoryinfo_cl.DOCID = v_uids[i];
                    Hyoa_flowhistoryinfo_cl.DeleteByDOCID();
                    HyoaClass.Hyoa_flowhistoryinfo_cy Hyoa_flowhistoryinfo_cy = new HyoaClass.Hyoa_flowhistoryinfo_cy();
                    Hyoa_flowhistoryinfo_cy.DOCID = v_uids[i];
                    Hyoa_flowhistoryinfo_cy.DeleteByDOCID();
                    //删除文档对应的hyp_flowhistoryinfo_cl hyp_flowhistoryinfo_cy end

                    ////删的时候将附件也删除start
                    //HyoaClass.Hyoa_fileatt Hyoa_fileatt = new HyoaClass.Hyoa_fileatt();
                    //DataTable dtfileatt = Hyoa_fileatt.GetfileattByFatherid(v_uids[i]);
                    //if (dtfileatt.Rows.Count > 0)
                    //{
                    //    for (int k = 0; k < dtfileatt.Rows.Count; k++)
                    //    {
                    //        ls_filepath = Server.MapPath("~/") + dtfileatt.Rows[k]["hy_filepath"].ToString();
                    //        if (File.Exists(ls_filepath))
                    //        {
                    //            System.IO.File.Delete(ls_filepath);
                    //        }
                    //        Hyoa_fileatt.ID = dtfileatt.Rows[k]["ID"].ToString();
                    //        Hyoa_fileatt.Delete();
                    //    }
                    //}
                    //删的时候将附件也删除end

                    //生成删除日志 start
                    string ls_oppcontent = "表名:hyc_" + txttableid.Value + ";文档ID:" + v_uids[i] + "被删除。";
                    HyoaClass.Hyoa_log Hyoa_log = new HyoaClass.Hyoa_log();
                    Hyoa_log.ID = System.Guid.NewGuid().ToString();
                    Hyoa_log.hy_createtime = System.DateTime.Now.ToString();
                    string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    if (userip == null || userip == "")
                    {
                        userip = Request.ServerVariables["REMOTE_ADDR"];
                    }
                    Hyoa_log.hy_oppip = userip;
                    Hyoa_log.hy_opptype = "删除";
                    Hyoa_log.hy_oppcontent = ls_oppcontent;
                    Hyoa_log.hy_oppuserid = this.Session["hyuid"].ToString();
                    Hyoa_log.hy_oppusername = this.Session["hyuname"].ToString();
                    Hyoa_log.Insert();
                    //生成删除日志end

                }
            }
            this.txtuids.Value = "";
            //DataPlay(1);
            DataPlay(System.Int32.Parse(this.curpage.Text));
        }
        else
        {
            for (var i = 0; i < v_uids.Length; i++)
            {
                if (v_uids[i] != "")
                {
                    //判断是否是当前用户的文档
                    string sql = "select * from hyc_" + txttableid.Value + " where DOCID='" + v_uids[i] + "'";
                    DataTable dt_judge = Hyoa_global.GetDataTable(sql);
                    if (dt_judge.Rows.Count > 0)
                    {
                        if (dt_judge.Rows[0]["hy_djrid"].ToString() == Session["hyuid"].ToString())
                        {
                            sql = "delete from hyc_" + txttableid.Value + " where DOCID='" + v_uids[i] + "'";
                            Hyoa_global.ExcuteSQL(sql);

                            //删除文档时将待办事宜删除start
                            HyoaClass.Hyoa_dbsy Hyoa_dbsy = new HyoaClass.Hyoa_dbsy();
                            Hyoa_dbsy.DOCID = v_uids[i];
                            Hyoa_dbsy.Deletebydocid(v_uids[i]);
                            //删除文档时将待办事宜删除end

                            //删除文档对应的hyp_flowhistoryinfo_cl hyp_flowhistoryinfo_cy start   add by xf 20121016
                            HyoaClass.Hyoa_flowhistoryinfo_cl Hyoa_flowhistoryinfo_cl = new HyoaClass.Hyoa_flowhistoryinfo_cl();
                            Hyoa_flowhistoryinfo_cl.DOCID = v_uids[i];
                            Hyoa_flowhistoryinfo_cl.DeleteByDOCID();
                            HyoaClass.Hyoa_flowhistoryinfo_cy Hyoa_flowhistoryinfo_cy = new HyoaClass.Hyoa_flowhistoryinfo_cy();
                            Hyoa_flowhistoryinfo_cy.DOCID = v_uids[i];
                            Hyoa_flowhistoryinfo_cy.DeleteByDOCID();
                            //删除文档对应的hyp_flowhistoryinfo_cl hyp_flowhistoryinfo_cy end

                            //删的时候将附件也删除start
                            HyoaClass.Hyoa_fileatt Hyoa_fileatt = new HyoaClass.Hyoa_fileatt();
                            DataTable dtfileatt = Hyoa_fileatt.GetfileattByFatherid(v_uids[i]);
                            if (dtfileatt.Rows.Count > 0)
                            {
                                for (int k = 0; k < dtfileatt.Rows.Count; k++)
                                {
                                    ls_filepath = Server.MapPath("~/") + dtfileatt.Rows[k]["hy_filepath"].ToString();
                                    if (File.Exists(ls_filepath))
                                    {
                                        System.IO.File.Delete(ls_filepath);
                                    }
                                    Hyoa_fileatt.ID = dtfileatt.Rows[k]["ID"].ToString();
                                    Hyoa_fileatt.Delete();
                                }
                            }
                            //删的时候将附件也删除end

                            //生成删除日志 start
                            string ls_oppcontent = "表名:hyc_" + txttableid.Value + ";文档ID:" + v_uids[i] + "被删除。";
                            HyoaClass.Hyoa_log Hyoa_log = new HyoaClass.Hyoa_log();
                            Hyoa_log.ID = System.Guid.NewGuid().ToString();
                            Hyoa_log.hy_createtime = System.DateTime.Now.ToString();
                            string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                            if (userip == null || userip == "")
                            {
                                userip = Request.ServerVariables["REMOTE_ADDR"];
                            }
                            Hyoa_log.hy_oppip = userip;
                            Hyoa_log.hy_opptype = "删除";
                            Hyoa_log.hy_oppcontent = ls_oppcontent;
                            Hyoa_log.hy_oppuserid = this.Session["hyuid"].ToString();
                            Hyoa_log.hy_oppusername = this.Session["hyuname"].ToString();
                            Hyoa_log.Insert();
                            //生成删除日志end
                        }
                    }
                }
            }
            this.txtuids.Value = "";
            //DataPlay(1);
            DataPlay(System.Int32.Parse(this.curpage.Text));
        }
    }