Ejemplo n.º 1
0
        protected void gvDocuments_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DoDelete")
            {
                try {
                    ImageButton imsource   = (ImageButton)e.CommandSource;
                    GridViewRow currentrow = null;
                    if (imsource != null)
                    {
                        currentrow = (GridViewRow)imsource.NamingContainer;
                    }
                    HiddenField LeadId = (HiddenField)currentrow.FindControl("hfLeadId");

                    using (TransactionScope scope = new TransactionScope()) {
                        LeadsDocument doc = LeadsUploadManager.GetLeadsDocumentById(Convert.ToInt32(e.CommandArgument));
                        doc.Status = 0;
                        LeadsUploadManager.SaveDocument(doc);
                        scope.Complete();
                    }
                    FillDocument(Convert.ToInt32(LeadId.Value));
                    lblSave.Visible = true;
                    lblSave.Text    = "Record Deleted !!!";
                }
                catch (Exception ex) {
                    lblError.Visible = true;
                    lblError.Text    = "Record Not Deleted !!!";
                }
            }
            if (e.CommandName == "DoUpdate")
            {
            }
        }
Ejemplo n.º 2
0
        protected void btnSaveContinue_Click(object sender, EventArgs e)
        {
            foreach (DataListItem item in dlImagesLocationDescription.Items)
            {
                int        leadImageID = (int)dlImagesLocationDescription.DataKeys[item.ItemIndex];
                LeadsImage leadImage   = null;

                TextBox txtLocation = item.FindControl("txtLocation") as TextBox;

                TextBox txtDescription = item.FindControl("txtDescription") as TextBox;

                if (!string.IsNullOrEmpty(txtLocation.Text) && !string.IsNullOrEmpty(txtDescription.Text))
                {
                    leadImage = LeadsUploadManager.GetLeadsImageById(leadImageID);
                    if (leadImage != null)
                    {
                        leadImage.Location = txtLocation.Text;

                        leadImage.Description = txtDescription.Text;

                        LeadsUploadManager.SaveImage(leadImage);
                    }
                }
            }

            // send user back to list of images
            Response.Redirect("~/Protected/Admin/LeadsImagesUpload.aspx");
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //string filepath = myimage.ImageUrl;
            //using (WebClient client = new WebClient())
            //{
            //    client.DownloadFile(filepath, Server.MapPath("~/Image/apple.jpg"));
            //}


            var list = LeadsUploadManager.GetLeadsImageById(Convert.ToInt32(hfLeadImageId.Value));

            list.Location    = txtLocation.Text.Trim();
            list.Description = txtDescription.Text.Trim();
            LeadsUploadManager.SaveImage(list);



            //const string javaScript = "<script language=javascript>window.top.close(); window.opener.location.reload(true);</script>";
            const string javaScript = "<script language=javascript>window.top.close(); window.opener.RebindImages();</script>";

            if (!ClientScript.IsStartupScriptRegistered("CloseMyWindow"))
            {
                ClientScript.RegisterStartupScript(GetType(), "CloseMyWindow", javaScript);
            }
        }
Ejemplo n.º 4
0
        protected void btnUploadDoc_Click(object sender, EventArgs e)
        {
            string ext;
            string ActualFileName = "", SavedFileName = string.Empty;
            string FileNameWithoutExt = "";
            string OccasionId         = string.Empty;
            string Occasion           = string.Empty;

            try {
                LeadsDocument objLeadDoc = new LeadsDocument();
                if (FileUpload2.HasFile)
                {
                    int LeadID = 0;
                    if (hfLeadsId.Value != null && Convert.ToInt32(hfLeadsId.Value) > 0)
                    {
                        LeadID = Convert.ToInt32(hfLeadsId.Value);
                    }
                    else
                    {
                        lblError.Text    = string.Empty;
                        lblError.Text    = "There is a problem to upload.";
                        lblError.Visible = true;
                        return;
                    }
                    string Location = "";
                    ext                     = System.IO.Path.GetExtension(FileUpload2.PostedFile.FileName);
                    ActualFileName          = FileUpload2.PostedFile.FileName.Substring(FileUpload2.PostedFile.FileName.LastIndexOf(@"\") + 1);
                    FileNameWithoutExt      = ActualFileName.Replace(ext, "");
                    objLeadDoc.LeadId       = LeadID;
                    objLeadDoc.Description  = txtDescriptionDoc.Text;
                    objLeadDoc.DocumentName = ActualFileName;
                    objLeadDoc.Status       = 1;
                    LeadsDocument objld = LeadsUploadManager.SaveDocument(objLeadDoc);
                    if (objld.LeadDocumentId > 0)
                    {
                        if (!Directory.Exists(Server.MapPath("~/LeadsDocument/" + LeadID + "/" + objld.LeadDocumentId)))
                        {
                            Directory.CreateDirectory(Server.MapPath("~/LeadsDocument/" + LeadID + "/" + objld.LeadDocumentId));
                        }

                        FileUpload2.PostedFile.SaveAs(Server.MapPath("~/LeadsDocument/" + LeadID + "/" + objld.LeadDocumentId + "/" + ActualFileName));


                        lblSave.Text           = string.Empty;
                        lblSave.Text           = "Document Uploaded Successfully";
                        lblSave.Visible        = true;
                        txtDescriptionDoc.Text = string.Empty;
                        FillDocument(LeadID);
                    }
                }
            }
            catch (Exception ex) {
                lblError.Text    = string.Empty;
                lblError.Text    = "There is a problem to upload.";
                lblError.Visible = true;
            }
        }
Ejemplo n.º 5
0
        private void bindHistoricalDocuments()
        {
            int leadID = Core.SessionHelper.getLeadId();

            // load legacy documents
            List <LeadsDocument> documents = LeadsUploadManager.getLeadsDocumentByLeadID(leadID);

            gvHistoricalDocuments.DataSource = documents;
            gvHistoricalDocuments.DataBind();
        }
        public void ProcessRequest(HttpContext context)
        {
            string LeadId       = "";
            int    policyTypeID = 0;

            if (context.Session["LeadIds"] != null)
            {
                LeadId = Convert.ToString(context.Session["LeadIds"]);
            }
            HttpPostedFile fileToUpload = context.Request.Files["Filedata"];


            string ext                = System.IO.Path.GetExtension(fileToUpload.FileName);
            string ActualFileName     = fileToUpload.FileName.Substring(fileToUpload.FileName.LastIndexOf(@"\") + 1);
            string FileNameWithoutExt = ActualFileName.Replace(ext, "");

            if (ext != ".doc" && ext != ".exl" && ext != ".pdf")
            {
                LeadsImage objLeadImage = new LeadsImage();
                objLeadImage.LeadId    = Convert.ToInt32(LeadId);
                objLeadImage.ImageName = ActualFileName;
                objLeadImage.Status    = 1;

                if (context.Session["policyTypeID"] != null)
                {
                    policyTypeID = (int)context.Session["policyTypeID"];
                }

                objLeadImage.policyTypeID = policyTypeID;

                // 2013-09-24 tortega
                objLeadImage.isPrint = true;

                objLeadImage = LeadsUploadManager.SaveImage(objLeadImage);

                if (Convert.ToInt32(LeadId) > 0)
                {
                    if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/LeadsImage/" + Convert.ToInt32(LeadId) + "/" + objLeadImage.LeadImageId)))
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/LeadsImage/" + Convert.ToInt32(LeadId) + "/" + objLeadImage.LeadImageId));
                    }

                    fileToUpload.SaveAs(HttpContext.Current.Server.MapPath("~/LeadsImage/" + Convert.ToInt32(LeadId) + "/" + objLeadImage.LeadImageId + "/" + ActualFileName));
                }
            }

            //string pathToSave = HttpContext.Current.Server.MapPath("~/TempLeadsImage/") + LeadId + "/" +fileToUpload.FileName;


            //if (!Directory.Exists(HttpContext.Current.Server.MapPath("~\\TempLeadsImage\\" + LeadId)))
            //    Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~\\TempLeadsImage\\" + LeadId));

            //fileToUpload.SaveAs(pathToSave);
        }
Ejemplo n.º 7
0
        private void loadData()
        {
            List <LeadsImage> images = null;
            int leadID = 0;

            leadID = Convert.ToInt32(Session["LeadIds"]);
            images = LeadsUploadManager.getLeadsImagesMissingLocationDescription(leadID);
            //image.LeadImageId
            dlImagesLocationDescription.DataSource = images;

            dlImagesLocationDescription.DataBind();
        }
Ejemplo n.º 8
0
        static protected string mergeDocuments(string sourcepath, string destinationPath, int leadID, int claimID)
        {
            List <LeadsDocument> documents      = null;
            List <ClaimDocument> claimDocuments = null;
            List <string>        pdfs           = new List <string>();

            string mergedReportPath = null;

            documents      = LeadsUploadManager.getLeadsDocumentForExportByLeadID(leadID);
            claimDocuments = ClaimDocumentManager.GetAll(claimID);

            // add original document to list
            pdfs.Insert(0, sourcepath);

            // lead documents
            if (documents != null && documents.Count > 0)
            {
                List <string> leadPDFs = (from x in documents
                                          where x.DocumentName.Contains(".pdf")
                                          select string.Format("{0}/LeadsDocument/{1}/{2}/{3}", appPath, x.LeadId, x.LeadDocumentId, x.DocumentName)
                                          ).ToList();

                foreach (string pdf in leadPDFs)
                {
                    pdfs.Add(pdf);
                }
            }

            // claim documents
            if (claimDocuments != null && claimDocuments.Count > 0)
            {
                List <string> claimPDFs = (from x in claimDocuments
                                           where x.DocumentName.Contains(".pdf")
                                           select string.Format("{0}/ClaimDocuments/{1}/{2}/{3}", appPath, x.ClaimID, x.ClaimDocumentID, x.DocumentName)
                                           ).ToList();

                foreach (string pdf in claimPDFs)
                {
                    pdfs.Add(pdf);
                }
            }

            // mergedReportPath = Path.GetDirectoryName(sourcepath) + "\\" + Guid.NewGuid().ToString() + ".pdf";
            // mergePDFFiles(mergedReportPath, pdfs.ToArray());

            mergePDFFiles(destinationPath, pdfs.ToArray());

            return(destinationPath);
        }
Ejemplo n.º 9
0
        private void FillDocument(int LeadId)
        {
            List <LeadsDocument> doc = LeadsUploadManager.getLeadsDocumentByLeadID(LeadId);

            if (doc != null && doc.Count > 0)
            {
                gvDocuments.DataSource = doc;
                gvDocuments.DataBind();
            }
            else
            {
                gvDocuments.DataSource = null;
                gvDocuments.DataBind();
            }
        }
        private void FillImage(int LeadId, int LeadImageId)
        {
            LeadsImage img = LeadsUploadManager.getLeadsImageByLeadID(LeadId).Where(x => x.LeadImageId == LeadImageId).SingleOrDefault();

            if (img != null)
            {
                txtLocation.Text    = img.Location;
                txtDescription.Text = img.Description;
                string imageName = img.ImageName == String.Empty ? "../../Images/no.jpg" : "../../LeadsImage/" + Convert.ToString(img.LeadId) + "/" + Convert.ToString(img.LeadImageId) + "/" + Convert.ToString(img.ImageName);
                myimage.ImageUrl = imageName;
            }
            else
            {
            }
        }
Ejemplo n.º 11
0
        public static void togglePrintFlag(bool isPrint, int leadImageID)
        {
            LeadsImage leadImage = LeadsUploadManager.GetLeadsImageById(leadImageID);

            if (leadImage != null)
            {
                leadImage.isPrint = isPrint;

                try {
                    LeadsUploadManager.SaveImage(leadImage);
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                }
            }
        }
Ejemplo n.º 12
0
        public static string getLeadPhoto(int leadImageID)
        {
            string         result    = null;
            LeadsImage     leadImage = LeadsUploadManager.GetLeadsImageById(leadImageID);
            ClaimImageView claimView = null;

            if (leadImage != null)
            {
                claimView = new ClaimImageView {
                    location    = leadImage.Location,
                    description = leadImage.Description
                };
            }
            result = ComputerBeacon.Json.Serializer.Serialize(claimView);
            return(result);
        }
Ejemplo n.º 13
0
        public static void saveLeadPhotoDescription(int leadImageID, string photoLocation, string photoDescription)
        {
            LeadsImage leadImage = LeadsUploadManager.GetLeadsImageById(leadImageID);

            if (leadImage != null)
            {
                leadImage.Location    = photoLocation.Trim();
                leadImage.Description = photoDescription.Trim();

                try {
                    LeadsUploadManager.SaveImage(leadImage);
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                }
            }
        }
Ejemplo n.º 14
0
        static protected void exportPhotos(LeadPolicy policy)
        {
            int    leadID            = (int)policy.LeadId;
            int    policyTypeID      = (int)policy.PolicyType;
            string policyDescription = policy.LeadPolicyType != null ? policy.LeadPolicyType.Description : "";

            List <LeadsImage> images = LeadsUploadManager.getLeadsImageByLeadID(leadID, policyTypeID);


            if (images == null || images.Count == 0)
            {
                return;
            }


            addPhotos(images, policyDescription);
        }
Ejemplo n.º 15
0
        protected void dtlist_ItemCommand(object sender, DataListCommandEventArgs e)
        {
            if (e.CommandName.Equals("DoDelete"))
            {
                int LeadImageId = Convert.ToInt32(e.CommandArgument);
                try {
                    var list = LeadsUploadManager.GetLeadsImageById(LeadImageId);
                    list.Status = 0;
                    LeadsUploadManager.SaveImage(list);


                    lblSave.Text    = "Image deleted Successfully.";
                    lblSave.Visible = true;
                    FillImage(this.leadID);
                }
                catch (Exception ex) {
                    lblError.Text    = "Image not deleted.";
                    lblError.Visible = true;
                }
            }
            if (e.CommandName.Equals("DoRotate"))
            {
                try {
                    System.Web.UI.WebControls.Image img = (System.Web.UI.WebControls.Image)e.Item.FindControl("Image1");
                    // get the full path of image url
                    string path = Server.MapPath(img.ImageUrl);

                    // creating image from the image url
                    System.Drawing.Image i = System.Drawing.Image.FromFile(path);

                    // rotate Image 90' Degree
                    i.RotateFlip(RotateFlipType.Rotate90FlipXY);

                    // save it to its actual path
                    i.Save(path);
                    // release Image File
                    i.Dispose();

                    img.Attributes.Add("ImageUrl", path);
                }
                catch (Exception ex) {
                }
            }
        }
Ejemplo n.º 16
0
        protected void uploadFile(FileUpload fileupload, int leadID, string fileDescription)
        {
            string appPath  = ConfigurationManager.AppSettings["appPath"].ToString();
            string filePath = null;

            if (fileupload.HasFile)
            {
                LeadsImage objLeadImage = new LeadsImage();
                objLeadImage.LeadId    = leadID;
                objLeadImage.ImageName = fileupload.FileName;
                objLeadImage.Status    = 1;
                objLeadImage.InsertBy  = userID;
                objLeadImage.isPrint   = true;

                if (!string.IsNullOrEmpty(fileDescription))
                {
                    objLeadImage.Description = fileDescription;
                }

                objLeadImage.policyTypeID = Convert.ToInt32(ucPolicyType1.SelectedValue);
                objLeadImage = LeadsUploadManager.SaveImage(objLeadImage);

                if (fileupload.PostedFile.ContentType == "application/msword")
                {
                }
                else
                {
                    // images
                    string filename = Path.GetFileName(fileupload.FileName);
                    filePath = string.Format("{0}\\LeadsImage\\{1}\\{2}", appPath, leadID, objLeadImage.LeadImageId);

                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }

                    fileupload.SaveAs(filePath + "\\" + filename);
                }
            }
        }
Ejemplo n.º 17
0
        private void updateDocumentLog(string reportPath, int policyTypeID)
        {
            string appPath      = ConfigurationManager.AppSettings["appPath"].ToString();
            string documentPath = null;

            int leadID = Core.SessionHelper.getLeadId();

            LeadsDocument objLeadDoc = new LeadsDocument();

            string ActualFileName = Path.GetFileName(reportPath);

            string FileNameWithoutExt = Path.GetFileNameWithoutExtension(reportPath);

            objLeadDoc.LeadId = leadID;

            objLeadDoc.Description = "Invoice";

            objLeadDoc.DocumentName = ActualFileName;
            objLeadDoc.Status       = 1;
            objLeadDoc.IsPrint      = false;

            objLeadDoc.InsertDate = DateTime.Now;

            objLeadDoc.PolicyTypeID = policyTypeID;

            objLeadDoc = LeadsUploadManager.SaveDocument(objLeadDoc);

            if (objLeadDoc.LeadDocumentId > 0)
            {
                documentPath = appPath + "/LeadsDocument/" + leadID + "/" + objLeadDoc.LeadDocumentId;

                if (!Directory.Exists(documentPath))
                {
                    Directory.CreateDirectory(documentPath);
                }

                File.Copy(reportPath, documentPath + "/" + ActualFileName, true);
            }
        }
Ejemplo n.º 18
0
        private void FillImage(int LeadId)
        {
            int policyTypeID = Convert.ToInt32(ViewState["policyTypeID"]);

            if (policyTypeID > 0)
            {
                List <LeadsImage> img = LeadsUploadManager.getLeadsImageByLeadID(LeadId, policyTypeID);
                if (img != null && img.Count > 0)
                {
                    adsource.DataSource       = img;
                    ViewState["ls"]           = adsource.PageCount - 1;
                    adsource.CurrentPageIndex = pos;
                    ViewState["pageIndex"]    = pos;
                    lblPageCount.Text         = "Page " + (pos + 1) + " of " + adsource.PageCount;


                    btnfirst.Enabled    = !adsource.IsFirstPage;
                    btnprevious.Enabled = !adsource.IsFirstPage;
                    btnlast.Enabled     = !adsource.IsLastPage;
                    btnnext.Enabled     = !adsource.IsLastPage;
                    t1.Visible          = true;
                    dtlist.DataSource   = adsource;
                    dtlist.DataBind();
                }
                else
                {
                    // divImage.Visible = false;
                    dtlist.DataSource = img;
                    dtlist.DataBind();
                    t1.Visible = false;
                }
            }
            else
            {
                dtlist.DataSource = null;
                dtlist.DataBind();
                t1.Visible = false;
            }
        }
Ejemplo n.º 19
0
        private void bindData()
        {
            int   leadID  = 0;
            int   claimID = 0;
            Leads lead    = null;
            Claim claim   = null;
            List <LeadsDocument> leadDocuments  = null;
            List <ClaimDocument> claimDocuments = null;
            List <DocumentList>  allDocuments   = new List <DocumentList>();

            int.TryParse(Core.SecurityManager.DecryptQueryString(Request.Params["q"].ToString()), out claimID);

            if (claimID > 0)
            {
                claim = ClaimsManager.Get(claimID);
                if (claim != null)
                {
                    lead = claim.LeadPolicy.Leads;

                    lblName.Text = lead.insuredName;

                    // lead documents
                    leadDocuments = LeadsUploadManager.getLeadsDocumentForExportByLeadID(leadID);
                    if (leadDocuments != null && leadDocuments.Count > 0)
                    {
                        foreach (LeadsDocument leadDocument in leadDocuments)
                        {
                            DocumentList doc = new DocumentList();
                            doc.DocumentName = leadDocument.DocumentName;
                            doc.Description  = leadDocument.Description;

                            doc.DocumentPath = string.Format("~/LeadsDocument/{0}/{1}/{2}",
                                                             leadDocument.LeadId,
                                                             leadDocument.LeadDocumentId,                                               // document id
                                                             leadDocument.DocumentName);                                                // document file name

                            allDocuments.Add(doc);
                        }
                    }

                    // claim documents
                    claimDocuments = ClaimDocumentManager.GetAll(claimID);
                    if (claimDocuments != null && claimDocuments.Count > 0)
                    {
                        foreach (ClaimDocument claimDocument in claimDocuments)
                        {
                            DocumentList doc = new DocumentList();
                            doc.DocumentName = claimDocument.DocumentName;
                            doc.Description  = claimDocument.Description;

                            doc.DocumentPath = string.Format("~/ClaimDocuments/{0}/{1}/{2}",
                                                             claimDocument.ClaimID,
                                                             claimDocument.ClaimDocumentID,                                             // document id
                                                             claimDocument.DocumentName);                                               // document file name
                            allDocuments.Add(doc);
                        }
                    }

                    gvDocument.DataSource = allDocuments;
                    gvDocument.DataBind();
                }
            }
        }
Ejemplo n.º 20
0
        protected void bindData()
        {
            //AppraiserMaster appraiser = null;
            Claim claim = null;
            //List<LeadContact> contacts = null;
            List <DocumentList> attachments = null;
            //ContractorMaster contractor = null;
            //List<SecUser> users = null;
            Leads lead = null;

            //Data.UmpireMaster umpire = null;
            // get email for user sending email

            CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(userID);
            if (user != null)
            {
                txtEmailFrom.Text = user.Email;
                txtEmailCC.Text   = user.Email;
                txtSignature.Text = user.emailSignature ?? "";
            }


            claim = ClaimsManager.Get(this.claimID);

            if (claim != null)
            {
                attachments = new List <DocumentList>();

                lead = claim.LeadPolicy.Leads;

                // build subject line
                txtEmailSubject.Text = string.Format("{0} Claim #: {1}", lead.policyHolderName, claim.AdjusterClaimNumber);

                // load legacy documents
                List <LeadsDocument> documents = LeadsUploadManager.getLeadsDocumentByLeadID((int)claim.LeadPolicy.LeadId);

                if (documents != null && documents.Count > 0)
                {
                    foreach (LeadsDocument x in documents)
                    {
                        DocumentList attachment = new DocumentList();
                        attachment.DocumentName = x.Description;
                        attachment.DocumentPath = string.Format("LeadsDocument/{0}/{1}/{2}",
                                                                x.LeadId,
                                                                x.LeadDocumentId,       // document id
                                                                x.DocumentName);        // document file name

                        attachments.Add(attachment);
                    }
                }

                // load claim documents
                List <ClaimDocument> claimDocuments = ClaimDocumentManager.GetAll(this.claimID);
                if (claimDocuments != null && claimDocuments.Count > 0)
                {
                    foreach (ClaimDocument x in claimDocuments)
                    {
                        DocumentList attachment = new DocumentList();

                        attachment.DocumentName = x.Description;
                        attachment.DocumentPath = string.Format("ClaimDocuments/{0}/{1}/{2}",
                                                                x.ClaimID,
                                                                x.ClaimDocumentID,      // document id
                                                                x.DocumentName);        // document file name

                        attachments.Add(attachment);
                    }
                }

                lbxDocuments.DataSource = attachments;
                lbxDocuments.DataBind();

                //// load legacy contacts
                //contacts = LeadContactManager.GetContactByLeadID(leadID);

                //// add adjusters to contact list
                //if (claim.AdjusterMaster != null)
                //	addToContactList(claim.AdjusterMaster.AdjusterName, claim.AdjusterMaster.email, contacts);


                //// add appraiser to contact list
                //if (lead.AppraiserID != null) {
                //	appraiser = AppraiserManager.Get((int)lead.AppraiserID);

                //	contacts.Add(new LeadContact {
                //		Email = appraiser.Email,
                //		ContactName = appraiser.AppraiserName
                //	});
                //}

                //// add contractor to contact list
                //if (lead.ContractorID != null) {
                //	contractor = ContractorManager.Get((int)lead.ContractorID);
                //	contacts.Add(new LeadContact {
                //		Email = lead.ContractorMaster.Email,
                //		ContactName = lead.ContractorMaster.ContractorName
                //	});
                //}

                //// add umpire to contact list
                //if (lead.UmpireID != null) {
                //	umpire = UmpireManager.Get((int)lead.UmpireID);

                //	contacts.Add(new LeadContact {
                //		Email = lead.UmpireMaster.Email,
                //		ContactName = lead.UmpireMaster.UmpireName
                //	});
                //}


                // add users 2013-12-12
                //users = SecUserManager.GetUsers(clientID);
                //if (users != null && users.Count > 0) {

                //	users.ForEach(x =>
                //		contacts.Add(new LeadContact {
                //			Email = x.Email,
                //			ContactName = x.FirstName ?? "" + " " + x.LastName ?? ""
                //		}));
                //}
            }

            //lbxContacts.DataSource = contacts;
            //lbxContacts.DataBind();
        }
Ejemplo n.º 21
0
        protected void btnUploadDoc_Click(object sender, EventArgs e)
        {
            string   ext;
            string   ActualFileName = "", SavedFileName = string.Empty;
            string   FileNameWithoutExt = "";
            DateTime fileDate           = DateTime.MinValue;
            string   OccasionId         = string.Empty;
            string   Occasion           = string.Empty;
            int      LeadID             = Convert.ToInt32(Session["LeadIds"]);

            Page.Validate("DocUpload");
            if (!Page.IsValid)
            {
                return;
            }

            string policyType   = Page.Request.Params["t"].ToString();
            int    policyTypeID = (int)Enum.Parse(typeof(PolicyType), policyType);

            try {
                if (FileUpload2.HasFile)
                {
                    LeadsDocument objLeadDoc = new LeadsDocument();

                    ext                     = System.IO.Path.GetExtension(FileUpload2.PostedFile.FileName);
                    ActualFileName          = FileUpload2.PostedFile.FileName.Substring(FileUpload2.PostedFile.FileName.LastIndexOf(@"\") + 1);
                    FileNameWithoutExt      = ActualFileName.Replace(ext, "");
                    objLeadDoc.LeadId       = LeadID;
                    objLeadDoc.Description  = txtDescriptionDoc.Text;
                    objLeadDoc.DocumentName = ActualFileName;
                    objLeadDoc.Status       = 1;

                    DateTime.TryParse(hf_lastModifiedDate.Value, out fileDate);

                    objLeadDoc.InsertDate = fileDate;

                    objLeadDoc.PolicyTypeID = policyTypeID;

                    LeadsDocument objld = LeadsUploadManager.SaveDocument(objLeadDoc);

                    if (objld.LeadDocumentId > 0)
                    {
                        if (!Directory.Exists(appPath + "/LeadsDocument/" + LeadID + "/" + objld.LeadDocumentId))
                        {
                            Directory.CreateDirectory(appPath + "/LeadsDocument/" + LeadID + "/" + objld.LeadDocumentId);
                        }

                        FileUpload2.PostedFile.SaveAs(appPath + "/LeadsDocument/" + LeadID + "/" + objld.LeadDocumentId + "/" + ActualFileName);

                        //lblSave.Text = string.Empty;
                        //lblSave.Text = "Document Uploaded Successfully";
                        //lblSave.Visible = true;
                        txtDescriptionDoc.Text = string.Empty;
                        //bindDocuments(LeadID);

                        string js = "<script type='text/javascript'>closeRefresh();</script>";

                        ClientScript.RegisterClientScriptBlock(typeof(Page), "commentk", js);
                    }
                }
            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);

                //lblError.Text = string.Empty;
                //lblError.Text = "There is a problem to upload.";
                //lblError.Visible = true;
            }
        }