示例#1
0
        //更新文件信息
        public void Update(object sender, EventArgs e)
        {
            try
            {
                projectFile              = bllProjectFile.FindByProjectFileId(Convert.ToInt32(Session["ProjectFileID"]), Convert.ToInt32(Session["SecrecyLevel"]));
                projectFile.FileCode     = txtFileCode.Text;
                projectFile.FileName     = txtFileName.Text.Trim();
                projectFile.FileType     = listFileType.SelectedText;
                projectFile.SecrecyLevel = listSecrecyLevel.SelectedIndex + 1;
                projectFile.EntryPerson  = bllUser.FindByLoginName(Session["LoginName"].ToString()).UserName;

                int    AttachmentID = bllProjectFile.FindAttachmentID(Convert.ToInt32(Session["ProjectFileID"]));
                string path         = bllAttachment.FindPath(AttachmentID);

                if (Convert.ToInt32(Session["SecrecyLevel"]) != 5)
                {
                    bllProjectFile.ChangePass(Convert.ToInt32(Session["ProjectFileID"]), false);
                    projectFile.IsPass            = false;
                    operationLog.LoginIP          = " ";
                    operationLog.LoginName        = Session["LoginName"].ToString();
                    operationLog.OperationType    = "更新";
                    operationLog.OperationContent = "ProjectFile";
                    operationLog.OperationTime    = DateTime.Now;

                    int attachid = publicMethod.UpLoadFile(fileupload).Attachid;
                    if (attachid != -3)//有值
                    {
                        switch (attachid)
                        {
                        case -1:
                            Alert.ShowInTop("文件类型不符,请重新选择!");
                            return;

                        case 0:
                            Alert.ShowInTop("文件名已经存在!");
                            return;

                        case -2:
                            Alert.ShowInTop("文件不能大于150M");
                            return;
                        }
                        projectFile.AttachmentID = attachid;//附件为新插入的附件ID
                    }
                    else//上传控件没有值
                    {
                        Alert.Show("没有上传文件!");
                        return;
                        //if (AttachmentID != 0)//原来有附件
                        //    projectFile.AttachmentID = AttachmentID;
                    }
                    bllProjectFile.InsertProjectFile(projectFile);//插入
                    operationLog.OperationDataID = Convert.ToInt32(Session["ProjectFileID"]);
                    operationLog.Remark          = projectFile.ProjectFileID.ToString();
                    bllOperationLog.Insert(operationLog);//将更新插入操作表
                    PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("文件信息已提交,正在等待审核!"));
                }
                else
                {
                    projectFile.IsPass = true;
                    int attachid = publicMethod.UpLoadFile(fileupload).Attachid;
                    if (attachid != -3)//上传控件是否有值
                    {
                        switch (attachid)
                        {
                        case -1:
                            Alert.ShowInTop("文件类型不符,请重新选择!");
                            return;

                        case 0:
                            Alert.ShowInTop("文件名已经存在!");
                            return;

                        case -2:
                            Alert.ShowInTop("文件不能大于150M");
                            return;
                        }
                        projectFile.AttachmentID = attachid;//附件为新插入的附件ID
                        publicMethod.DeleteFile(AttachmentID, path);
                    }
                    else //上传控件没有值
                    {
                        Alert.Show("没有上传文件!");
                        return;
                        //if (AttachmentID != 0)
                        //    projectFile.AttachmentID = AttachmentID;
                    }
                    bllProjectFile.Update(projectFile);//直接更新
                    PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("文件信息已更新完成!"));
                }
            }
            catch (Exception ex)
            {
                publicMethod.SaveError(ex, this.Request);
            }
        }