Exemplo n.º 1
0
        protected void photoupload_FileSelected(object sender, EventArgs e)

        {
            int AttachID = publicmethod.UpLoadPhoto(photoupload);

            switch (AttachID)
            {
            case -1:
                Alert.ShowInTop("照片类型不符,请重新选择!");
                return;

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

            case -2:
                Alert.ShowInTop("照片不能大于150M");
                return;

            case -3:
                Session["AttachID"] = null;
                break;

            //Alert.ShowInTop("请上传附件");
            //return;
            default:
            {
                Session["AttachID"] = AttachID;
                BLHelper.BLLAttachment att = new BLHelper.BLLAttachment();
                Image_show.ImageUrl = att.FindPath(AttachID);
                break;
            }
            }
        }
Exemplo n.º 2
0
        //上传,返回附件id
        public int UpLoad(FileUpload file)
        {
            string filepath = "~/Uploads/";

            BLHelper.BLLAttachment BLLattachment = new BLHelper.BLLAttachment();
            if (file.HasFile)
            {
                if (file.PostedFile.ContentLength < 5120000)
                {
                    string fileName      = file.ShortFileName;
                    string fileExtension = Path.GetExtension(fileName);


                    if (!ValidateFileType(fileExtension))
                    {
                        return(0);
                    }
                    if (Directory.Exists(System.Web.HttpContext.Current.Server.MapPath(filepath)) == false)//如果不存在就创建file文件夹
                    {
                        Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath(filepath));
                    }

                    fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_");
                    string FileName = DateTime.Now.Ticks.ToString() + "_" + fileName;

                    if (!BLLattachment.IsAttachmentName(fileName))
                    {
                        Common.Entities.Attachment attachment = new Common.Entities.Attachment();
                        //向附件表中插入数据
                        attachment.FileName = fileName;
                        attachment.FilePath = System.Web.HttpContext.Current.Server.MapPath(filepath) + FileName;
                        file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(filepath) + FileName);
                        BLLattachment.Insert(attachment);
                        return(Convert.ToInt32(attachment.AttachmentID));
                    }
                    else
                    {
                        //该文件名已存在
                        return(-1);
                    }
                }
                else
                {
                    //上传的文件不能大于50M
                    return(-2);
                }
            }
            else
            {
                return(-3);
            }
        }
Exemplo n.º 3
0
 //删除所选行数据
 protected void Delete_Click(object sender, EventArgs e)
 {
     BLHelper.BLLPatent           blpant  = new BLHelper.BLLPatent();
     BLHelper.BLLAttachment       blat    = new BLHelper.BLLAttachment();
     Common.Entities.OperationLog operate = new OperationLog();
     try
     {
         string username = user.FindByLoginName(Session["LoginName"].ToString()).UserName;
         if (Convert.ToInt32(Session["SecrecyLevel"]) == 5)
         {
             for (int i = 0; i < pm.GridCount(Grid_Patent, CBoxSelect).Count(); i++)
             {
                 int    ss               = Convert.ToInt32(Grid_Patent.DataKeys[pm.GridCount(Grid_Patent, CBoxSelect)[i]][0].ToString());
                 int[]  attachid         = blpant.Delete(ss);
                 string path_Patent      = blat.FindPath(attachid[0]);
                 string path_Application = blat.FindPath(attachid[1]);
                 pm.DeleteFile(attachid[0], path_Patent);
                 pm.DeleteFile(attachid[1], path_Application);
             }
             InitData();
             btnSelect_All.Text = "全选";
             Alert.ShowInTop("删除数据成功!");
             Delete.Enabled = false;
         }
         else
         {
             for (int i = 0; i < pm.GridCount(Grid_Patent, CBoxSelect).Count(); i++)
             {
                 blpant.UpdateIsPass(Convert.ToInt32(Grid_Patent.DataKeys[pm.GridCount(Grid_Patent, CBoxSelect)[i]][0]), false);
                 operate.LoginName        = username;
                 operate.OperationTime    = DateTime.Now;
                 operate.LoginIP          = " ";
                 operate.OperationContent = "Patents";
                 operate.OperationType    = "删除";
                 operate.OperationDataID  = Convert.ToInt32(Grid_Patent.DataKeys[pm.GridCount(Grid_Patent, CBoxSelect)[i]][0]);
                 op.Insert(operate);
             }
             InitData();
             btnSelect_All.Text = "全选";
             Alert.ShowInTop("您的数据已提交,请等待确认!");
             Delete.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         pm.SaveError(ex, this.Request);
         Alert.ShowInTop("删除错误,请联系管理员!");
     }
 }
Exemplo n.º 4
0
        //删除文件
        public void DeleteFile(int AttachId, string path)
        {
            BLHelper.BLLAttachment BLLattachment = new BLHelper.BLLAttachment();

            if (File.Exists(path))
            {
                FileInfo file = new FileInfo(path);
                if (file.Attributes.ToString().IndexOf("ReadOnly") != -1)
                {
                    file.Attributes = FileAttributes.Normal;
                }
                File.Delete(path);
            }
            BLLattachment.Delete(AttachId);
        }
Exemplo n.º 5
0
 //删除
 protected void btn_Delete_Click(object sender, EventArgs e)
 {
     BLHelper.BLLPaper        paper = new BLHelper.BLLPaper();
     BLHelper.BLLAttachment   blat  = new BLHelper.BLLAttachment();
     BLHelper.BLLOperationLog op    = new BLHelper.BLLOperationLog();
     try
     {
         int count = pm.GridCount(Grid_Paper, CBoxSelect).Count();
         if (count <= 0)
         {
             Alert.ShowInTop("请至少选择一项!");
             return;
         }
         string username = user.FindByLoginName(Session["LoginName"].ToString()).UserName;
         if (Convert.ToInt32(Session["SecrecyLevel"]) == 5)
         {
             for (int i = 0; i < pm.GridCount(Grid_Paper, CBoxSelect).Count(); i++)
             {
                 paper.Delete(Convert.ToInt32(Grid_Paper.DataKeys[pm.GridCount(Grid_Paper, CBoxSelect)[i]][0].ToString()));
             }
             InitData();
             Alert.ShowInTop("删除数据成功!");
             btn_Delete.Enabled = false;
         }
         else
         {
             Common.Entities.OperationLog operate = new OperationLog();
             for (int i = 0; i < pm.GridCount(Grid_Paper, CBoxSelect).Count(); i++)
             {
                 paper.UpdateIsPass(Convert.ToInt32(Grid_Paper.DataKeys[pm.GridCount(Grid_Paper, CBoxSelect)[i]][0]), false);
                 operate.LoginName        = username;
                 operate.OperationTime    = DateTime.Now;
                 operate.LoginIP          = " ";
                 operate.OperationContent = "Files";
                 operate.OperationType    = "删除";
                 operate.OperationDataID  = Convert.ToInt32(Grid_Paper.DataKeys[pm.GridCount(Grid_Paper, CBoxSelect)[i]][0]);
                 op.Insert(operate);
             }
             InitData();
             Alert.ShowInTop("您的数据已提交,请等待确认!");
         }
     }
     catch (Exception ex)
     {
         pm.SaveError(ex, this.Request);
         Alert.ShowInTop("删除失败,请联系管理员!");
     }
 }
Exemplo n.º 6
0
        //上传大文件,返回附件id
        public int UpLoad(System.Web.UI.WebControls.FileUpload file)
        {
            BLHelper.BLLAttachment BLLattachment = new BLHelper.BLLAttachment();

            foreach (UploadedFile files in RadUploadContext.Current.UploadedFiles)
            {
                string Path     = System.Web.HttpContext.Current.Server.MapPath(@"Uploads");
                string fileName = files.GetName().ToString();

                string Filename = DateTime.Now.Ticks.ToString() + "_" + files.GetName().ToString();
                //如果路径不存在,则创建
                if (System.IO.Directory.Exists(Path) == false)
                {
                    System.IO.Directory.CreateDirectory(Path);
                }
                if (!BLLattachment.IsAttachmentName(fileName))
                {
                    Common.Entities.Attachment attachment = new Common.Entities.Attachment();
                    //向附件表中插入数据
                    attachment.FileName = fileName;
                    attachment.FilePath = Path + Filename;
                    Path = Path + "/" + Filename;
                    //保存
                    files.SaveAs(Path, true);

                    BLLattachment.Insert(attachment);
                    return(attachment.AttachmentID);
                }
                else
                {
                    //该文件名已存在
                    return(0);
                }
            }
            //没存
            return(-1);
        }
Exemplo n.º 7
0
        //文件上传
        public FileUpLoad UpLoadFile(HtmlInputFile InputFile)
        {
            //文件路径
            string filepath = "~/Uploads/";

            FileUpLoad fp = new FileUpLoad();
            string     fileName, fileExtension;
            //
            //建立上传对象
            //
            HttpPostedFile postedFile = InputFile.PostedFile;

            fileName      = System.IO.Path.GetFileName(postedFile.FileName);
            fileExtension = System.IO.Path.GetExtension(fileName);

            if (fileName == "")
            {
                fp.Attachid = -3;
                return(fp);
            }
            //上传文件大小
            int i = 100;

            if (InputFile.PostedFile.ContentLength > i * 1024 * 1024)
            {
                fp.Attachid = -2;
                return(fp);
            }
            //根据类型确定文件格式
            if (!ValidateFileType(fileExtension))
            {
                //无效的文件类型
                fp.Attachid = -1;
                return(fp);
            }
            string phyPath = HttpContext.Current.Request.MapPath(filepath);

            //判断路径是否存在,若不存在则创建路径
            DirectoryInfo upDir = new DirectoryInfo(phyPath);

            if (!upDir.Exists)
            {
                upDir.Create();
            }

            //
            //保存文件
            //
            try
            {
                BLHelper.BLLAttachment blat = new BLHelper.BLLAttachment();
                if (!blat.IsAttachmentName(fileName))
                {
                    fp.FilePath      = HttpContext.Current.Request.MapPath(filepath) + fileName;
                    fp.FileExtension = fileExtension;
                    fp.FileName      = fileName;
                    fileName         = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_");
                    string Filename = DateTime.Now.Ticks.ToString() + "_" + fileName;

                    //插入附件表
                    Common.Entities.Attachment at = new Common.Entities.Attachment();
                    at.FileName = System.IO.Path.GetFileName(postedFile.FileName);
                    at.FilePath = filepath + Filename;
                    blat.Insert(at);
                    fp.Attachid = at.AttachmentID;
                    postedFile.SaveAs(phyPath + Filename);
                    return(fp);
                }
                else
                {
                    fp.Attachid = 0;
                    return(fp);
                }
            }
            catch
            {
                throw new ApplicationException("上传失败!");
            }
        }
Exemplo n.º 8
0
        public void BindData()
        {
            try
            {
                UserInfo user = bllUser.Find(Convert.ToInt32(Session["UserInfoID"]), true);
                T_UserName.Text = user.UserName;
                if (user.Sex == true)
                {
                    rbtnBoy.Checked = true;
                }
                else
                {
                    rbtnGril.Checked = true;
                }
                DropDownListNation.SelectedValue = user.Nation;
                T_Hometown.Text = user.Hometown;
                DatePickerBirth.SelectedDate = user.Birth;
                T_JobTitle.Text = user.JobTitle;
                DropDownListAgencyP.SelectedValue = bllAgency.FindAgenName(user.AgencyID);
                T_Telenum.Text      = user.TeleNum;
                T_HomeTetlum.Text   = user.HomeNum;
                T_Officenum.Text    = user.OfficeNum;
                T_DocumentsNum.Text = user.DocumentsNum;
                DropDownListDocumentsType.SelectedValue   = user.DocumentsType;
                DropDownListPoliticalStatus.SelectedValue = user.PoliticalStatus;
                ////NewUser.Profile = null;
                DropDownListEducation.SelectedValue = user.Education;
                DropDownListDegree.SelectedValue    = user.Degree;
                DropDownListStaffType.SelectedValue = user.StaffType;
                T_Specilty.Text = user.Specialty;

                //图片加载
                BLHelper.BLLAttachment att = new BLHelper.BLLAttachment();
                Image_show.ImageUrl = att.FindPath(user.PhotoID);
                if (user.Marriage == true)
                {
                    ISMarriage.Checked = true;
                }
                else
                {
                    NotMarriage.Checked = true;
                }

                T_Fax.Text         = user.Fax;
                T_HomeAddress.Text = user.HomeAddress;
                T_PostalCode.Text  = user.PostalCode;
                T_QQnum.Text       = user.qqNum;
                T_Remark.Text      = user.Remark;
                T_UnitName.Text    = user.UnitName;
                //T_StaffType.Text = user.StaffType;
                //T_UserInfoBH.Text = user.UserInfoBH;
                T_LoginName.Text = user.LoginName;
                T_Email.Text     = user.Email;
                T_Telenum.Text   = user.TeleNum;
                DropDownListAdmin.SelectedValue = user.AdministrativeLevelName;
                T_Domicile.Text = user.Domicile;
                DropDownListSubjectSortP.SelectedValue = user.SubjectSortName;
                DatePickerJobTitleTime.SelectedDate    = user.JobTitleTime;
                TextAreaProfile.Text = user.Profile;
                DatePickerPoliticalStatusTime.SelectedDate = user.PoliticalStatusTime;
                if (user.IsDocdorTeacher == true)
                {
                    IsDoctorTeacher.Checked = true;
                }
                else
                {
                    NotDoctorTeacher.Checked = true;
                }
                if (user.IsMasteTeacher == true)
                {
                    IsMasterTeacher.Checked = true;
                }
                else
                {
                    NotMasterTeacher.Checked = true;
                }
                DatePickerMasterTeacherTime.SelectedDate = user.MasterTeacherTime;
                DatePickerDoctorTeacherTime.SelectedDate = user.DoctorTeacherTime;
                DropDownListSecrecyLevel.SelectedIndex   = Convert.ToInt32(user.SecrecyLevel) - 1;
                T_Reserch.Text  = user.ResearchDirection;
                LastSchool.Text = user.LastSchool;
                DatePickerEnterSchoolTime.SelectedDate = user.EnterSchoolTime; //入校时间;
                DropDownListStudySource.SelectedValue  = user.StudySource;     //学缘
            }
            catch (Exception ex)
            {
                publicmethod.SaveError(ex, this.Request);
            }
        }