Exemple #1
0
 //删除人员
 protected void Delete_OnClick(object sender, EventArgs e)
 {
     CheckBox cb;
     LabMS.BLL.Staff staff = new LabMS.BLL.Staff();
     try
     {
         for (int i = 0; i < gvStaffList.Rows.Count; i++)
         {
             cb = (CheckBox)gvStaffList.Rows[i].FindControl("StaffCB");
             if (cb.Checked)
             {
                 string SID = gvStaffList.DataKeys[i].Value.ToString();
                 staff.Delete(int.Parse(SID));
             }
         }
         BindGridViewList(SearchString());
         LabMS.Common.JShelper.JSAlert(Page, "deleteSuccess", "删除成功!");
     }
     catch
     {
         LabMS.Common.JShelper.JSAlert(Page, "err", "删除失败!");
     }
 }
Exemple #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", "添加失败!");
            }
        }
 //删除人员
 protected void Delete_OnClick(object sender, EventArgs e)
 {
     LabMS.BLL.Staff staff = new LabMS.BLL.Staff();
     try
     {
         staff.Delete(ID);
         LabMS.Common.JShelper.JSAlertAndRedirect(Page, "deleteSuccess", "删除成功!","ListStaff.aspx");
     }
     catch
     {
         LabMS.Common.JShelper.JSAlert(Page, "err", "删除失败!");
     }
 }