コード例 #1
0
 public ActionResult Signup(user User, string Department, string Designation, string gender)
 {
     if (User.UserName != "" || User.Name != "" || User.Password != "" || User.Email != "")
     {
         try
         {
             int         depid = int.Parse(Department);
             int         desid = int.Parse(Designation);
             department  dep   = db.Departments.FirstOrDefault(p => p.DepartmentId == depid);
             designation des   = db.Designations.FirstOrDefault(p => p.DesignationId == desid);
             status      st    = db.States.FirstOrDefault(p => p.StatusId == 1);
             string      role  = "Employ";
             User.Role        = role;
             User.Status      = st;
             User.Department  = dep;
             User.Designation = des;
             db.Users.Add(User);
             db.SaveChanges();
             return(Redirect("dashboard"));
         }
         catch (Exception ex)
         {
             ViewBag.errormsg = "Some Thing Went Wrong";
             return(Signup());
         }
     }
     return(Signup());
 }
コード例 #2
0
        private void dgDept_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            if (e.EditAction == DataGridEditAction.Commit)
            {
                department dept = e.Row.DataContext as department;

                var matchedData = (from dp in dbContext.department
                                   where dp.ID == dept.ID
                                   select dp).SingleOrDefault();
                if (matchedData == null)
                {
                    department rDepartment = new department();
                    rDepartment.departmentName = dept.departmentName;
                    rDepartment.organizationID = selectedOrgID;
                    dbContext.department.Add(rDepartment);
                    dbContext.SaveChanges();
                    dgDept.ItemsSource = GetDepartmentList(selectedOrgID);
                    txtStatus.Text     = rDepartment.departmentName + " has being added!";
                }
                else
                {
                    matchedData.departmentName = dept.departmentName;
                    dbContext.SaveChanges();
                    dgDept.ItemsSource = GetDepartmentList(selectedOrgID);
                    txtStatus.Text     = "Success. Info updated";
                }
            }
        }
コード例 #3
0
      public ActionResult create(department d)
      {
          e.Departments.Add(d);
          e.SaveChanges();

          return(RedirectToAction("index"));
      }
コード例 #4
0
        public ActionResult delete(int id)
        {
            department dep = departments.FirstOrDefault(s => s.id == id);

            departments.Remove(dep);
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public ActionResult CreateDepartment(department model)
        {
            using (DisDBContext db = new DisDBContext())
            {
                var newUser = User as CustomPrincipal;
                if (newUser != null)
                {
                    user _userAdmin = db.Users.FirstOrDefault(m => m.id == newUser.UserId && m.email == newUser.UserEmail);
                    if (_userAdmin != null)
                    {
                        if (_userAdmin.position == 1)
                        {
                            department companyDepartment = new department();
                            companyDepartment.dpt_name        = model.dpt_name;
                            companyDepartment.dpt_description = model.dpt_description;
                            companyDepartment.company_id      = _userAdmin.company_id;

                            db.SaveChanges();
                            return(Json("success", JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        return(Json("error", JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(RedirectToAction("AccessDenied", "Home"));
        }
コード例 #6
0
ファイル: DepartmentService.cs プロジェクト: Ang05/vehicle
        public int AddDepartment(department department)
        {
            _entity.department.Add(department);
            _entity.SaveChanges();

            return(department.department_id);
        }
コード例 #7
0
        public string update(department department)
        {
            try
            {
                us = new UserInfoService();
                string quanxian_save1 = us.new_quanxian("upd", "部门");
                if (quanxian_save1 != null && quanxian_save1.Length > 0 && quanxian_save1 == "是")
                {
                }
                else
                {
                    return(ResultUtil.error("没有权限!"));
                }


                ds = new DepartmentService();
                if (ds.update(department))
                {
                    return(ResultUtil.success("修改成功"));
                }
                else
                {
                    return(ResultUtil.error("修改失败"));
                }
            }
            catch (ErrorUtil err)
            {
                return(ResultUtil.fail(401, err.Message));
            }
            catch
            {
                return(ResultUtil.error("修改失败"));
            }
        }
コード例 #8
0
ファイル: DepartmentService.cs プロジェクト: Ang05/vehicle
        public void Update(department department)
        {
            var old = _entity.department.FirstOrDefault(e => e.department_id == department.department_id);

            _entity.Entry(old).CurrentValues.SetValues(department);
            _entity.SaveChanges();
        }
コード例 #9
0
        private List <TreeData> GetChildren(List <department> dp)
        {
            List <TreeData> td = new List <TreeData> ();

            if (dp == null || dp.Count <= 0)
            {
                return(td);
            }
            foreach (department d in dp)
            {
                department pd = Department.SelectByGuid(d.parentDepartment);
                td.Add(new TreeData()
                {
                    id = d.id, title = d.departmentName, ParentId = pd.id
                });
                List <TreeData> temptd = new List <TreeData> ();
                temptd = GetChildren(Department.SelectByDelFlag(d.guid, false));
                if (temptd == null || temptd.Count <= 0)
                {
                    continue;
                }
                foreach (TreeData rt in temptd)
                {
                    td.Add(rt);
                }
            }
            return(td);
        }
コード例 #10
0
        public static DepartmentVM FromDto(DepartmentVM parent, department d)
        {
            DepartmentVM vm = new DepartmentVM();

            vm.Id          = d.id;
            vm.Code        = d.code;
            vm.Description = d.description;
            if (d.jobPositions != null)
            {
                foreach (jobPosition jp in d.jobPositions)
                {
                    JobPositionVM jpVm = JobPositionConvertUtil.FromDto(jp);
                    jpVm.Department = vm;
                    vm.JobPositions.Add(jpVm);
                }
            }
            if (d.leader != null)
            {
                vm.Leader = new EmployeeVM();
                // vm.Leader
            }
            vm.Name = d.name;

            vm.ParentDepartment = parent;
            if (d.subDepartments != null)
            {
                foreach (department subD in d.subDepartments)
                {
                    DepartmentVM subVM = FromDto(vm, subD);
                    vm.SubDepartments.Add(subVM);
                }
            }
            return(vm);
        }
コード例 #11
0
        //新增
        public static int Add(department dep)
        {
            CKSJKEntities ck = new CKSJKEntities();

            ck.department.Add(dep);
            return(ck.SaveChanges());
        }
コード例 #12
0
        public static department ToDto(DepartmentVM value, bool keepTree = false)
        {
            department d = new department();

            d.description = value.Description;
            d.id          = value.Id;
            d.code        = value.Code;
            d.name        = value.Name;
            if (value.JobPositions != null)
            {
                d.jobPositions = new List <jobPosition>();

                foreach (var jp in value.JobPositions)
                {
                    d.jobPositions.Add(JobPositionConvertUtil.ToDto(jp));
                }
            }
            d.parentDepartmentId = value.ParentDepartment?.Id;
            if (value.Leader != null)
            {
                // EmployeeConverter emConverter = new EmployeeConverter();
                // d.leader = emConverter.Convert(value.Leader);
            }
            if (keepTree && value.SubDepartments != null && value.SubDepartments.Count > 0)
            {
                d.subDepartments = new List <department>();
                foreach (var item in value.SubDepartments)
                {
                    d.subDepartments.Add(ToDto(item, true));
                }
            }
            return(d);
        }
コード例 #13
0
ファイル: Form1.cs プロジェクト: OliverQnn/employeeInfoSystem
        //修改
        private void btnDepEdit_Click(object sender, EventArgs e)
        {
            if (listDepartment.SelectedItems.Count == 0)
            {
                return;
            }
            ListViewItem item = listDepartment.SelectedItems[0];

            if (txtDepName.Text == "")
            {
                MessageBox.Show("请输入信息");
                return;
            }
            department dep = new department()
            {
                departmentName = txtDepName.Text
            };
            int id = int.Parse(item.Text);

            if (dataTools.updateTools.updateDepartment(x => x.departmentId == id, dep) == false)
            {
                MessageBox.Show("修改失败");
            }
            else
            {
                MessageBox.Show("修改成功");
                item.SubItems[1].Text = txtDepName.Text;
            }
        }
コード例 #14
0
 private List <TreeData> GetDepartment()
 {
     try
     {
         List <department> dpl = Department.SelectByFlag(false);
         List <TreeData>   td  = new List <TreeData>();
         foreach (department d in dpl)
         {
             if (d != null)
             {
                 if (string.IsNullOrEmpty(d.parentDepartment))
                 {
                     td.Add(new TreeData()
                     {
                         id = d.id, ParentId = 0, title = d.departmentName
                     });
                 }
                 else
                 {
                     department pd = Department.SelectByGuid(d.parentDepartment);
                     td.Add(new TreeData()
                     {
                         id = d.id, ParentId = pd.id, title = d.departmentName
                     });
                 }
             }
         }
         return(td);
     }
     catch
     {
         return(new List <TreeData>());
     }
 }
コード例 #15
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] department dep)
        {
            if (id != dep.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dep);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!departmentsExists(dep.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dep));
        }
コード例 #16
0
ファイル: FirebirdSQLClass.cs プロジェクト: ruslan81/FIS
        public void LoadAllDepartments()
        {
            fb_con.Open();
            string     sql = "SELECT * FROM DEPARTMENTS ORDER BY ID";
            FbCommand  cmd = new FbCommand(sql, fb_con);
            department onedep;

            using (FbDataReader r = cmd.ExecuteReader())
            {
                int i;
                while (r.Read())
                {
                    i                 = 0;
                    onedep            = new department();
                    onedep.ID         = r.GetInt32(i++);
                    onedep.DEPARTMENT = r.GetString(i++);
                    onedep.NOTES      = r.GetString(i++);
                    onedep.CREATEWHO  = r.GetString(i++);
                    onedep.CREATEWHEN = r.GetString(i++);
                    onedep.CHANGEWHO  = r.GetString(i++);
                    onedep.CHANGEWHEN = r.GetString(i++);
                    departments.Add(onedep);
                }
            }
            fb_con.Close();
        }
コード例 #17
0
        public ActionResult update(int id, string name)
        {
            department dep = departments.FirstOrDefault(s => s.id == id);

            dep.name = name;
            return(RedirectToAction("Index"));
        }
コード例 #18
0
        public ActionResult Index()
        {
            var current_user = db_user.Users.FirstOrDefault(u => u.UserName == User.Identity.Name);

            if (HttpContext.User.IsInRole("admin"))
            {
                IEnumerable <department> department_list = db_certs.departments;
                ViewBag.departments = department_list;
                return(View());
            }
            else if (HttpContext.User.IsInRole("user"))
            {
                List <department> department_list = new List <department>();
                string[]          deps            = current_user.departmentID.Split(' ');

                foreach (string a in deps)
                {
                    if (a != "")
                    {
                        int        b   = Convert.ToInt16(a);
                        department des = db_certs.departments.FirstOrDefault(d => d.id == b);
                        department_list.Add(des);

                        ViewBag.departments = department_list;
                    }
                }
                //return RedirectToAction("view_department/"+current_user.departmentID, "Home");
                return(View());
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
コード例 #19
0
        public ActionResult Login(student model)
        {
            if (ModelState.IsValid)
            {
                var Username = db.students.FirstOrDefault(x => x.username == model.username && x.password == model.password);
                if (Username != null)
                {

                    faculty faculty = db.faculties.SingleOrDefault(f => f.facultyID == Username.facultyID);
                    department department = db.departments.SingleOrDefault(d => d.departmentID == Username.departmentID);
                    instructor instructor = db.instructors.SingleOrDefault(d => d.instructorID == Username.instructorID);


                    Session["StudentName"] = Username.stufullname;
                    Session["StudentNumber"] = Username.number;
                    Session["StudentDep"] = department.depname;
                    Session["StudentFac"] = faculty.facultyname;
                    Session["studepid"] = Username.departmentID;
                    Session["studentid"] = Username.studentID;
                    Session["stufoto"] = Username.image;
                    Session["stuinst"] = instructor.instfullname;
                    Session["curriculum"] = department.curriculum;
                    Session["Username"] = Username;
                    ViewBag.curriculum = department.curriculum;
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ViewBag.Message = "Username or password wrong!!!";
                }
            }

            return View(model);
        }
コード例 #20
0
        private List <DepartmentModel> GetDepartmentModel()
        {
            List <DepartmentModel> departmentmodellist = new List <DepartmentModel>();
            List <department>      departmentlist      = Department.SelectByFlag(false);

            if (departmentlist != null && departmentlist.Count > 0)
            {
                foreach (department d in departmentlist)
                {
                    department pd = new department();
                    pd.departmentName = "";
                    if (d.parentDepartment != "")
                    {
                        pd = Department.SelectByGuid(d.parentDepartment);
                    }

                    departmentmodellist.Add(new DepartmentModel()
                    {
                        delDepartment  = false,
                        parentname     = pd == null ? "" : pd.departmentName,
                        id             = d.id,
                        guid           = d.guid,
                        departmentName = d.departmentName,
                        comment        = d.comment
                    });
                }
            }
            return(departmentmodellist);
        }
コード例 #21
0
        public ResultHelper AddDepartment(DepartmentDto departmentDto)
        {
            try
            {
                if (IsThere(departmentDto))
                {
                    return(new ResultHelper(false, departmentDto.DepartmentID, ResultHelper.IsThereItem));
                }

                department item = new department();
                item.DepartmentID = departmentDto.DepartmentID;
                item.Description  = departmentDto.Description;
                item.Other        = departmentDto.Other;
                item.SubUnitID    = departmentDto.SubUnitID;
                item.Name         = departmentDto.Name;

                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    unitOfWork.GetRepository <department>().Insert(item);
                    unitOfWork.saveChanges();
                    return(new ResultHelper(true, item.DepartmentID, ResultHelper.SuccessMessage));
                }
            }
            catch (Exception ex)
            {
                return(new ResultHelper(false, departmentDto.DepartmentID, ResultHelper.UnSuccessMessage));
            }
        }
コード例 #22
0
        private void del_Click(object sender, RoutedEventArgs e)
        {
            var c = tvProperties.SelectedItem as PropertyNodeItem;

            if (c == null)
            {
                MessageAlert.Alert("请先选择要操作的部门");
                return;
            }

            department d = new department();

            if (c.Children.Count > 0)
            {
                MessageAlert.Alert("该部门存在子部门\n不能删除!");
                return;
            }
            if (MessageAlert.Alter("是否删除!"))
            {
                d = Department.SelectById(c.id.ToString());
                d.delDepartment = true;
                if (Department.Update(d))
                {
                    MessageAlert.Alert("删除成功!");
                }
            }
            lt.TreeLoad();
            this.dataGrid1.ItemsSource = GetDepartmentModel();
        }
コード例 #23
0
ファイル: DepartmentDAL.cs プロジェクト: sha0510/POS
        public void delete(department deleteItem)
        {
            department selectedItem = db.departments.First(item => item.id == deleteItem.id);

            db.departments.Remove(selectedItem);
            db.SaveChanges();
        }
コード例 #24
0
 public DepartmentDto GetDepartment(int departmentID)
 {
     try
     {
         using (UnitOfWork unitofWork = new UnitOfWork())
         {
             department item = new department();
             item = unitofWork.GetRepository <department>().GetById(x => x.DepartmentID == departmentID);
             DepartmentDto departmentDto = new DepartmentDto();
             departmentDto.DepartmentID      = item.DepartmentID;
             departmentDto.SubUnitID         = (int)item.SubUnitID;
             departmentDto.Name              = item.Name;
             departmentDto.Description       = item.Description;
             departmentDto.Other             = item.Other;
             departmentDto.DepartmentRoomDto = new DepartmentRoomDto();
             var depRoomDto = unitofWork.GetRepository <departmentroom>().GetById(x => x.DepartmentID == departmentID);
             if (depRoomDto != null)
             {
                 departmentDto.DepartmentRoomDto.DepartmentRoomID = depRoomDto.DepartmentRoomID;
                 departmentDto.DepartmentRoomDto.DepartmentID     = depRoomDto.DepartmentID.Value;
                 departmentDto.DepartmentRoomDto.RoomID           = depRoomDto.RoomID.Value;
             }
             return(departmentDto);
         }
     }
     catch (Exception ex)
     {
         return(new DepartmentDto());
     }
 }
コード例 #25
0
        public IHttpActionResult Putdepartment(int id, department department)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != department.ID)
            {
                return(BadRequest());
            }

            db.Entry(department).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!departmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #26
0
        public IHttpActionResult Postdepartment(department department)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.department.Add(department);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (departmentExists(department.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = department.ID }, department));
        }
コード例 #27
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            //获取输入内容
            string name = TextBox3.Text;

            if (name != "")
            {
                //创建实体类对象
                department department = new department();
                department.name = name;

                //通过linq技术添加对象到数据库
                myDBEntities myDBEntities = new myDBEntities();
                myDBEntities.department.Add(department);
                int result = myDBEntities.SaveChanges();

                //通过执行返回值判断是否添加成功
                if (result > 0)
                {
                    Label1.Text = "添加成功";
                }
                else
                {
                    Label1.Text = "添加失败";
                }
            }
            else
            {
                Label1.Text = "请输入添加的信息!";
            }
        }
コード例 #28
0
        // GET: departments/Details/5
        public ActionResult Details(int?id)
        {
            try
            {
                if (Session["role"] != null)
                {
                    if (Session["role"].ToString() == "ADM")
                    {
                        if (id == null)
                        {
                            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                        }

                        department department = db.departments.Find(id);
                        if (department == null)
                        {
                            return(HttpNotFound());
                        }
                        return(View(department));
                    }
                }
                else
                {
                    return(View("~/Views/LabTestResults/NotLoggedIn.cshtml"));
                }
            }
            catch (Exception genericException)
            {
                ViewBag.ExceptionMessage = genericException.Message;
            }
            return(View("~/Views/Errors/Details.cshtml"));
        }
コード例 #29
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            try
            {
                if (Session["role"] != null)
                {
                    if (Session["role"].ToString() == "ADM")
                    {
                        department department = await db.departments.FindAsync(id);

                        db.departments.Remove(department);
                        await db.SaveChangesAsync();

                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    return(View("~/Views/LabTestResults/NotLoggedIn.cshtml"));
                }
            }
            catch (DbUpdateException e)
            {
                ViewBag.DbExceptionMessage = e.Message;
            }
            catch (SqlException sqlException)
            {
                TempData["SqlException"] = sqlException.Message;
            }
            catch (Exception genericException)
            {
                TempData["SqlException"] = genericException.Message;
            }
            return(RedirectToAction("Delete", new { id = id }));
        }
コード例 #30
0
 void clear()
 {
     _depart = null;
     this.tbox_depart.Clear();
     this.cb_parentdep.SelectedIndex = 0;
     isadd = true;
 }
コード例 #31
0
 public void AddTodepartments(department department)
 {
     base.AddObject("departments", department);
 }
コード例 #32
0
ファイル: FirebirdSQLClass.cs プロジェクト: ShunkevichDV/FIS
 public void LoadAllDepartments()
 {
     fb_con.Open();
     string sql = "SELECT * FROM DEPARTMENTS ORDER BY ID";
     FbCommand cmd = new FbCommand(sql, fb_con);
     department onedep;
     using (FbDataReader r = cmd.ExecuteReader())
     {
         int i;
         while (r.Read())
         {
             i=0;
             onedep = new department();
             onedep.ID = r.GetInt32(i++);
             onedep.DEPARTMENT = r.GetString(i++);
             onedep.NOTES = r.GetString(i++);
             onedep.CREATEWHO = r.GetString(i++);
             onedep.CREATEWHEN = r.GetString(i++);
             onedep.CHANGEWHO = r.GetString(i++);
             onedep.CHANGEWHEN = r.GetString(i++);
             departments.Add(onedep);
         }
     }
     fb_con.Close();
 }
コード例 #33
0
 public static department Createdepartment(int department_id)
 {
     department department = new department();
     department.department_id = department_id;
     return department;
 }