/// <summary>
        /// Date Created:   26/Sep/2013
        /// Created By:     Josephine Gad
        /// (description)   Get Attachment List from Session or ListView
        /// </summary>
        private List <ContractSafeguardAttachment> GetAttachmentList()
        {
            List <ContractSafeguardAttachment> list = new List <ContractSafeguardAttachment>();

            if (Session["ContractSafeguardAttachment"] != null)
            {
                list = (List <ContractSafeguardAttachment>)Session["ContractSafeguardAttachment"];
            }
            else
            {
                ContractSafeguardAttachment itemList;
                //HiddenField uoHiddenFieldID;
                HiddenField uoLabelServiceTypeName;
                foreach (ListViewItem item in uoListViewAttachment.Items)
                {
                    itemList = new ContractSafeguardAttachment();
                    //uoHiddenFieldID = (HiddenField)item.FindControl("uoHiddenFieldID");
                    uoLabelServiceTypeName = (HiddenField)item.FindControl("uoLabelServiceTypeName");

                    itemList.FileName = uoLabelServiceTypeName.Value;
                    list.Add(itemList);
                }
            }
            return(list);
        }
        /// <summary>
        /// Date Created:   26/Sep/2013
        /// Created By:     Josephine Gad
        /// (description)   Remove Attachment from List
        /// </summary>
        private void AttachmentListRemove(string sFileName)
        {
            List <ContractSafeguardAttachment> list = new List <ContractSafeguardAttachment>();
            ContractSafeguardAttachment        item = new ContractSafeguardAttachment();

            list = GetAttachmentList();

            list.RemoveAll(a => list.Exists(b => a.FileName == sFileName));
            list = list.OrderBy(a => a.FileName).ToList();

            Session["ContractSafeguardAttachment"] = list;
            BindAttachmentListView(0, 0);
        }
        /// <summary>
        /// Date Created: 18/10/2011
        /// Created By: Gabriel Oquialda
        /// (description) Upload vehicle contract attachment
        /// ---------------------------------------------------------
        /// Date Modified:  2013/08/23
        /// Modified By:    Josephine Gad
        /// (description)   Upload file in listview
        /// </summary>
        protected void uoButtonUpload_Click(object sender, EventArgs e)
        {
            if (uoFileUploadContract.PostedFile == null || string.IsNullOrEmpty(uoFileUploadContract.PostedFile.FileName) || uoFileUploadContract.PostedFile.InputStream == null)
            {
                Label1.Text = "<br />Error - unable to upload file. Please try again.<br />";
                uoFileUploadContract.Focus();
            }
            else
            {
                ContractSafeguardAttachment item = new ContractSafeguardAttachment();
                int fileSize = uoFileUploadContract.PostedFile.ContentLength;
                if (fileSize > (10000 * 1024)) //10000 means 10MB
                {
                    Label1.Text = "Filesize is too large. Maximum file size permitted is 10MB";
                    uoFileUploadContract.Focus();
                    return;
                }
                //Label1.Visible = false;
                byte[] imageBytes = new byte[uoFileUploadContract.PostedFile.InputStream.Length + 1];
                uoFileUploadContract.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length);
                uoHiddenFieldFileName.Value = uoFileUploadContract.FileName;
                uoHiddenFieldFileType.Value = uoFileUploadContract.PostedFile.ContentType;

                //uoFileUploadContract.Visible = false;
                //ucLabelAttached.Visible = true;

                //ucLabelAttached.Text = uoHiddenFieldFileName.Value;

                //ViewState["imageByte"] = imageBytes;
                //uoLinkAttach.Visible = false;
                //uoLinkButtonRemove.Visible = true;
                uoButtonSave.Focus();

                List <ContractSafeguardAttachment> list = new List <ContractSafeguardAttachment>();
                list = GetAttachmentList();

                item.FileName     = uoFileUploadContract.FileName;
                item.FileType     = uoFileUploadContract.PostedFile.ContentType;
                item.UploadedDate = DateTime.Now;
                item.uploadedFile = imageBytes;
                list.Add(item);
                Session["ContractSafeguardAttachment"] = list;
                BindAttachmentListView(0, 0);
            }
        }