protected void OnButtonSaveClick(object sender, EventArgs e)
    {
        radUploadSingle.AllowedFileExtensions = WebConfig.AllowFileExtension;
        radUploadSingle.MaxFileSize = WebConfig.MaxFileSize;

        CompanyDocumentRepository docRepo = new CompanyDocumentRepository();
        //edit
        if (!string.IsNullOrEmpty(Request.QueryString["docID"]))
        {
            int docID = Int32.Parse(Request.QueryString["docID"]);
            CompanyDocument doc = docRepo.FindOne(new CompanyDocument(docID));
            if (doc != null)
            {
                if (!string.IsNullOrEmpty(txtDocumentLegend.Text.Trim()))
                    doc.DocumentLegend = txtDocumentLegend.Text.Trim();
                if (radUploadSingle.UploadedFiles.Count > 0)
                {
                    string fileName = DateTime.Now.ToString("ddMMyyyyHHmmss") + "_" + radUploadSingle.UploadedFiles[0].GetName();

                    doc.DocumentName = fileName;//radUploadSingle.UploadedFiles[0].GetName();
                    doc.ContentType = radUploadSingle.UploadedFiles[0].ContentType;

                    doc.AbsoluteURL = WebConfig.CompanyDocumentAbsolutePath + fileName;
                    radUploadSingle.UploadedFiles[0].SaveAs(WebConfig.CompanyDocumentPhysicalPath + fileName);
                }
                docRepo.Update(doc);
            }
        }
        else //add new
            if (!string.IsNullOrEmpty(Request.QueryString["compID"]))
            {
                if (radUploadSingle.UploadedFiles.Count > 0)
                {
                    string fileName = DateTime.Now.ToString("ddMMyyyyHHmmss") + "_" + radUploadSingle.UploadedFiles[0].GetName();
                    CompanyDocument doc = new CompanyDocument();
                    doc.DocumentLegend = txtDocumentLegend.Text.Trim();
                    doc.DocumentName = fileName;// radUploadSingle.UploadedFiles[0].GetName();
                    doc.ContentType = radUploadSingle.UploadedFiles[0].ContentType;
                    doc.CreatedDate = DateTime.Now;
                    doc.CompanyID = Int32.Parse(Request.QueryString["compID"]);

                    doc.AbsoluteURL = WebConfig.CompanyDocumentAbsolutePath + fileName;
                    radUploadSingle.UploadedFiles[0].SaveAs(WebConfig.CompanyDocumentPhysicalPath + fileName);

                    docRepo.Insert(doc);
                }
            }
        string script = "<script type=\"text/javascript\">";
        script += " OnBtnSaveClientClicked();";
        script += " </script>";

        if (!ClientScript.IsClientScriptBlockRegistered("saveAndCloseWindow"))
            ClientScript.RegisterStartupScript(this.GetType(), "saveAndCloseWindow", script);
    }
    protected void OnUploadMutiSaveClick(object sender, EventArgs e)
    {
        CompanyDocumentRepository docRepo = new CompanyDocumentRepository();

        radUploadMulti.MaxFileSize = WebConfig.MaxFileSize;
        radUploadMulti.AllowedFileExtensions = WebConfig.AllowFileExtension;
        radUploadMulti.MaxFileInputsCount = WebConfig.MaxDocumentFilePerMultiUpload;
        foreach (UploadedFile file in radUploadMulti.UploadedFiles)
        {
            string fileName = DateTime.Now.ToString("ddMMyyyyHHmmss") + "_" + file.GetName();
            CompanyDocument doc = new CompanyDocument();
            doc.DocumentLegend = file.GetFieldValue("Legend");
            doc.DocumentName = fileName;// file.GetName();
            doc.AbsoluteURL = WebConfig.CompanyDocumentAbsolutePath + fileName;
            doc.CreatedDate = DateTime.Now;
            doc.CompanyID = Int16.Parse(Request.QueryString["compID"]);
            doc.ContentType = file.ContentType;
            docRepo.Insert(doc);

            file.SaveAs(WebConfig.CompanyDocumentPhysicalPath + fileName);
        }
        string script = "<script type=\"text/javascript\">";
        script += " OnBtnSaveClientClicked();";
        script += " </script>";

        if (!ClientScript.IsClientScriptBlockRegistered("saveAndCloseWindow"))
            ClientScript.RegisterStartupScript(this.GetType(), "saveAndCloseWindow", script);
    }