Пример #1
0
        protected void gvAttachFiles_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = gvAttachFiles.Rows[e.RowIndex];
            //Only 0-1 Element
            //AttachFile attachFile = ActiveAttachFiles.Single(a => a.ID == ((Label)row.FindControl("lblAttachFileId")).Text);
            //Only one more Element
            AttachFile attachFile    = ActiveAttachFiles.FirstOrDefault(a => a.ID == ((Label)row.FindControl("lblAttachFileId")).Text);
            TextBox    rowTextRemark = (TextBox)row.FindControl("txtDetailGv");

            AttachFile editAttachFile = attachFile.ConvertToAttachFileView();

            editAttachFile.REMARK      = (rowTextRemark == null) ? "" : rowTextRemark.Text;
            editAttachFile.FILE_STATUS = AttachFileStatus.Edit.Value();


            if (TempAttachFiles.Where(t => t.ATTACH_FILE_TYPE == editAttachFile.ATTACH_FILE_TYPE).Count() > 0)
            {
                AlertMessageShow(SysMessage.AttachFileDupicate);
            }
            else
            {
                _attachFiles.Add(editAttachFile);
            }

            gvAttachFiles.EditIndex = -1;

            ((DataControlField)gvAttachFiles.Columns
             .Cast <DataControlField>()
             .Where(fld => fld.HeaderText == "ดำเนินการ")
             .SingleOrDefault()).Visible = true;

            BindAttachFile();
        }
Пример #2
0
        private void BindingRowMode(AttachFile attachFile, LinkButton lbnEditGv, LinkButton hplView, LinkButton hplDelete, LinkButton hplCancel, GridViewRowEventArgs e)
        {
            if (attachFile.FILE_STATUS == AttachFileStatus.Active.Value())
            {
                if (TempAttachFiles.Where(a => a.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                          (a.FILE_STATUS == AttachFileStatus.Edit.Value() ||
                                           a.FILE_STATUS == AttachFileStatus.Wait.Value())).Count() > 0)
                {
                    if (lbnEditGv != null)
                    {
                        lbnEditGv.Visible = false;
                    }
                    if (hplView != null)
                    {
                        hplView.Visible = false;
                    }
                    if (hplDelete != null)
                    {
                        hplDelete.Visible = false;
                    }
                    if (hplCancel != null)
                    {
                        hplCancel.Visible = false;
                    }

                    e.Row.Style.Value = "text-decoration:line-through;";
                }
                else if (TempAttachFiles.Where(a => a.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                               a.FILE_STATUS == AttachFileStatus.Delete.Value()).Count() > 0)
                {
                    e.Row.Visible = false;
                }

                else
                {
                    if (lbnEditGv != null)
                    {
                        lbnEditGv.Visible = true;
                    }
                    if (hplView != null)
                    {
                        hplView.Visible       = true;
                        hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                    }
                    if (hplDelete != null)
                    {
                        hplDelete.Visible = true;
                    }
                    if (hplCancel != null)
                    {
                        hplCancel.Visible = false;
                    }
                }
            }
            else if (attachFile.FILE_STATUS == AttachFileStatus.Delete.Value())
            {
                if (TempAttachFiles.Where(a => a.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                          a.FILE_STATUS == AttachFileStatus.Wait.Value()).Count() > 0)
                {
                    if (lbnEditGv != null)
                    {
                        lbnEditGv.Visible = false;
                    }
                    if (hplView != null)
                    {
                        hplView.Visible       = true;
                        hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                    }
                    if (hplDelete != null)
                    {
                        hplDelete.Visible = false;
                    }
                    if (hplCancel != null)
                    {
                        hplCancel.Visible = false;
                    }
                }
                else
                {
                    if (lbnEditGv != null)
                    {
                        lbnEditGv.Visible = false;
                    }
                    if (hplView != null)
                    {
                        hplView.Visible       = true;
                        hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                    }
                    if (hplDelete != null)
                    {
                        hplDelete.Visible = false;
                    }
                    if (hplCancel != null)
                    {
                        hplCancel.Visible = true;
                    }
                }


                e.Row.Style.Value = "text-decoration:line-through;";
            }
            else if (attachFile.FILE_STATUS == AttachFileStatus.Edit.Value())
            {
                if (lbnEditGv != null)
                {
                    lbnEditGv.Visible = false;
                }
                if (hplView != null)
                {
                    hplView.Visible       = true;
                    hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                }
                if (hplDelete != null)
                {
                    hplDelete.Visible = false;
                }
                if (hplCancel != null)
                {
                    hplCancel.Visible = true;
                }
            }
            else if (attachFile.FILE_STATUS == AttachFileStatus.Wait.Value())
            {
                if (lbnEditGv != null)
                {
                    lbnEditGv.Visible = false;
                }
                if (hplView != null)
                {
                    hplView.Visible       = true;
                    hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                }
                if (hplDelete != null)
                {
                    hplDelete.Visible = false;
                }
                if (hplCancel != null)
                {
                    hplCancel.Visible = true;
                }
            }
        }
