public ActionResult Create([Bind(Include = "Eid,Ename,ESal,EGen,EDOB,Did")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Did = new SelectList(db.Departments, "Did", "Dname", employee.Did);
            return(View(employee));
        }
 protected internal bool Insert(Employee emp)
 {
     try
     {
         OE.Employees.Add(emp);
         OE.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
        protected internal bool Insert(Department dep)
        {
            try

            {
                OE.Departments.Add(dep);
                OE.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public void DeleteEmpliyee(string empid, string phone)
        {
            OrganizationEntities OE = new OrganizationEntities();
            var employee            = OE.EmployeeDetails.SingleOrDefault(x => x.EmployeeID == empid);

            OE.EmployeeDetails.Attach(employee);
            OE.EmployeeDetails.Remove(employee);
            OE.SaveChanges();
        }
        public void DeleteDepartment(string deptid, string empid)
        {
            OrganizationEntities OE = new OrganizationEntities();
            var dept = OE.DepartmentDetails.SingleOrDefault(x => x.DepartmentID == deptid);

            OE.DepartmentDetails.Attach(dept);
            OE.DepartmentDetails.Remove(dept);
            OE.SaveChanges();
        }
        public void UpdateDepartment(string depid, string depname, int totalemployees)
        {
            OrganizationEntities OE = new OrganizationEntities();
            var dept = OE.DepartmentDetails.SingleOrDefault(x => x.DepartmentID == depid);

            dept.DepartmentName = depname;
            dept.TotalEmployee  = totalemployees;
            OE.SaveChanges();
        }
        public void AddNewEmployee(int empid, string empname, string emailId, int phone, int salary, string city)
        {
            OrganizationEntities NewOE = new OrganizationEntities();
            var newEmp = new EmployeeDetail {
                EmployeeID = empid.ToString(), EmployeeName = empname, EmailID = emailId, Phone = phone.ToString(), Salary = Convert.ToInt32(salary), City = city
            };

            NewOE.EmployeeDetails.Add(newEmp);
            NewOE.SaveChanges();
        }
        public void AddNewDepartment(string depid, string depname, int totalemployees, string empid)
        {
            OrganizationEntities NewOE = new OrganizationEntities();
            var newDept = new DepartmentDetail {
                DepartmentID = depid, DepartmentName = depname, TotalEmployee = totalemployees, EmployeeID = empid
            };

            NewOE.DepartmentDetails.Add(newDept);
            NewOE.SaveChanges();
        }
        public void UpdateEmployee(string empid, string empname, string emailId, string phone, int salary, string city)
        {
            OrganizationEntities OE = new OrganizationEntities();
            var emp = OE.EmployeeDetails.SingleOrDefault(x => x.EmployeeID == empid);

            emp.EmployeeName = empname;
            emp.EmailID      = emailId;
            emp.Phone        = phone;
            emp.Salary       = salary;
            emp.City         = city;
            OE.SaveChanges();
        }
Beispiel #10
0
        protected internal bool Insert(string roleName)
        {
            try
            {
                AuthenticationLibrary.Model.Role obj = new AuthenticationLibrary.Model.Role();
                obj.RoleName = roleName;

                OE.Roles.Add(obj);
                OE.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        protected internal bool Insert(string userName, string password)
        {
            try
            {
                AuthenticationLibrary.Model.User obj = new AuthenticationLibrary.Model.User();
                obj.UserName = userName;
                obj.Password = password;

                OE.Users.Add(obj);
                OE.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #12
0
        protected internal bool Insert(AuthenticationLibrary.Model.User user, AuthenticationLibrary.Model.Role role)
        {
            try
            {
                AuthenticationLibrary.Model.UserRole obj = new AuthenticationLibrary.Model.UserRole();
                obj.Role = new AuthenticationLibrary.Model.Role {
                    RoleId = role.RoleId, RoleName = role.RoleName
                };
                obj.User = new AuthenticationLibrary.Model.User {
                    UserId = user.UserId, Password = user.Password, UserName = user.UserName
                };

                OE.UserRoles.Add(obj);
                OE.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }