| | |
| | | |
| | | |
| | | |
| | | 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() |
| | | { |
| | |
| | | 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) |
| | |
| | | BindList(); |
| | | |
| | | } |
| | | |
| | | return; |
| | | } |
| | | |
| | |
| | | BindList(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // CY.WebForm.cs.UploadCS.Upload(System.Web.HttpContext.Current.Request.MapPath("contractImgs/") + Guid.NewGuid().ToString() + fileName) |
| | | |
| | |
| | | |
| | | // } |
| | | //} |
| | | |
| | | } |
| | | |
| | | public void test() |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前页面的guiid,判断是否时新建页面 |
| | | /// 获取当前页面的guiid,判断是否是新建页面 如果没有,则获取页面的页码 |
| | | /// </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 |
| | | { |
| | |
| | | |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |