Esempio n. 1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <typeparam name="T">泛型</typeparam>
        /// <param name="entity">泛型类型对象</param>
        /// <returns>影响行数</returns>
        public int comDel <T>(T entity)
        {
            int result = 0;

            fin.Set(entity.GetType()).Remove(entity);
            try
            {
                result = fin.SaveChanges();
            }
            catch (Exception ex)
            {
                FinanceToError.getFinanceToError().toError();
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 新增部门
        /// </summary>
        /// <param name="department">部门对象</param>
        /// <returns>影响行数</returns>
        public int newDepartment(Department department)
        {
            fin.Department.Add(department);
            int result = 0;

            try
            {
                result = fin.SaveChanges();
            }
            catch (Exception ex)
            {
                FinanceToError.getFinanceToError().toError();
            }
            return(result);
        }
Esempio n. 3
0
        public int updAccounting(Accounting accounting)
        {
            //新的实体类添加到上下文
            fin.Accounting.Attach(accounting);
            //手动修改状态
            fin.Entry <Accounting>(accounting).State = EntityState.Modified;
            int result = 0;

            try
            {
                //保存修改
                result = fin.SaveChanges();
            }
            catch (Exception ex)
            {
                FinanceToError.getFinanceToError().toError();
            }
            return(result);
        }
Esempio n. 4
0
        public int delUser(int id)
        {
            List <Account> list    = fin.Account.Where(u => u.id == id).ToList();
            string         bianhao = list[0].bianhao;

            List <quanxian> list2      = fin.quanxian.Where(u => u.bianhao == bianhao).ToList();
            int             quanxianid = list2[0].id;
            quanxian        quan       = fin.quanxian.Find(quanxianid);

            fin.quanxian.Remove(quan);

            fin.Account.Remove(this.findUser(id));
            int result = 0;

            try
            {
                result = fin.SaveChanges();
            }
            catch (Exception ex)
            {
                FinanceToError.getFinanceToError().toError();
            }
            return(result);
        }