From d789099e9dc45e7fa3ee0eb73ee97f80b1963466 Mon Sep 17 00:00:00 2001
From: CB2-20200827ONU\Administrator <liaoxujun@qq.com>
Date: 星期五, 08 十月 2021 09:23:47 +0800
Subject: [PATCH] no message

---
 CY_ECommercePlatform/CY.WebForm/Pages/business/CorporateClientsUpLoadContract.aspx.cs |  436 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 380 insertions(+), 56 deletions(-)

diff --git a/CY_ECommercePlatform/CY.WebForm/Pages/business/CorporateClientsUpLoadContract.aspx.cs b/CY_ECommercePlatform/CY.WebForm/Pages/business/CorporateClientsUpLoadContract.aspx.cs
index 20e062c..6f2c9e8 100644
--- a/CY_ECommercePlatform/CY.WebForm/Pages/business/CorporateClientsUpLoadContract.aspx.cs
+++ b/CY_ECommercePlatform/CY.WebForm/Pages/business/CorporateClientsUpLoadContract.aspx.cs
@@ -39,69 +39,147 @@
 
             
             
-                if (Request["deleteKeyIds"] != null)
+                if (Request["deleteKeyIds"] != null&& Request["deleteKeyIds"]!="")
             {
-                //鍒犻櫎椤甸潰
-                string  keyid = Request["deleteKeyIds"].ToString();
-                Database DC = new Database();
-                string  sqlStr = string.Format(@"USE [ECTEST] SELECT[Keyid]      ,[CorporateClientsid]       ,[CorporateClientsName]       ,[FileName]       ,[PageCode]       ,[FilePath]       ,[Remark]     FROM[dbo].[OA_CorporateClientContract] where Keyid='{0}'ORDER BY PageCode ", keyid);
-
-                
-                try
+                if (Request["deleteKeyIds"] == "all")
                 {
-                    SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection);
-                    //SqlDataAdapter myDa = new SqlDataAdapter(myCmd);
-                    var a = myCmd.ExecuteReader();
-                    //myDa.Dispose();
-                    fileDataList = new List<OA_CorporateClientsContract>();
-                    OA_CorporateClientsContract Contract;
-                    while (a.Read())
-                    {   //娉ㄦ剰濡備綍灏嗘瘡娆¤鍙栧埌鐨勮褰曟坊鍔犲埌listbox1涓紙鍥犱负绗竴娆″仛鏃跺嚭閿欎簡锛屽樋鍢匡級
-                        Contract = new OA_CorporateClientsContract();
-                        Contract.Keyid = a.GetGuid(0);
-                        Contract.CorporateClientsid = a.GetGuid(1);
-                        Contract.CorporateClientsName = a.GetString(2);
-                        Contract.FileName = a.GetString(3);
-                        Contract.PageCode = a.GetInt32(4);
-                        Contract.FilePath = a.GetString(5);
-                        Contract.Remark = a.GetString(6);
+                    //鍒犻櫎璇存湁椤甸潰
+                    string keyid = Request["deleteKeyIds"].ToString();
+                    string pageID = Request["Keyid"];
+                    Database DC = new Database();
+                    string sqlStr = string.Format(@"USE [ECTEST] SELECT[Keyid]      ,[CorporateClientsid]       ,[CorporateClientsName]       ,[FileName]       ,[PageCode]       ,[FilePath]       ,[Remark]     FROM[dbo].[OA_CorporateClientContract] where CorporateClientsid='{0}'ORDER BY PageCode ", pageID);
 
 
-                        fileDataList.Add(Contract);
-                    }
-                    a.Close();     //鍏抽棴sqldatareader
-                    if (fileDataList.Count > 0)
-                    { FileInfo file = new FileInfo(Server.MapPath(fileDataList[0].FilePath));//鎸囧畾鏂囦欢璺緞
-                        if (file.Exists)//鍒ゆ柇鏂囦欢鏄惁瀛樺湪
-                        {
-                            file.Attributes = FileAttributes.Normal;//灏嗘枃浠跺睘鎬ц缃负鏅��,姣旀柟璇村彧璇绘枃浠惰缃负鏅��
-                            file.Delete();//鍒犻櫎鏂囦欢
+                    try
+                    {
+                        SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection);
+                        //SqlDataAdapter myDa = new SqlDataAdapter(myCmd);
+                        var a = myCmd.ExecuteReader();
+                        //myDa.Dispose();
+                        fileDataList = new List<OA_CorporateClientsContract>();
+                        OA_CorporateClientsContract Contract;
+                        while (a.Read())
+                        {   //娉ㄦ剰濡備綍灏嗘瘡娆¤鍙栧埌鐨勮褰曟坊鍔犲埌listbox1涓紙鍥犱负绗竴娆″仛鏃跺嚭閿欎簡锛屽樋鍢匡級
+                            Contract = new OA_CorporateClientsContract();
+                            Contract.Keyid = a.GetGuid(0);
+                            Contract.CorporateClientsid = a.GetGuid(1);
+                            Contract.CorporateClientsName = a.GetString(2);
+                            Contract.FileName = a.GetString(3);
+                            Contract.PageCode = a.GetInt32(4);
+                            Contract.FilePath = a.GetString(5);
+                            Contract.Remark = a.GetString(6);
+
+
+                            fileDataList.Add(Contract);
                         }
+                        a.Close();     //鍏抽棴sqldatareader
+                        if (fileDataList.Count > 0)
+                        {
+                            foreach (var item in fileDataList)
+                            {
+                                FileInfo file = new FileInfo(Server.MapPath(item.FilePath));//鎸囧畾鏂囦欢璺緞
+                                if (file.Exists)//鍒ゆ柇鏂囦欢鏄惁瀛樺湪
+                                {
+                                    file.Attributes = FileAttributes.Normal;//灏嗘枃浠跺睘鎬ц缃负鏅��,姣旀柟璇村彧璇绘枃浠惰缃负鏅��
+                                    file.Delete();//鍒犻櫎鏂囦欢
+                                }
+                                sqlStr = string.Format(@"USE [ECTEST]DELETE FROM [dbo].[OA_CorporateClientContract] where Keyid='{0}'", item.Keyid);
+                                myCmd = new SqlCommand(sqlStr, DC.Connection);
+                                myCmd.ExecuteNonQuery();
+                                myCmd.Dispose();
+                            }
+                          
+                        }
+                    
+                        JavaScript.MessageBox("鍒犻櫎鎴愬姛", this);
+                        //  Response.Redirect("/Pages/business/CorporateClientsUpLoadContract.aspx");
                     }
-                    sqlStr = string.Format(@"USE [ECTEST]DELETE FROM [dbo].[OA_CorporateClientContract] where Keyid='{0}'", keyid);
-                    myCmd = new SqlCommand(sqlStr, DC.Connection);
-                    myCmd.ExecuteNonQuery();
-                    JavaScript.MessageBox("鍒犻櫎鎴愬姛",this);
-                  //  Response.Redirect("/Pages/business/CorporateClientsUpLoadContract.aspx");
-                }
-                catch (Exception ee)
-                {
-                    new Log4NetAdapter().Log("鏌ユ壘鍚堝悓鍑洪敊锛�" + ee.Message);
-                    JavaScript.MessageBox("鍒犻櫎澶辫触", this);
+                    catch (Exception ee)
+                    {
+                        new Log4NetAdapter().Log("鏌ユ壘鍚堝悓鍑洪敊锛�" + ee.Message);
+                        JavaScript.MessageBox("鍒犻櫎澶辫触", this);
+
+                    }
+                    finally
+                    {
+                        if (DC.Connection.State != System.Data.ConnectionState.Closed)
+                            DC.Connection.Close();
+                    }
+
+
 
                 }
-                finally
+                else
                 {
-                    if (DC.Connection.State != System.Data.ConnectionState.Closed)
-                        DC.Connection.Close();
+                    //鍒犻櫎椤甸潰
+                    string keyid = Request["deleteKeyIds"].ToString();
+                    Database DC = new Database();
+                    string sqlStr = string.Format(@"USE [ECTEST] SELECT[Keyid]      ,[CorporateClientsid]       ,[CorporateClientsName]       ,[FileName]       ,[PageCode]       ,[FilePath]       ,[Remark]     FROM[dbo].[OA_CorporateClientContract] where Keyid='{0}'ORDER BY PageCode ", keyid);
+
+
+                    try
+                    {
+                        SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection);
+                        //SqlDataAdapter myDa = new SqlDataAdapter(myCmd);
+                        var a = myCmd.ExecuteReader();
+                        //myDa.Dispose();
+                        fileDataList = new List<OA_CorporateClientsContract>();
+                        OA_CorporateClientsContract Contract;
+                        while (a.Read())
+                        {   //娉ㄦ剰濡備綍灏嗘瘡娆¤鍙栧埌鐨勮褰曟坊鍔犲埌listbox1涓紙鍥犱负绗竴娆″仛鏃跺嚭閿欎簡锛屽樋鍢匡級
+                            Contract = new OA_CorporateClientsContract();
+                            Contract.Keyid = a.GetGuid(0);
+                            Contract.CorporateClientsid = a.GetGuid(1);
+                            Contract.CorporateClientsName = a.GetString(2);
+                            Contract.FileName = a.GetString(3);
+                            Contract.PageCode = a.GetInt32(4);
+                            Contract.FilePath = a.GetString(5);
+                            Contract.Remark = a.GetString(6);
+
+
+                            fileDataList.Add(Contract);
+                        }
+                        a.Close();     //鍏抽棴sqldatareader
+                        if (fileDataList.Count > 0)
+                        {
+                            FileInfo file = new FileInfo(Server.MapPath(fileDataList[0].FilePath));//鎸囧畾鏂囦欢璺緞
+                            if (file.Exists)//鍒ゆ柇鏂囦欢鏄惁瀛樺湪
+                            {
+                                file.Attributes = FileAttributes.Normal;//灏嗘枃浠跺睘鎬ц缃负鏅��,姣旀柟璇村彧璇绘枃浠惰缃负鏅��
+                                file.Delete();//鍒犻櫎鏂囦欢
+                            }
+                        }
+                        sqlStr = string.Format(@"USE [ECTEST]DELETE FROM [dbo].[OA_CorporateClientContract] where Keyid='{0}'", keyid);
+                        myCmd = new SqlCommand(sqlStr, DC.Connection);
+                        myCmd.ExecuteNonQuery();
+                        JavaScript.MessageBox("鍒犻櫎鎴愬姛", this);
+                        //  Response.Redirect("/Pages/business/CorporateClientsUpLoadContract.aspx");
+                    }
+                    catch (Exception ee)
+                    {
+                        new Log4NetAdapter().Log("鏌ユ壘鍚堝悓鍑洪敊锛�" + ee.Message);
+                        JavaScript.MessageBox("鍒犻櫎澶辫触", this);
+
+                    }
+                    finally
+                    {
+                        if (DC.Connection.State != System.Data.ConnectionState.Closed)
+                            DC.Connection.Close();
+                    }
                 }
+
+                Response.AppendHeader("deleteKeyIds", "");
 
             }
+              
             if (!IsPostBack)
                 BindList();
-            
+           
         }
-
+        public Guid GetKeyid()
+        {
+            return Request["Keyid"].ToGuid2();
+        }
         //缁戝畾鍒楄〃
         private void BindList()
         {
@@ -176,15 +254,212 @@
             BindList();
         }
 
+        protected void btn_Submit_Click_multi(object sender, EventArgs e)
+        {
+
+            var files = Request.Files;
+            //if (files.Count <= 0)
+            //    return;
+            HttpPostedFile postedFile;
+            List<HttpPostedFile> fileList = new List<HttpPostedFile>();
+
+
+            for (int i=0;i< files.Count;i++)
+            {
+              
+                if (files.Keys[i]=="file2")
+                {
+                    postedFile = files[i];
+                    if (postedFile.ContentLength == 0)
+                        continue;
+                    fileList.Add(postedFile);
+                }
+                
+            }
+       
+            upLoadContractFile uploadContract = null;
+            OA_CorporateClientsContract contract = null;
+            Guid? g = null;
+            foreach (var item in fileList)
+            {
+
+                int page = 0;
+                try
+                {
+                    page = pagecount(item);
+                }
+                catch (Exception)
+                {
+
+                    continue;
+                }
+                try
+                {
+                    g = GetContractFileID(page);
+                }
+                catch (Exception)
+                {
+
+                    continue;
+                }
+               
+                uploadContract = new upLoadContractFile();
+                if (g != null)
+                {
+
+                    try
+                    {
+                        uploadContract.SavAndUpDataContractFile(item, CountractFileKeiId: g);
+
+                        JavaScript.MessageBox( "涓婁紶鏂囦欢鎴愬姛", this);
+                        //JavaScript.RefreshSelf(this);
+                        //JavaScript.RefreshOpener(this);
+                       
+                    }
+                    catch (Exception)
+                    {
+                        JavaScript.MessageBox("涓婁紶鏂囦欢澶辫触", this);
+                        // JavaScript.RefreshSelf(this);
+                        //JavaScript.RefreshOpener(this);
+                      
+
+                    }
+
+                    continue;
+                }
+
+                //鏂板缓璧颁笅闈㈤〉闈�
+                 contract = new OA_CorporateClientsContract
+                {
+                    CorporateClientsid = Request["Keyid"].ToGuid2(),
+                    FileName = System.IO.Path.GetFileName(item.FileName),
+                    PageCode = page,
+                    Creater = CurrentUser.TrueMemberId,
+
+                };
+
+
+
+                try
+                {
+                    uploadContract.SavAndUpDataContractFile(item, contract);
+
+                    JavaScript.MessageBox("涓婁紶鏂囦欢鎴愬姛", this);
+                   
+                   
+                }
+                catch (Exception)
+                {
+                    JavaScript.MessageBox( "涓婁紶鏂囦欢澶辫触", this);
+                  
+
+                }
+
+
+            }
+            BindList();
+               
+
+
+           
+
+        }
+        protected void btn_Submit_Click_DELLALL(object sender, EventArgs e)
+        {
+
+          
+            string pageID = Request["Keyid"];
+            Database DC = new Database();
+            string sqlStr = string.Format(@"USE [ECTEST] SELECT[Keyid]      ,[CorporateClientsid]       ,[CorporateClientsName]       ,[FileName]       ,[PageCode]       ,[FilePath]       ,[Remark]     FROM[dbo].[OA_CorporateClientContract] where CorporateClientsid='{0}'ORDER BY PageCode ", pageID);
+
+
+            try
+            {
+                SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection);
+                //SqlDataAdapter myDa = new SqlDataAdapter(myCmd);
+                var a = myCmd.ExecuteReader();
+                //myDa.Dispose();
+                fileDataList = new List<OA_CorporateClientsContract>();
+                OA_CorporateClientsContract Contract;
+                while (a.Read())
+                {   //娉ㄦ剰濡備綍灏嗘瘡娆¤鍙栧埌鐨勮褰曟坊鍔犲埌listbox1涓紙鍥犱负绗竴娆″仛鏃跺嚭閿欎簡锛屽樋鍢匡級
+                    Contract = new OA_CorporateClientsContract();
+                    Contract.Keyid = a.GetGuid(0);
+                    Contract.CorporateClientsid = a.GetGuid(1);
+                    Contract.CorporateClientsName = a.GetString(2);
+                    Contract.FileName = a.GetString(3);
+                    Contract.PageCode = a.GetInt32(4);
+                    Contract.FilePath = a.GetString(5);
+                    Contract.Remark = a.GetString(6);
+
+
+                    fileDataList.Add(Contract);
+                }
+                a.Close();     //鍏抽棴sqldatareader
+                if (fileDataList.Count > 0)
+                {
+                    foreach (var item in fileDataList)
+                    {
+                        FileInfo file = new FileInfo(Server.MapPath(item.FilePath));//鎸囧畾鏂囦欢璺緞
+                        if (file.Exists)//鍒ゆ柇鏂囦欢鏄惁瀛樺湪
+                        {
+                            file.Attributes = FileAttributes.Normal;//灏嗘枃浠跺睘鎬ц缃负鏅��,姣旀柟璇村彧璇绘枃浠惰缃负鏅��
+                            file.Delete();//鍒犻櫎鏂囦欢
+                        }
+                        sqlStr = string.Format(@"USE [ECTEST]DELETE FROM [dbo].[OA_CorporateClientContract] where Keyid='{0}'", item.Keyid);
+                        myCmd = new SqlCommand(sqlStr, DC.Connection);
+                        myCmd.ExecuteNonQuery();
+                        myCmd.Dispose();
+                    }
+
+                }
+
+                JavaScript.MessageBox("鍒犻櫎鎴愬姛", this);
+                //  Response.Redirect("/Pages/business/CorporateClientsUpLoadContract.aspx");
+            }
+            catch (Exception ee)
+            {
+                new Log4NetAdapter().Log("鏌ユ壘鍚堝悓鍑洪敊锛�" + ee.Message);
+                JavaScript.MessageBox("鍒犻櫎澶辫触", this);
+
+            }
+            finally
+            {
+                if (DC.Connection.State != System.Data.ConnectionState.Closed)
+                    DC.Connection.Close();
+            }
+
+            BindList();
+        }
         protected void btn_Submit_Click(object sender, EventArgs e)
         {
-        
+
             var files = Request.Files;
             if (files.Count <= 0)
                 return;
-            HttpPostedFile postedFile = files[0];           
-            if (postedFile.ContentLength == 0)
-                return;
+            //    return;
+            HttpPostedFile postedFile=null;
+         
+
+
+            for (int i = 0; i < files.Count; i++)
+            {
+
+                if (files.Keys[i] == "filesel")
+                {
+                    postedFile = files[i];
+                    if (postedFile.ContentLength == 0)
+                    {
+                        return;
+                    }
+                       
+                    break;
+                }
+
+            }
+       
+            
+
             Guid? g = GetContractFileID();
             upLoadContractFile uploadContract = new upLoadContractFile();
             if (g != null)
@@ -206,6 +481,7 @@
                     BindList();
 
                 }