Пример #3
0
        protected void btnUploadFile_Click(object sender, EventArgs e)
        {
            if (!fulAttachFile.HasFile)
            {
                AlertMessageShow(SysMessage.CannotUploadFile);
                return;
            }

            var           documentCode = ddlDocumentType.SelectedValue;
            DataCenterBiz dbiz         = new DataCenterBiz();
            var           imgItem      = dbiz.GetPicByDocumentCode(documentCode);

            if (imgItem != null)
            {
                if (!FilterContentTypeImage(fulAttachFile.PostedFile.ContentType))
                {
                    AlertMessageShow(String.Format("ไม่สามารถนำเข้าไฟล์ ประเภท{0} ได้.", fulAttachFile.FileName.Substring(fulAttachFile.FileName.LastIndexOf('.'))));
                    return;
                }
            }
            else
            {
                if (!FilterContentType(fulAttachFile.PostedFile.ContentType))
                {
                    AlertMessageShow(String.Format("ไม่สามารถนำเข้าไฟล์ ประเภท{0} ได้.", fulAttachFile.FileName.Substring(fulAttachFile.FileName.LastIndexOf('.'))));
                    return;
                }
            }

            if (fulAttachFile.FileBytes.LongCount() > 1048576)
            {
                AlertMessageShow(SysMessage.AttachNotOverOneMB);
                return;
            }

            AttachFile attachFile = ConcreateFromControl();

            Stream fileStream = fulAttachFile.PostedFile.InputStream;

            try
            {
                if (ActiveAttachFiles.Where(a => a.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE).Count() > 0)
                {
                    if (TempAttachFiles.Where(t => t.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                              t.FILE_STATUS == AttachFileStatus.Wait.Value()).Count() > 0)
                    {
                        AlertMessageShow(SysMessage.AttachFileDupicate);
                        return;
                    }
                    if (TempAttachFiles.Where(t => t.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                              t.FILE_STATUS == AttachFileStatus.Delete.Value()).Count() > 0)
                    {
                        var biz = new BLL.UploadDataBiz();
                        UploadFileResponse response = new UploadFileResponse();
                        response = biz.UploadAttachFileToTemp(attachFile, fileStream);

                        if (response.Code != "0000")
                        {
                            AlertMessageShow(response.Message);
                            return;
                        }
                        attachFile.ATTACH_FILE_PATH = response.TargetFullName;

                        AttachFile deleteAttach = _attachFiles.Single(t => t.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                                                      t.FILE_STATUS == AttachFileStatus.Delete.Value());

                        attachFile.MappingToEntity <AttachFile>(deleteAttach);
                        DefaultValue();
                        BindAttachFile();
                    }
                    else
                    {
                        AlertMessageShow(SysMessage.AttachFileDupicate);
                        return;
                    }
                }
                else
                {
                    if (TempAttachFiles.Where(t => t.ATTACH_FILE_TYPE == ddlDocumentType.SelectedValue &&
                                              t.FILE_STATUS == AttachFileStatus.Wait.Value()).Count() > 0)
                    {
                        AlertMessageShow(SysMessage.AttachFileDupicate);
                        return;
                    }
                    else
                    {
                        var biz = new BLL.UploadDataBiz();
                        UploadFileResponse response = new UploadFileResponse();
                        //response = biz.UploadAttachFileToTemp(attachFile, fileStream);
                        response = biz.UploadAttachFileLicenseToTemp(attachFile, fileStream);


                        if (response.Code != "0000")
                        {
                            AlertMessageShow(response.Message);
                            return;
                        }
                        attachFile.ATTACH_FILE_PATH = response.TargetFullName;

                        _attachFiles.Add(attachFile);
                        DefaultValue();
                        BindAttachFile();


                        //Add to masterLicense
                        this.MasterLicense.AttachFiles = _attachFiles;
                    }
                }
            }
            catch (Exception ex)
            {
                AlertMessageShow(ex.Message);
            }

            udpAttachFiles.Update();
        }