Example #1
0
        //修改
        private void btnPosEdit_Click(object sender, EventArgs e)
        {
            if (txtPosName.Text == "")
            {
                MessageBox.Show("请输入信息");
                return;
            }
            if (listPosition.SelectedItems.Count == 0)
            {
                return;
            }
            ListViewItem    item = listPosition.SelectedItems[0];
            companyPosition pos  = new companyPosition()
            {
                departmentId   = int.Parse(nudPosDepId.Value.ToString()),
                positionSalary = int.Parse(nudPosMoney.Value.ToString()),
                positionName   = txtPosName.Text
            };
            int id = int.Parse(item.Text);

            if (dataTools.updateTools.updateCompanyPosition(x => x.positionId == id, pos) == false)
            {
                MessageBox.Show("修改失败");
            }
            else
            {
                MessageBox.Show("修改成功");
                item.SubItems[1].Text = pos.departmentId.ToString();
                item.SubItems[2].Text = pos.positionName;
                item.SubItems[3].Text = pos.positionSalary.ToString();
            }
        }
 /// <summary>
 /// 往公司职务表中插入数据
 /// </summary>
 /// <param name="info"></param>
 /// <returns>插入数据后的对象</returns>
 public static bool insertCompanyPosition(companyPosition info)
 {
     try
     {
         using (employeeInfoSystemEntities db = new employeeInfoSystemEntities())
         {
             db.companyPosition.Add(info);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Example #3
0
 /// <summary>
 /// 查找公司职务信息
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <param name="whereLambda"></param>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public static companyPosition[] selectCompanyPosition <TKey>(Expression <Func <companyPosition, bool> > whereLambda, Expression <Func <companyPosition, TKey> > orderBy)
 {
     try
     {
         using (employeeInfoSystemEntities db = new employeeInfoSystemEntities())
         {
             DbQuery <companyPosition> dataObject = db.companyPosition.Where(whereLambda).OrderBy(orderBy) as DbQuery <companyPosition>;
             companyPosition[]         infoList   = dataObject.ToArray();
             return(infoList);
         }
     }
     catch
     {
         companyPosition[] nullInfo = new companyPosition[0];
         return(nullInfo);
     }
 }
 /// <summary>
 /// 修改companyPosition表的数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static bool updateCompanyPosition(Expression <Func <companyPosition, bool> > whereLambda, companyPosition info)
 {
     try
     {
         using (employeeInfoSystemEntities db = new employeeInfoSystemEntities())
         {
             DbQuery <companyPosition> dataObject = db.companyPosition.Where(whereLambda) as DbQuery <companyPosition>;
             companyPosition           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.departmentId   = info.departmentId;
             oldInfo.positionName   = info.positionName;
             oldInfo.positionSalary = info.positionSalary;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Example #5
0
        //添加
        private void btnPosAdd_Click(object sender, EventArgs e)
        {
            if (txtPosName.Text == "")
            {
                MessageBox.Show("请输入信息");
                return;
            }
            companyPosition pos = new companyPosition()
            {
                departmentId   = int.Parse(nudPosDepId.Value.ToString()),
                positionSalary = double.Parse(nudPosMoney.Value.ToString()),
                positionName   = txtPosName.Text
            };

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