+              
                 return;
             }
           
@@ -238,7 +514,7 @@
                 BindList();
 
             }
-            
+        
 
             //    CY.WebForm.cs.UploadCS.Upload(System.Web.HttpContext.Current.Request.MapPath("contractImgs/") + Guid.NewGuid().ToString() + fileName)
 
@@ -266,6 +542,7 @@
 
             //    }
             //}
+
         }
 
         public void  test()
@@ -274,14 +551,42 @@
         }
         
         /// <summary>
-        /// 鑾峰彇褰撳墠椤甸潰鐨刧uiid锛屽垽鏂槸鍚︽椂鏂板缓椤甸潰
+        /// 鑾峰彇褰撳墠椤甸潰鐨刧uiid锛屽垽鏂槸鍚︽槸鏂板缓椤甸潰  濡傛灉娌℃湁锛屽垯鑾峰彇椤甸潰鐨勯〉鐮�
         /// </summary>
         /// <returns></returns>
-        public Guid? GetContractFileID()
+        public Guid? GetContractFileID(int?  Pagecode=null)
         {
             Guid Keyid = Request["Keyid"].ToGuid2();
             Database DC = new Database();
-            string sqlStr = string.Format(@"USE [ECTEST] SELECT[Keyid] FROM[dbo].[OA_CorporateClientContract] where CorporateClientsid='{0}' and [PageCode]='{1}' ", Keyid, Convert.ToInt32(this.TextPage.Value));
+            if (Pagecode != null)
+            {
+                try
+                {
+                    Pagecode = Convert.ToInt32(Pagecode);
+                }
+                catch (Exception)
+                {
+
+                    return null;
+                }
+            }
+            else
+            {
+                try
+                {
+                    Pagecode = Convert.ToInt32(this.TextPage.Value);
+                }
+                catch (Exception)
+                {
+
+                    return null;
+                }
+             
+            }
+             
+                   
+                    
+            string sqlStr = string.Format(@"USE [ECTEST] SELECT[Keyid] FROM[dbo].[OA_CorporateClientContract] where CorporateClientsid='{0}' and [PageCode]='{1}' ", Keyid, Pagecode);
 
             try
             {
@@ -315,6 +620,25 @@
 
         }
 
+        public int pagecount(HttpPostedFile file)
+        {
+            try
+            {
+                string filepagecode = System.IO.Path.GetFileNameWithoutExtension(file.FileName);
+                return Convert.ToInt32(filepagecode);
+
+            }
+            catch (Exception)
+            {
+
+                JavaScript.MessageBox(file.FileName + "鏂囦欢涓婁紶澶辫触锛屽懡鍚嶈鍒欏啿绐�", this);
+                throw;
+            }
+           
+
+        }
+
+
 
 
     }

--
Gitblit v1.9.1