Beispiel #1
0
        //删除科研人员投入的信息
        public void Delete(int staffdevoteid)
        {
            StaffDevote sd = dbcontext.StaffDevoteContext.Where(u => u.StaffDevoteID == staffdevoteid).FirstOrDefault();

            dbcontext.StaffDevoteContext.Attach(sd);
            dbcontext.StaffDevoteContext.Remove(sd);
            dbcontext.SaveChanges();
        }
Beispiel #2
0
 /// <summary>
 /// 录入科研人员投入时间,,向人员投入表中插入数据
 /// </summary>
 /// <param name="staff"></param>
 public bool Insert(StaffDevote staff)
 {
     dbcontext.Configuration.ValidateOnSaveEnabled = false;//关闭验证
     dbcontext.StaffDevoteContext.Add(staff);
     dbcontext.SaveChanges();
     dbcontext.Configuration.ValidateOnSaveEnabled = true;//保存完之后再开启
     return(true);
 }
Beispiel #3
0
 //将表中的审核状态变为False
 public bool ChangePass(int ProjectID, bool ispass)
 {
     try
     {
         StaffDevote project = dbcontext.StaffDevoteContext.Find(ProjectID);
         project.IsPass = ispass;
         dbcontext.SaveChanges();
         return(true);
     }
     catch (System.Data.SqlClient.SqlException e)
     {
         throw e;
     }
 }
