示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Buffer = true;
            Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
            Response.Expires = 0;
            Response.CacheControl = "no-cache";
            if (Request.QueryString["ID"] != null)
            {
                int StaffID = int.Parse(Request.QueryString["ID"]);
                LabMS.BLL.Staff staff = new LabMS.BLL.Staff();
                LabMS.Model.Staff staffinfo = new LabMS.Model.Staff();

                staffinfo = staff.GetModel(StaffID);
                byte[] PhotoArray = staffinfo.Staff_Photo;

                string PhotoType = staffinfo.Staff_PhotoType;
                if (PhotoArray.Length != 0)
                {
                    Response.ContentType = PhotoType;
                    Response.BinaryWrite(PhotoArray);
                    Response.End();
                }
            }
        }
示例#2
0
        protected void Submit_OnClick(object sender, EventArgs e)
        {
            #region 验证
            if (string.IsNullOrEmpty(StaffID.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "人员编号不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(StaffName.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "姓名不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(StaffBirth.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "出生年月不能为空!");
                return;
            }
            if (int.Parse(StaffLabDDL.SelectedValue.Trim()) == 0)
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "实验室不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(StaffSubject.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "所属学科不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(StaffTitle.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "职称不能为空!");
                return;
            }
            int temp = 0;
            if (!string.IsNullOrEmpty(StaffLabSeniority.Text.Trim()))
            {
                if (!int.TryParse(StaffLabSeniority.Text, out temp))
                {
                    LabMS.Common.JShelper.JSAlert(Page, "err", "实验室工龄必须为数字!");
                    return;
                }
            }
            if (!string.IsNullOrEmpty(StaffPaperNum.Text.Trim()))
            {
                if (!int.TryParse(StaffPaperNum.Text, out temp))
                {
                    LabMS.Common.JShelper.JSAlert(Page, "err", "论文数量必须为数字!");
                    return;
                }
            }
            if (!string.IsNullOrEmpty(StaffPublicationsNum.Text.Trim()))
            {
                if (!int.TryParse(StaffPublicationsNum.Text, out temp))
                {
                    LabMS.Common.JShelper.JSAlert(Page, "err", "著作数量必须为数字!");
                    return;
                }
            }
            HttpPostedFile upPhoto = ImageUpload.PostedFile;
            if (upPhoto.ContentLength > 2097152)
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "上传图片大小不能超过2MB");
                return;
            }
            //if (string.IsNullOrEmpty(StaffExpertLevel.SelectedValue))
            //{
            //    LabMS.Common.JShelper.JSAlert(Page, "err", "专家类别不能为空!");
            //    return;
            //}
            #endregion
            LabMS.Model.Staff staff = new LabMS.Model.Staff();
            LabMS.BLL.Staff staffinfo = new LabMS.BLL.Staff();

            staff.Staff_Code = StaffID.Text.Trim();//人员编号
            staff.Staff_Award = StaffAward.Text.ToString().Trim();//成果奖励
            staff.Staff_Birth = Convert.ToDateTime(StaffBirth.Text.Trim());//出生日期
            staff.Staff_Disciplines = tbDesciplineCode.Text.Trim();//主讲课程
            staff.Staff_Education = StaffEducationDDL.SelectedValue.Trim();//文化程度
            staff.Staff_Employ = StaffEmployDDL.SelectedValue.Trim();//任聘情况
            //string expertLevelList = "";
            //for (int i = 0; i < StaffExpertLevel.Items.Count; i++ )
            //{
            //    if (StaffExpertLevel.Items[i].Selected == true)
            //    {
            //        expertLevelList += StaffExpertLevel.Items[i].Value.Trim() + ";";//专家类别
            //    }
            //}
            //staff.Staff_ExpertLevel = expertLevelList.Substring(0, expertLevelList.Length-1);
            staff.Staff_ForeignLanguage = StaffForeignLanguage.Text.Trim();//一外语种
            staff.Staff_ForeignLevel = StaffForeignLevel.Text.Trim();//一外水平
            staff.Staff_GradInstution = StaffGradInstitution.Text.Trim();//毕业院校
            DateTime tempTime = new DateTime();
            if (DateTime.TryParse(StaffGraduteTime.Text.Trim(), out tempTime))
            {
                staff.Staff_GraduteTime = tempTime;//毕业时间
            }
            staff.Staff_Lab = int.Parse(StaffLabDDL.SelectedValue.Trim());//所属实验室

            int tempInt = new int();
            if (int.TryParse(StaffLabSeniority.Text.Trim(), out tempInt))
            {
                staff.Staff_LabSeniority = tempInt;//实验室工龄
            }
            if (DateTime.TryParse(StaffLabTime.Text.Trim(), out tempTime))
            {
                staff.Staff_LabTime = tempTime;//实验室工作时间
            }
            staff.Staff_Level = StaffLevelDDL.SelectedValue.Trim();//人员类别等级
            staff.Staff_Name = StaffName.Text.Trim();//姓名
            staff.Staff_PaperLevel = StaffPaperLevelDDL.SelectedValue.Trim();//论文级别
            if (int.TryParse(StaffPaperNum.Text.Trim(), out tempInt))
            {
                staff.Staff_PaperNum = tempInt;//论文数量
            }
            staff.Staff_PartTime = StaffPartTimeDDL.SelectedValue.Trim();//人员类别
            if (DateTime.TryParse(StaffPositionTime.Text.Trim(), out tempTime))
            {
                staff.Staff_PositionTime = tempTime;//评职时间
            }
            staff.Staff_Professional = StaffProfessional.Text.Trim();//专业方向
            staff.Staff_PublicationsLevel = StaffPublicationsLevelDDL.SelectedValue.Trim();//著作水平

            if (int.TryParse(StaffPublicationsNum.Text.Trim(), out tempInt))
            {
                staff.Staff_PublicationsNum = tempInt;//著作数量
            }
            staff.Staff_ResearchSub = StaffResearchSub.Text.Trim();//在研课题
            staff.Staff_Sex = StaffSexDDL.SelectedValue.Trim();//性别
            staff.Staff_Subject = tbSubjectCode.Text.Trim();//所属学科
            staff.Staff_SubjectLevel = StaffSubjectLevel.Text.Trim();//课题级别
            staff.Staff_Summary = StaffSummary.Text.Trim();//备注
            if (DateTime.TryParse(StaffTakeInJob.Text.Trim(), out tempTime))
            {
                staff.Staff_TakeInJob = tempTime;//参加工作时间
            }
            staff.Staff_Title = tbStaffTitleCode.Text.Trim();//职称
            staff.Staff_Work = StaffWorkDDL.SelectedValue.Trim();//主要工作
            staff.Staff_Workload = StaffWorkload.Text.Trim();//工作量

            //上传图片
            try
            {
                if (ImageUpload.HasFile)
                {
                    int upPhotoLength = upPhoto.ContentLength;
                    string PhotoContentType = upPhoto.ContentType;
                    byte[] PhotoArray = new byte[upPhotoLength];
                    Stream PhotoStream = upPhoto.InputStream;
                    PhotoStream.Read(PhotoArray, 0, upPhotoLength);

                    staff.Staff_Photo = PhotoArray;//相片
                    staff.Staff_PhotoType = PhotoContentType;//图片类型
                }
            }
            catch
            {
                LabMS.Common.JShelper.JSAlert(Page, "Picwrong", "程序错误:图片保存出错");
            }

            try
            {
                staffinfo.Add(staff);
                LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "添加成功!", "AddStaff.aspx");
            }
            catch
            {
                LabMS.Common.JShelper.JSAlert(Page, "AddFailed", "添加失败!");
            }
        }
