public void RemoveDoc(CaseDoc doc)
 {
     using (var connection = new SqlConnection(_connectionString))
     {
         connection.Open();
         var prKey1 = new KeyValuePair<string, object>("案件编号", doc.案件编号);
         var prKey2 = new KeyValuePair<string, object>("文件名", doc.FileName);
         string command = string.Format("DELETE FROM [{0}] WHERE {1} = @{1} AND {2}=@{2}", CaseDocTableName,
                                        prKey1.Key, prKey2.Key);
         connection.ExecuteNonQuery(command);
     }
 }
 public void AddDoc(CaseDoc doc)
 {
     using (var connection = new SqlConnection(_connectionString))
     {
         connection.Open();
         var dictionary = new Dictionary<string, object>
                              {
                                  {"文件名", doc.FileName},
                                  {"创建人", doc.UploadUserName},
                                  {"创建日期", doc.UploadDateTime},
                                  {"文件路径", doc.FilePath},
                                  {"案件编号", doc.案件编号}
                              };
         connection.Insert(CaseDocTableName, dictionary);
     }
 }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (InputFile.HasFile)
            {
                IEnumerable<CaseDoc> docs = _caseDocManager.GetDocsOf(Session["SelectedCaseID"] as string);
                bool multiUploadTime = false;
                foreach (CaseDoc doc in docs)
                {
                    if (doc.FileName == InputFile.FileName)
                    {
                        lblErrorMessage.Text = "您多次上传了同一文件, 请删除现有文件再上传";
                        lblErrorMessage.Visible = true;
                        multiUploadTime = true;
                    }

                }

                if (!multiUploadTime)
                {
                    string saveFilePath = Path.Combine("~/App_Data/", Guid.NewGuid().ToString());

                    InputFile.MoveTo(Server.MapPath(saveFilePath), Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
                    var CurrentUser = (User)Session["User"];
                    var m_Doc = new CaseDoc
                    {
                        FileName = InputFile.FileName,
                        UploadDateTime = DateTime.Now,
                        UploadUserName = CurrentUser.UserName,
                        FilePath = saveFilePath,
                        案件编号 = Session["SelectedCaseID"] as string
                    };
                    var caseDocManager = _caseDocManager;
                    caseDocManager.AddDoc(m_Doc);
                    InputFile.Visible = false;
                    btnUpload.Visible = false;

                    var caseId = Session["SelectedCaseID"] as string;
                    listViewFiles.DataSource = _caseDocManager.GetDocsOf(caseId);
                    listViewFiles.DataBind();
                }
            }
        }