Beispiel #4
0
 //更新IsPass状态
 public void UpdateIsPass(int ID, bool isPass)
 {
     try
     {
         StaffDevote NewStaffDevote = dbcontext.StaffDevoteContext.Find(ID);
         if (NewStaffDevote == null)
         {
             return;
         }
         NewStaffDevote.IsPass = isPass;
         dbcontext.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
Beispiel #5
0
 public void BindData()
 {
     try
     {
         List <StaffDevote> list      = bllStaffDevote.FindStaffDevoteID(Convert.ToInt32(Session["StaffDevoteID"].ToString()));
         StaffDevote        Important = list.FirstOrDefault();
         UserInfoName.Text = bllUser.FindByUserID(Convert.ToInt32(Important.UserInfoID.ToString()));
         DatePickerDevoteTime.SelectedDate      = Important.DevoteTime;
         DatePickerExitTime.SelectedDate        = Important.ExitTime;
         DropDownListProjectID.SelectedValue    = bllProject.FindByid(Convert.ToInt32(Important.ProjectID)).ProjectName;
         DropDownListSecrecyLevel.SelectedValue = Important.SecrecyLevel.ToString();
         DropDownListSort.SelectedIndex         = Convert.ToInt32(Important.Sort - 1);
         tb_ProjectCompletion.Text = Important.ProjectCompletion;
     }
     catch (Exception ex)
     {
         publicmethod.SaveError(ex, this.Request);;
     }
 }
Beispiel #6
0
 //修改科研人员投入的信息
 public void Update(StaffDevote sd)
 {
     try
     {
         StaffDevote nsd = dbcontext.StaffDevoteContext.Find(sd.StaffDevoteID);
         nsd.UserInfoID        = sd.UserInfoID;
         nsd.ProjectID         = sd.ProjectID;
         nsd.DevoteTime        = sd.DevoteTime;
         nsd.ExitTime          = sd.ExitTime;
         nsd.IsPass            = sd.IsPass;
         nsd.ProjectCompletion = sd.ProjectCompletion;
         nsd.SecrecyLevel      = sd.SecrecyLevel;
         nsd.EntryPerson       = sd.EntryPerson;
         dbcontext.SaveChanges();
     }
     catch (System.Data.SqlClient.SqlException e)
     {
         throw e;
     }
 }
Beispiel #7
0
 //保存
 protected void Save_Click(object sender, EventArgs e)
 {
     try
     {
         //if (UserInfoName.Text.Trim() != "")
         //{
         StaffDevote devote = new StaffDevote();
         if (bllUser.IsUser(UserInfoName.Text.Trim()) != null)
         {
             devote.UserInfoID = bllUser.FindID(UserInfoName.Text.Trim());
             devote.DevoteTime = DatePickerDevoteTime.SelectedDate;
             //if (DatePickerExitTime.SelectedDate.HasValue)
             //{
             //    if (DatePickerExitTime.SelectedDate < DatePickerDevoteTime.SelectedDate)
             //    {
             //        Alert.ShowInTop("退出时间不能小于开始时间!");
             //        return;
             //    }
             //    else
             devote.ExitTime = DatePickerExitTime.SelectedDate;
             //}
             devote.ProjectID         = bllProject.SelectProjectID(DropDownListProjectID.SelectedItem.Text);
             devote.SecrecyLevel      = DropDownListSecrecyLevel.SelectedIndex + 1;
             devote.Sort              = DropDownListSort.SelectedIndex + 1;
             devote.ProjectCompletion = tb_ProjectCompletion.Text.Trim();
             devote.EntryPerson       = bllStaffDevote.FindStaffDevoteID(Convert.ToInt32(Session["StaffDevoteID"])).FirstOrDefault().EntryPerson;
             if (Convert.ToInt32(Session["SecrecyLevel"]) != 5)
             {
                 devote.IsPass = false;
             }
             else
             {
                 devote.IsPass = true;
             }
             //原数据UserID
             int oldUserID = Convert.ToInt32(bllStaffDevote.FindStaffDevoteID(Convert.ToInt32(Session["StaffDevoteID"])).FirstOrDefault().UserInfoID);
             //原数据Sort序号
             int oldSort = Convert.ToInt32(bllStaffDevote.FindStaffDevoteID(Convert.ToInt32(Session["StaffDevoteID"])).FirstOrDefault().Sort);
             if (devote.Sort > 0 && devote.Sort <= 60)
             {
                 //判断人员名称和序号是否与原数据相同
                 if (devote.UserInfoID == oldUserID && devote.Sort == oldSort)
                 {
                     if (Convert.ToInt32(Session["SecrecyLevel"]) != 5)
                     {
                         bllStaffDevote.ChangePass(Convert.ToInt32(Session["StaffDevoteID"]), false); //改变原人员投入数据的状态
                         bllStaffDevote.Insert(devote);                                               //插入人员投入表
                         OperationLog operate = new OperationLog();
                         operate.LoginName        = devote.EntryPerson;
                         operate.OperationType    = "更新";
                         operate.OperationContent = "StaffDevote";
                         operate.OperationDataID  = Convert.ToInt32(Session["StaffDevoteID"]);   //原人员投入ID
                         operate.LoginIP          = "";
                         operate.OperationTime    = DateTime.Now;
                         operate.Remark           = devote.StaffDevoteID.ToString();
                         bllOperate.Insert(operate);    //插入操作日志表
                         //bllStaffDevote.ChangePass(Convert.ToInt32(Session["StaffDevoteID"]), false);//改变原人员投入数据的状态
                         PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("您的操作已提交审核,请等待!"));
                     }
                     else
                     {
                         devote.StaffDevoteID = Convert.ToInt32(Session["StaffDevoteID"]);
                         bllStaffDevote.Update(devote);    //更新人员投入表
                         PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("项目人员投入信息修改完成!"));
                     }
                 }
                 else
                 {
                     if (bllStaffDevote.IsNullUserInfoID(Convert.ToInt32(devote.UserInfoID.ToString()), Convert.ToInt32(devote.ProjectID.ToString())) == null)
                     {
                         if (bllStaffDevote.IsNullSort(Convert.ToInt32(devote.ProjectID.ToString()), Convert.ToInt32(devote.Sort)) == null)
                         {
                             //Alert.ShowInTop("人员已存在项目" + DropDownListProjectID.SelectedText);
                             if (Convert.ToInt32(Session["SecrecyLevel"]) != 5)
                             {
                                 bllStaffDevote.ChangePass(Convert.ToInt32(Session["StaffDevoteID"]), false); //改变原人员投入数据的状态
                                 bllStaffDevote.Insert(devote);                                               //插入人员投入表
                                 OperationLog operate = new OperationLog();
                                 operate.LoginName        = devote.EntryPerson;
                                 operate.OperationType    = "更新";
                                 operate.OperationContent = "StaffDevote";
                                 operate.OperationDataID  = Convert.ToInt32(Session["StaffDevoteID"]);   //原人员投入ID
                                 operate.LoginIP          = "";
                                 operate.OperationTime    = DateTime.Now;
                                 operate.Remark           = devote.StaffDevoteID.ToString();
                                 bllOperate.Insert(operate);    //插入操作日志表
                                 //bllStaffDevote.ChangePass(Convert.ToInt32(Session["StaffDevoteID"]), false);//改变原人员投入数据的状态
                                 PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("您的操作已提交审核,请等待!"));
                             }
                             else
                             {
                                 devote.StaffDevoteID = Convert.ToInt32(Session["StaffDevoteID"]);
                                 bllStaffDevote.Update(devote);    //更新人员投入表
                                 PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("项目人员投入信息修改完成!"));
                             }
                         }
                         else
                         {
                             if (bllStaffDevote.IsNullSort(Convert.ToInt32(devote.ProjectID.ToString()), Convert.ToInt32(devote.Sort)).IsPass == true)
                             {
                                 Alert.ShowInTop("序号为" + devote.Sort + "的人员已经存在于该项目");
                             }
                             else
                             {
                                 Alert.ShowInTop("序号为" + devote.Sort + "的人员正在审核");
                             }
                         }
                     }
                     else
                     {
                         if (bllStaffDevote.IsNullUserInfoID(Convert.ToInt32(devote.UserInfoID.ToString()), Convert.ToInt32(devote.ProjectID.ToString())).IsPass == true)
                         {
                             Alert.ShowInTop("人员" + UserInfoName.Text + "已存在项目" + DropDownListProjectID.SelectedText + "中");
                         }
                         if (bllStaffDevote.IsNullUserInfoID(Convert.ToInt32(devote.UserInfoID.ToString()), Convert.ToInt32(devote.ProjectID.ToString())).IsPass == false)
                         {
                             Alert.ShowInTop("人员" + UserInfoName.Text + "正在审核");
                         }
                     }
                 }
             }
             else
             {
                 Alert.ShowInTop("序号为1~60");
             }
         }
         else
         {
             Alert.ShowInTop("人员名称不存在");
         }
         //}
         //else
         //{
         //    Alert.ShowInTop("人员名称不能为空!");
         //    UserInfoName.Text = "";
         //    return;
         //}
     }
     catch (Exception ex)
     {
         publicmethod.SaveError(ex, this.Request);
     }
 }