private void btnEmail_Click(object sender, EventArgs e)
        {
            try
            {
                string tempPath = string.Format("{0}{1}", AppCommon.GetDefaultStorageFolderPath(), "Temp");
                if (!System.IO.Directory.Exists(tempPath))
                {
                    System.IO.Directory.CreateDirectory(tempPath);
                }
                string newfileName = string.Format("{0}\\{1}{2}", tempPath, FileTitle, Path.GetExtension(this.FileName));
                File.Copy(this.FileName, newfileName, true);
                frmSendMail frm = new frmSendMail();
                frm.AttachedFiles.Add(this.FileTitle, newfileName);
                frm.SOURCE_ENTITY    = this.EntityType;
                frm.SOURCE_ENTITY_ID = this.EntityID;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    // MAINTAINING HISTORY OF EMAIL SENT
                    TBL_MP_CRM_SM_DocumentHistory history = new TBL_MP_CRM_SM_DocumentHistory();
                    history.AttachmentID   = this.AttachmentID;
                    history.EntityType     = (int)this.EntityType;
                    history.EmployeeID     = Program.CURR_USER.EmployeeID;
                    history.CreateDatetime = AppCommon.GetServerDateTime();
                    history.Description    = string.Format("{0} sent Email Atachment\nTO: {1} dt. {2}\nSUB: {3}\n\n{4}", Program.CURR_USER.UserFullName, frm.txtMailTo.Text, history.CreateDatetime, frm.txtSubject.Text, frm.txtMessage.Text);
                    _UOM.AppDBContext.TBL_MP_CRM_SM_DocumentHistory.Add(history);
                    _UOM.AppDBContext.SaveChanges();

                    PopulateHistory();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnDownload_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.FileName = string.Format("{0}{1}", this.FileTitle, Path.GetExtension(this.FileName));
            saveFileDialog1.Title    = "Save Document";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                File.Copy(this.FileName, saveFileDialog1.FileName, true);
                switch (this.EntityType)
                {
                case APP_ENTITIES.SALES_LEAD:
                    TBL_MP_CRM_SM_SalesLead_Attachment attachment = _UOM.AppDBContext.TBL_MP_CRM_SM_SalesLead_Attachment.Where(x => x.PK_AttachmentID == this.AttachmentID).FirstOrDefault();
                    if (attachment != null)
                    {
                        _UOM.AppDBContext.SaveChanges();

                        // MAINTAINING HISTORY OF EMAIL SENT
                        TBL_MP_CRM_SM_DocumentHistory history = new TBL_MP_CRM_SM_DocumentHistory();
                        history.AttachmentID   = this.AttachmentID;
                        history.EntityType     = (int)this.EntityType;
                        history.EmployeeID     = Program.CURR_USER.EmployeeID;
                        history.CreateDatetime = AppCommon.GetServerDateTime();
                        history.Description    = string.Format("Downloaded by {0} dt. {1}", Program.CURR_USER.UserFullName, history.CreateDatetime.Value.ToString("dd MMMyy hh:mmtt"));
                        _UOM.AppDBContext.TBL_MP_CRM_SM_DocumentHistory.Add(history);
                        _UOM.AppDBContext.SaveChanges();

                        PopulateHistory();
                    }

                    break;
                }
            }
        }