Exemple #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string msg = string.Empty;

            if (!CheckInput(out msg))
            {
                ShowMessageToClient(msg, 2, false, false);
                return;
            }
            if (rbtnNewDirectory.Checked)
            {
                DirectoryEntity model = GetDirectory();
                int             id    = fileApp.UpdateDirectory(model);
                if (id > 0)
                {
                    this.ShowSuccessMessageToClient();
                }
                else
                {
                    this.ShowFailMessageToClient(fileApp.BrokenRuleMessages, false);
                }
            }
            else if (rbtnNewFile.Checked)
            {
                FilesEntity model = GetFile();
                if (fileApp.UpdateFile(model))
                {
                    ShowSuccessMessageToClient(true, true);
                }
                else
                {
                    ShowFailMessageToClient(fileApp.BrokenRuleMessages, false);
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int id            = QS("id", 0);
            int workRequestId = QS("wid", 0);

            if (fileProject.HasFile || lblFile.Visible == true)
            {
                FilesEntity model = FileFactory.CreateFileEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>());
                model.FilePath = UtilFactory.Helpers.FileHelper.SaveUploadFiles("WorkRequest", workRequestId, fileProject.PostedFile);;

                model.WorkRequestId = workRequestId;
                model.ContentType   = fileProject.PostedFile.ContentType;
                model.FileID        = 0;
                model.FileSize      = fileProject.PostedFile.ContentLength;
                if (string.IsNullOrEmpty(txtFileTitle.Text))
                {
                    model.FileTitle = Path.GetFileName(fileProject.FileName);
                    model.FileTitle = model.FileTitle.Substring(0, model.FileTitle.LastIndexOf("."));
                }
                else
                {
                    model.FileTitle = txtFileTitle.Text;
                }
                model.IsDelete   = false;
                model.IsPublic   = UserInfo.Role == RolesEnum.CLIENT;
                model.SourceType = (int)FileSourceType.WorkRequest;
                model.ThumbPath  = Path.GetFileName(fileProject.PostedFile.FileName);
                model.IsDelete   = false;
                model.Tags       = txtTags.Text.Trim();
                bool result = true;
                if (id > 0)
                {
                    model.FileID = id;
                    result       = fileApp.UpdateFile(model);
                }
                else
                {
                    result = fileApp.AddFile(model) > 0 ? true : false;
                }
                if (!result)
                {
                    this.ShowFailMessageToClient(fileApp.BrokenRuleMessages, false);
                }
                else
                {
                    this.ShowSuccessMessageToClient();
                }
            }
            else
            {
                this.ShowFailMessageToClient("Please select a file");
            }
        }