Exemplo n.º 1
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <returns>bool</returns>
        public bool Update(DeptEmployee model)
        {
            bool result  = false;
            var  e       = new ModelExceptions();
            int  _rseult = instance.Update(model);

            if (_rseult > 0)
            {
                result = true;
            }
            return(result);
        }
Exemplo n.º 2
0
        public ActionResult SuccessfulCancelActingHead(FormCollection form)
        {
            int depID        = headService.FindDepID();
            int actingHeadID = headService.FindActingHeadID(depID);

            headService.CancelActingHead(actingHeadID);
            DeptEmployee depEmployee = db.DeptEmployees.Where(x => x.DeptEmployeeID == actingHeadID).First();
            string       name        = depEmployee.ToString();

            ViewBag.actingHead = name;
            return(View("~/Views/Department/Head/SuccessfulCancelActingHead.cshtml"));
        }
Exemplo n.º 3
0
        public ActionResult CreateRequisition()
        {
            CustomPrincipal user       = (CustomPrincipal)System.Web.HttpContext.Current.User;
            int             employeeId = user.UserID;
            DeptEmployee    Employee   = db.DeptEmployees.SingleOrDefault(d => d.DeptEmployeeID == employeeId);
            var             query      = (from item in db.Items
                                          select item).ToList();

            ViewBag.employee   = Employee;
            ViewBag.items      = query;
            ViewBag.employeeID = employeeId;
            return(View("~/Views/Department/Employee/CreateRequisition.cshtml"));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取指定的部门人员关系表 DeptEmployee对象集合
        /// </summary>
        public List <DeptEmployee> GetListByWhere(string strCondition)
        {
            List <DeptEmployee> ret = new List <DeptEmployee>();
            string sql = "SELECT  DE_ID,DE_Dept_Code,DE_Empoyee_Code,DE_Type,Stat FROM DeptEmployee WHERE 1=1 AND ((Stat is null) or (Stat=0) ) ";

            if (!string.IsNullOrEmpty(strCondition))
            {
                strCondition.Replace('\'', '"'); //防sql注入
                sql += strCondition;
            }
            SqlDataReader dr = null;

            try {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    DeptEmployee deptEmployee = new DeptEmployee();
                    if (dr["DE_ID"] != DBNull.Value)
                    {
                        deptEmployee.DE_ID = Convert.ToDecimal(dr["DE_ID"]);
                    }
                    if (dr["DE_Dept_Code"] != DBNull.Value)
                    {
                        deptEmployee.DE_Dept_Code = Convert.ToString(dr["DE_Dept_Code"]);
                    }
                    if (dr["DE_Empoyee_Code"] != DBNull.Value)
                    {
                        deptEmployee.DE_Empoyee_Code = Convert.ToString(dr["DE_Empoyee_Code"]);
                    }
                    if (dr["DE_Type"] != DBNull.Value)
                    {
                        deptEmployee.DE_Type = Convert.ToString(dr["DE_Type"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        deptEmployee.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                    ret.Add(deptEmployee);
                }
            }catch (System.Exception ex) { throw ex; }  finally { if (dr != null)
                                                                  {
                                                                      dr.Close();
                                                                  }
                                                                  if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open)
                                                                  {
                                                                      idb.GetConnection().Close();
                                                                  }
            }
            return(ret);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取实体数据
        /// </summary>
        /// <param name='strCondition'>条件(AND Code='11')</param>
        /// <returns>model</returns>
        public DeptEmployee GetModel(string strCondition)
        {
            List <DeptEmployee> list  = instance.GetListByWhere(strCondition);
            DeptEmployee        model = new DeptEmployee();

            if (list != null && list.Count > 0)
            {
                model = list[0];
            }
            else
            {
                model = null;
            }
            return(model);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <param name='model'>是否完成验证</param>
        /// <returns>bool</returns>
        public bool Insert(DeptEmployee model, bool IsValid)
        {
            var  e      = new ModelExceptions();
            bool result = false;

            if (e.IsValid && IsValid)
            {
                //完成了验证,开始更新数据库了
                int _result = instance.Add(model);
                if (_result > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 逻辑删除数据
        /// </summary>
        /// <param name='model'>model</param>
        /// <returns>bool</returns>
        public bool Delete(string Condition)
        {
            bool result = false;
            List <DeptEmployee> list = instance.GetListByWhere(Condition);

            if (list.Count > 0)
            {
                DeptEmployee model = list[0];
                model.Stat = 1;
                int _rseult = instance.Update(model);
                if (_rseult > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取指定的部门人员关系表 DeptEmployee对象(即:一条记录
        /// </summary>
        public DeptEmployee GetByKey(decimal dE_ID)
        {
            DeptEmployee deptEmployee = new DeptEmployee();
            string       sql          = "SELECT  DE_ID,DE_Dept_Code,DE_Empoyee_Code,DE_Type,Stat FROM DeptEmployee WHERE 1=1 AND ((Stat is null) or (Stat=0) )  AND DE_ID=@DE_ID ";

            idb.AddParameter("@DE_ID", dE_ID);

            SqlDataReader dr = null;

            try {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    if (dr["DE_ID"] != DBNull.Value)
                    {
                        deptEmployee.DE_ID = Convert.ToDecimal(dr["DE_ID"]);
                    }
                    if (dr["DE_Dept_Code"] != DBNull.Value)
                    {
                        deptEmployee.DE_Dept_Code = Convert.ToString(dr["DE_Dept_Code"]);
                    }
                    if (dr["DE_Empoyee_Code"] != DBNull.Value)
                    {
                        deptEmployee.DE_Empoyee_Code = Convert.ToString(dr["DE_Empoyee_Code"]);
                    }
                    if (dr["DE_Type"] != DBNull.Value)
                    {
                        deptEmployee.DE_Type = Convert.ToString(dr["DE_Type"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        deptEmployee.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                }
            }catch (System.Exception ex) { throw ex; }  finally { if (dr != null)
                                                                  {
                                                                      dr.Close();
                                                                  }
                                                                  if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open)
                                                                  {
                                                                      idb.GetConnection().Close();
                                                                  }
            }
            return(deptEmployee);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取所有的部门人员关系表 DeptEmployee对象(即:一条记录
        /// </summary>
        public List <DeptEmployee> GetAll()
        {
            List <DeptEmployee> ret = new List <DeptEmployee>();
            string        sql       = "SELECT  DE_ID,DE_Dept_Code,DE_Empoyee_Code,DE_Type,Stat FROM DeptEmployee where 1=1 AND ((Stat is null) or (Stat=0) ) order by DE_ID desc ";
            SqlDataReader dr        = null;

            try {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    DeptEmployee deptEmployee = new DeptEmployee();
                    if (dr["DE_ID"] != DBNull.Value)
                    {
                        deptEmployee.DE_ID = Convert.ToDecimal(dr["DE_ID"]);
                    }
                    if (dr["DE_Dept_Code"] != DBNull.Value)
                    {
                        deptEmployee.DE_Dept_Code = Convert.ToString(dr["DE_Dept_Code"]);
                    }
                    if (dr["DE_Empoyee_Code"] != DBNull.Value)
                    {
                        deptEmployee.DE_Empoyee_Code = Convert.ToString(dr["DE_Empoyee_Code"]);
                    }
                    if (dr["DE_Type"] != DBNull.Value)
                    {
                        deptEmployee.DE_Type = Convert.ToString(dr["DE_Type"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        deptEmployee.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                    ret.Add(deptEmployee);
                }
            }catch (System.Exception ex) { throw ex; }  finally { if (dr != null)
                                                                  {
                                                                      dr.Close();
                                                                  }
                                                                  if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open)
                                                                  {
                                                                      idb.GetConnection().Close();
                                                                  }
            }
            return(ret);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <returns>bool</returns>
        public bool Insert(DeptEmployee model)
        {
            bool result = false;

            try
            {
                int _result = instance.Add(model);
                if (_result > 0)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Exemplo n.º 11
0
        public List <Department> DepartmentsForItem(Item item, List <RequisitionDetail> pendingRequisitionDetails)
        {
            List <RequisitionDetail> requisitionDetails = pendingRequisitionDetails.Where(x => x.ItemID == item.ItemID).ToList();
            List <Requisition>       requisitions       = new List <Requisition>();
            List <DeptEmployee>      employees          = new List <DeptEmployee>();

            foreach (var reqDetail in requisitionDetails)
            {
                Requisition  requisition = db.Requisitions.Where(x => x.RequisitionID == reqDetail.RequisitionID).SingleOrDefault();
                DeptEmployee depEmployee = db.DeptEmployees.Where(x => x.DeptEmployeeID == requisition.EmployeeID).SingleOrDefault();
                employees.Add(depEmployee);
            }
            List <Department> departments = new List <Department>();

            foreach (var employee in employees)
            {
                Department department = db.Departments.Where(x => x.DepartmentID == employee.DepartmentID).SingleOrDefault();
                if (!departments.Contains(department))
                {
                    departments.Add(department);
                }
            }
            return(departments);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获取实体数据
        /// </summary>
        /// <param name='strCondition'>条件(AND Code='11')</param>
        /// <returns>model</returns>
        public DeptEmployee GetModel(int id)
        {
            DeptEmployee model = instance.GetByKey(id);

            return(model);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 添加部门人员关系表 DeptEmployee对象(即:一条记录)
        /// </summary>
        public object AddWithReturn(DeptEmployee deptEmployee)
        {
            string sql = "INSERT INTO DeptEmployee (DE_Dept_Code,DE_Empoyee_Code,DE_Type,Stat) VALUES (@DE_Dept_Code,@DE_Empoyee_Code,@DE_Type,@Stat);SELECT @@IDENTITY AS ReturnID;";

            if (string.IsNullOrEmpty(deptEmployee.DE_Dept_Code))
            {
                idb.AddParameter("@DE_Dept_Code", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@DE_Dept_Code", deptEmployee.DE_Dept_Code);
            }
            if (string.IsNullOrEmpty(deptEmployee.DE_Empoyee_Code))
            {
                idb.AddParameter("@DE_Empoyee_Code", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@DE_Empoyee_Code", deptEmployee.DE_Empoyee_Code);
            }
            if (string.IsNullOrEmpty(deptEmployee.DE_Type))
            {
                idb.AddParameter("@DE_Type", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@DE_Type", deptEmployee.DE_Type);
            }
            if (deptEmployee.Stat == 0)
            {
                idb.AddParameter("@Stat", 0);
            }
            else
            {
                idb.AddParameter("@Stat", deptEmployee.Stat);
            }


            int Re = 0;
            //SQL日志记录
            var RunMethod = System.Reflection.MethodBase.GetCurrentMethod();

            System.Collections.Hashtable param = new System.Collections.Hashtable();
            string Ex = "0";

            foreach (System.Collections.DictionaryEntry item in idb.GetParameters())
            {
                param.Add(item.Key, item.Value);
            }
            try
            {
                var Return = idb.ReturnValue(sql);
                Ex = Return.ToString();
            }
            catch (Exception ex)
            {
                Ex = ex.Message;
            }

            SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name, Ex);

            return(Re);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 更新部门人员关系表 DeptEmployee对象(即:一条记录
        /// </summary>
        public int Update(DeptEmployee deptEmployee)
        {
            StringBuilder sbParameter = new StringBuilder();
            StringBuilder sb          = new StringBuilder();

            sb.Append(@"UPDATE       DeptEmployee       SET ");
            if (deptEmployee.DE_Dept_Code_IsChanged)
            {
                sbParameter.Append("DE_Dept_Code=@DE_Dept_Code, ");
            }
            if (deptEmployee.DE_Empoyee_Code_IsChanged)
            {
                sbParameter.Append("DE_Empoyee_Code=@DE_Empoyee_Code, ");
            }
            if (deptEmployee.DE_Type_IsChanged)
            {
                sbParameter.Append("DE_Type=@DE_Type, ");
            }
            if (deptEmployee.Stat_IsChanged)
            {
                sbParameter.Append("Stat=@Stat ");
            }
            sb.Append(sbParameter.ToString().Trim().TrimEnd(','));
            sb.Append(" WHERE 1=1 AND ((Stat is null) or (Stat=0))   and DE_ID=@DE_ID; ");
            string sql = sb.ToString();

            if (deptEmployee.DE_Dept_Code_IsChanged)
            {
                if (string.IsNullOrEmpty(deptEmployee.DE_Dept_Code))
                {
                    idb.AddParameter("@DE_Dept_Code", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@DE_Dept_Code", deptEmployee.DE_Dept_Code);
                }
            }
            if (deptEmployee.DE_Empoyee_Code_IsChanged)
            {
                if (string.IsNullOrEmpty(deptEmployee.DE_Empoyee_Code))
                {
                    idb.AddParameter("@DE_Empoyee_Code", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@DE_Empoyee_Code", deptEmployee.DE_Empoyee_Code);
                }
            }
            if (deptEmployee.DE_Type_IsChanged)
            {
                if (string.IsNullOrEmpty(deptEmployee.DE_Type))
                {
                    idb.AddParameter("@DE_Type", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@DE_Type", deptEmployee.DE_Type);
                }
            }
            if (deptEmployee.Stat_IsChanged)
            {
                if (deptEmployee.Stat == 0)
                {
                    idb.AddParameter("@Stat", 0);
                }
                else
                {
                    idb.AddParameter("@Stat", deptEmployee.Stat);
                }
            }

            idb.AddParameter("@DE_ID", deptEmployee.DE_ID);


            int Re = 0;
            //SQL日志记录
            var RunMethod = System.Reflection.MethodBase.GetCurrentMethod();

            System.Collections.Hashtable param = new System.Collections.Hashtable();
            string Ex = "0";

            foreach (System.Collections.DictionaryEntry item in idb.GetParameters())
            {
                param.Add(item.Key, item.Value);
            }
            try
            {
                Re = idb.ExeCmd(sql);
                Ex = Re.ToString();
            }
            catch (Exception ex)
            {
                Ex = ex.Message;
            }

            SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name, Ex);

            return(Re);
        }