예제 #1
0
        /// <summary>
        /// 修改公司就职信息选中项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPerEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Performance.SelectedItems.Count == 0)
                {
                    return;
                }
                ListViewItem item = Performance.SelectedItems[0];

                //先确定数据库中是否有修改后的职工
                employeeInfo[] isEmployee = dataTools.selectTools.selectEmployeeInfo(u => u.employeeId == nudPerId.Value, u => u.employeeId);
                if (isEmployee.Length == 0)
                {
                    MessageBox.Show("没有此员工,请输入正确的信息!");
                    return;
                }
                //确定数据库中是否有修改后的职位
                companyPosition[] isPosition = dataTools.selectTools.selectCompanyPosition(u => u.positionId == nudPerPosId.Value, u => u.positionId);
                if (isPosition.Length == 0)
                {
                    MessageBox.Show("没有此职位,请输入正确的信息!");
                    return;
                }

                employeePerformance performance = new employeePerformance()
                {
                    employeeId  = Convert.ToInt32(nudPerId.Value),
                    positionId  = Convert.ToInt32(nudPerPosId.Value),
                    performance = Convert.ToDouble(nudPerPerformance.Value),
                };
                int id = Convert.ToInt32(item.SubItems[0].Text);
                if (dataTools.updateTools.updateEmployeePerformance(x => x.employeeId == id, performance) == false)
                {
                    MessageBox.Show("修改失败");
                }
                else
                {
                    MessageBox.Show("修改成功");
                    item.SubItems[0].Text = performance.employeeId.ToString();
                    item.SubItems[1].Text = isEmployee[0].employeeName;
                    item.SubItems[2].Text = isPosition[0].positionId.ToString();
                    item.SubItems[3].Text = isPosition[0].positionName;
                    item.SubItems[4].Text = performance.performance.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("出错了!" + ex.ToString());
                return;
            }
        }
예제 #2
0
 /// <summary>
 /// 往公司职务表中插入数据
 /// </summary>
 /// <param name="info"></param>
 /// <returns>插入数据后的对象</returns>
 public static bool insertEmployeePerformance(employeePerformance info)
 {
     try
     {
         using (employeeInfoSystemEntities db = new employeeInfoSystemEntities())
         {
             db.employeePerformance.Add(info);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
예제 #3
0
 /// <summary>
 /// 查找公司就职信息
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <param name="whereLambda"></param>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public static employeePerformance[] selectEmployeePerformance <TKey>(Expression <Func <employeePerformance, bool> > whereLambda, Expression <Func <employeePerformance, TKey> > orderBy)
 {
     try
     {
         using (employeeInfoSystemEntities db = new employeeInfoSystemEntities())
         {
             DbQuery <employeePerformance> dataObject = db.employeePerformance.Where(whereLambda).OrderBy(orderBy) as DbQuery <employeePerformance>;
             employeePerformance[]         infoList   = dataObject.ToArray();
             return(infoList);
         }
     }
     catch
     {
         employeePerformance[] nullInfo = new employeePerformance[0];
         return(nullInfo);
     }
 }
예제 #4
0
 /// <summary>
 /// 修改employeePerformance表的数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static bool updateEmployeePerformance(Expression <Func <employeePerformance, bool> > whereLambda, employeePerformance info)
 {
     try
     {
         using (employeeInfoSystemEntities db = new employeeInfoSystemEntities())
         {
             DbQuery <employeePerformance> dataObject = db.employeePerformance.Where(whereLambda) as DbQuery <employeePerformance>;
             employeePerformance           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.positionId  = info.positionId;
             oldInfo.performance = info.performance;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
예제 #5
0
        /// <summary>
        /// 添加公司就职信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPerAdd_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(nudPerId.Value) == 0 || Convert.ToInt32(nudPerPosId.Value) == 0)
            {
                MessageBox.Show("请输入信息");
                return;
            }

            //先确定数据库中是否有此职工
            employeeInfo[] isEmployee = dataTools.selectTools.selectEmployeeInfo(u => u.employeeId == nudPerId.Value, u => u.employeeId);
            if (isEmployee.Length == 0)
            {
                MessageBox.Show("没有此员工,请输入正确的信息!");
                return;
            }

            //确定数据库中是否有此职位
            companyPosition[] isPosition = dataTools.selectTools.selectCompanyPosition(u => u.positionId == nudPerPosId.Value, u => u.positionId);
            if (isPosition.Length == 0)
            {
                MessageBox.Show("没有此职位,请输入正确的信息!");
                return;
            }

            employeePerformance employee = new employeePerformance()
            {
                employeeId  = Convert.ToInt32(nudPerId.Value),
                positionId  = Convert.ToInt32(nudPerPosId.Value),
                performance = Convert.ToDouble(nudPerPerformance.Value)
            };

            if (dataTools.insertTools.insertEmployeePerformance(employee) == false)
            {
                MessageBox.Show("添加失败");
            }
            else
            {
                MessageBox.Show("添加成功");
            }
        }