示例#3
0
文件: Staff.cs 项目: dalinhuang/labms
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.Staff GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 ID,Staff_Code,Staff_Name,Staff_Sex,Staff_Birth,Staff_Lab,Staff_Education,Staff_GraduteTime,Staff_GradInstution,Staff_TakeInJob,Staff_Subject,Staff_Professional,Staff_LabSeniority,Staff_Title,Staff_Disciplines,Staff_PositionTime,Staff_Employ,Staff_LabTime,Staff_PaperNum,Staff_PaperLevel,Staff_PublicationsNum,Staff_PublicationsLevel,Staff_Work,Staff_Workload,Staff_ForeignLanguage,Staff_ForeignLevel,Staff_ResearchSub,Staff_SubjectLevel,Staff_Award,Staff_Level,Staff_PartTime,Staff_ExpertLevel,Staff_Photo,Staff_Summary,Staff_PhotoType from Staff ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = ID;

            LabMS.Model.Staff model = new LabMS.Model.Staff();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.Staff_Code = ds.Tables[0].Rows[0]["Staff_Code"].ToString();
                model.Staff_Name = ds.Tables[0].Rows[0]["Staff_Name"].ToString();
                model.Staff_Sex = ds.Tables[0].Rows[0]["Staff_Sex"].ToString();
                if (ds.Tables[0].Rows[0]["Staff_Birth"].ToString() != "")
                {
                    model.Staff_Birth = DateTime.Parse(ds.Tables[0].Rows[0]["Staff_Birth"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Staff_Lab"].ToString() != "")
                {
                    model.Staff_Lab = int.Parse(ds.Tables[0].Rows[0]["Staff_Lab"].ToString());
                }
                model.Staff_Education = ds.Tables[0].Rows[0]["Staff_Education"].ToString();
                if (ds.Tables[0].Rows[0]["Staff_GraduteTime"].ToString() != "")
                {
                    model.Staff_GraduteTime = DateTime.Parse(ds.Tables[0].Rows[0]["Staff_GraduteTime"].ToString());
                }
                model.Staff_GradInstution = ds.Tables[0].Rows[0]["Staff_GradInstution"].ToString();
                if (ds.Tables[0].Rows[0]["Staff_TakeInJob"].ToString() != "")
                {
                    model.Staff_TakeInJob = DateTime.Parse(ds.Tables[0].Rows[0]["Staff_TakeInJob"].ToString());
                }
                model.Staff_Subject = ds.Tables[0].Rows[0]["Staff_Subject"].ToString();
                model.Staff_Professional = ds.Tables[0].Rows[0]["Staff_Professional"].ToString();
                if (ds.Tables[0].Rows[0]["Staff_LabSeniority"].ToString() != "")
                {
                    model.Staff_LabSeniority = int.Parse(ds.Tables[0].Rows[0]["Staff_LabSeniority"].ToString());
                }
                model.Staff_Title = ds.Tables[0].Rows[0]["Staff_Title"].ToString();
                model.Staff_Disciplines = ds.Tables[0].Rows[0]["Staff_Disciplines"].ToString();
                if (ds.Tables[0].Rows[0]["Staff_PositionTime"].ToString() != "")
                {
                    model.Staff_PositionTime = DateTime.Parse(ds.Tables[0].Rows[0]["Staff_PositionTime"].ToString());
                }
                model.Staff_Employ = ds.Tables[0].Rows[0]["Staff_Employ"].ToString();
                if (ds.Tables[0].Rows[0]["Staff_LabTime"].ToString() != "")
                {
                    model.Staff_LabTime = DateTime.Parse(ds.Tables[0].Rows[0]["Staff_LabTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Staff_PaperNum"].ToString() != "")
                {
                    model.Staff_PaperNum = int.Parse(ds.Tables[0].Rows[0]["Staff_PaperNum"].ToString());
                }
                model.Staff_PaperLevel = ds.Tables[0].Rows[0]["Staff_PaperLevel"].ToString();
                if (ds.Tables[0].Rows[0]["Staff_PublicationsNum"].ToString() != "")
                {
                    model.Staff_PublicationsNum = int.Parse(ds.Tables[0].Rows[0]["Staff_PublicationsNum"].ToString());
                }
                model.Staff_PublicationsLevel = ds.Tables[0].Rows[0]["Staff_PublicationsLevel"].ToString();
                model.Staff_Work = ds.Tables[0].Rows[0]["Staff_Work"].ToString();
                model.Staff_Workload = ds.Tables[0].Rows[0]["Staff_Workload"].ToString();
                model.Staff_ForeignLanguage = ds.Tables[0].Rows[0]["Staff_ForeignLanguage"].ToString();
                model.Staff_ForeignLevel = ds.Tables[0].Rows[0]["Staff_ForeignLevel"].ToString();
                model.Staff_ResearchSub = ds.Tables[0].Rows[0]["Staff_ResearchSub"].ToString();
                model.Staff_SubjectLevel = ds.Tables[0].Rows[0]["Staff_SubjectLevel"].ToString();
                model.Staff_Award = ds.Tables[0].Rows[0]["Staff_Award"].ToString();
                model.Staff_Level = ds.Tables[0].Rows[0]["Staff_Level"].ToString();
                model.Staff_PartTime = ds.Tables[0].Rows[0]["Staff_PartTime"].ToString();
                model.Staff_ExpertLevel = ds.Tables[0].Rows[0]["Staff_ExpertLevel"].ToString();
                if (ds.Tables[0].Rows[0]["Staff_Photo"].ToString() != "")
                {
                    model.Staff_Photo = (byte[])ds.Tables[0].Rows[0]["Staff_Photo"];
                }
                model.Staff_Summary = ds.Tables[0].Rows[0]["Staff_Summary"].ToString();
                model.Staff_PhotoType = ds.Tables[0].Rows[0]["Staff_PhotoType"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }