public ActionResult Create([Bind(Include = "id,depart_name")] Departament departament, List <string> designation)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (ModelState.IsValid)
            {
                Departament new_departament = new Departament()
                {
                    depart_name = departament.depart_name
                };
                db.Departaments.Add(new_departament);
                for (int a = 0; a < designation.Count; a++)
                {
                    Designation new_designation = new Designation()
                    {
                        desig_name = designation[a],
                        depart_id  = new_departament.id
                    };
                    db.Designations.Add(new_designation);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(Content(departament.depart_name));
        }
Ejemplo n.º 2
0
 // GET: Adminpanel/Holidays
 public ActionResult Index()
 {
     if (!AdminpanelMethods.CheckAdminLogin())
     {
         return(RedirectToAction("Index", "Login"));
     }
     return(View(db.Holidays.OrderByDescending(h => h.id).ToList()));
 }
 // GET: Adminpanel/Departaments
 public ActionResult Index()
 {
     if (!AdminpanelMethods.CheckAdminLogin())
     {
         return(RedirectToAction("Index", "Login"));
     }
     return(View(db.Departaments.ToList()));
 }
 // GET: Adminpanel/Home
 public ActionResult Index()
 {
     if (!AdminpanelMethods.CheckAdminLogin())
     {
         return(RedirectToAction("Index", "Login"));
     }
     return(View());
 }
 // GET: Adminpanel/Awards/Create
 public ActionResult Create()
 {
     if (!AdminpanelMethods.CheckAdminLogin())
     {
         return(RedirectToAction("Index", "Login"));
     }
     ViewBag.award_emp_id = new SelectList(db.Employees, "id", "emp_fullname");
     return(View());
 }
Ejemplo n.º 6
0
        // GET: Adminpanel/Attendences
        public ActionResult Index()
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            var attendences = db.Employees.Include(a => a.Attendences);

            return(View(attendences.ToList()));
        }
        // GET: Adminpanel/Employees
        public ActionResult Index()
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            var employees = db.Employees.Include(e => e.Departament).Include(e => e.Designation).Include(e => e.Gender).OrderByDescending(e => e.id);

            return(View(employees.ToList()));
        }
 // GET: Adminpanel/Employees/Create
 public ActionResult Create()
 {
     if (!AdminpanelMethods.CheckAdminLogin())
     {
         return(RedirectToAction("Index", "Login"));
     }
     ViewBag.emp_dep_id    = new SelectList(db.Departaments, "id", "depart_name");
     ViewBag.emp_desig_id  = new SelectList(db.Designations, "id", "desig_name");
     ViewBag.emp_gender_id = new SelectList(db.Genders, "id", "gender_name");
     return(View());
 }
Ejemplo n.º 9
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            Attendence attendence = db.Attendences.Find(id);

            db.Attendences.Remove(attendence);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            Award award = db.Awards.Find(id);

            db.Awards.Remove(award);
            db.SaveChanges();
            return(Json(new { success = "deleted" }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        // GET: Adminpanel/Attendences/Create
        public ActionResult Create()
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            List <Employee>   employeers  = db.Employees.ToList();
            List <Leave_type> leave_types = db.Leave_type.ToList();

            return(View(new CreateAttendence {
                Employee = employeers, Leave_type = leave_types
            }));
        }
Ejemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "id,holiday_name,holiday_date")] Holiday holiday)
 {
     if (!AdminpanelMethods.CheckAdminLogin())
     {
         return(RedirectToAction("Index", "Login"));
     }
     if (ModelState.IsValid)
     {
         db.Entry(holiday).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(holiday));
 }
Ejemplo n.º 13
0
        public ActionResult Create([Bind(Include = "id,holiday_name,holiday_date")] Holiday holiday)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (ModelState.IsValid)
            {
                db.Holidays.Add(holiday);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(holiday));
        }
        // GET: Adminpanel/Departaments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            db.Configuration.ProxyCreationEnabled = false;
            var designations = db.Designations.Where(d => d.depart_id == id).Select(d => new { id = d.id, name = d.desig_name }).ToList();

            return(Json(designations, JsonRequestBehavior.AllowGet));
        }
 public ActionResult Edit([Bind(Include = "id,award_emp_id,award_name,award_reason,award_cash_price,award_date")] Award award)
 {
     if (!AdminpanelMethods.CheckAdminLogin())
     {
         return(RedirectToAction("Index", "Login"));
     }
     if (ModelState.IsValid)
     {
         db.Entry(award).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.award_emp_id = new SelectList(db.Employees, "id", "emp_fullname", award.award_emp_id);
     return(View(award));
 }
Ejemplo n.º 16
0
 public ActionResult Edit([Bind(Include = "id,atten_emp_id,atten_status,atten_leave_type_id,atten_date,atten_reason")] Attendence attendence)
 {
     if (!AdminpanelMethods.CheckAdminLogin())
     {
         return(RedirectToAction("Index", "Login"));
     }
     if (ModelState.IsValid)
     {
         db.Entry(attendence).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.atten_emp_id        = new SelectList(db.Employees, "id", "emp_fullname", attendence.atten_emp_id);
     ViewBag.atten_leave_type_id = new SelectList(db.Leave_type, "id", "type_name", attendence.atten_leave_type_id);
     return(View(attendence));
 }
        public ActionResult DeleteConfirmed(int id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            Employee employee = db.Employees.Find(id);

            if (System.IO.File.Exists(@"~/Areas/Adminpanel/Uploads/" + employee.emp_photo))
            {
                System.IO.File.Delete(@"~/Areas/Adminpanel/Uploads/" + employee.emp_photo);
            }
            db.Employees.Remove(employee);
            db.SaveChanges();
            return(Json(new { success = "deleted" }));
        }
Ejemplo n.º 18
0
        // GET: Adminpanel/Holidays/Details/5
        public ActionResult Details(int?id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Holiday holiday = db.Holidays.Find(id);

            if (holiday == null)
            {
                return(HttpNotFound());
            }
            return(View(holiday));
        }
        // GET: Adminpanel/Departaments/Details/5
        public ActionResult Details(int?id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Departament departament = db.Departaments.Find(id);

            if (departament == null)
            {
                return(HttpNotFound());
            }
            return(View(departament));
        }
Ejemplo n.º 20
0
        // GET: Adminpanel/Attendences/Details/5
        public ActionResult Details(int?id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Attendence attendence = db.Attendences.Find(id);

            if (attendence == null)
            {
                return(HttpNotFound());
            }
            return(View(attendence));
        }
Ejemplo n.º 21
0
        // GET: Adminpanel/Holidays/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Holiday holiday = db.Holidays.Find(id);

            if (holiday == null)
            {
                return(HttpNotFound());
            }
            return(Json(new { name = holiday.holiday_name, date = string.Format("{0:yyyy-MM-dd}", holiday.holiday_date) }, JsonRequestBehavior.AllowGet));
        }
        // GET: Adminpanel/Employees/Delete/5
        public ActionResult Delete(int?id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employee employee = db.Employees.Find(id);

            if (employee == null)
            {
                return(HttpNotFound());
            }
            return(View(employee));
        }
        // GET: Adminpanel/Awards/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Award award = db.Awards.Find(id);

            if (award == null)
            {
                return(HttpNotFound());
            }
            ViewBag.award_emp_id = new SelectList(db.Employees, "id", "emp_fullname", award.award_emp_id);
            return(View(award));
        }
Ejemplo n.º 24
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            Holiday holiday = db.Holidays.Find(id);

            if (holiday == null)
            {
                return(HttpNotFound());
            }
            else
            {
                db.Holidays.Remove(holiday);
                db.SaveChanges();
                return(Json(new { success = "deleted" }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Edit(int deptId, string deptName, List <string> designation_id, List <string> designation)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            var departament = db.Departaments.Find(deptId);

            departament.depart_name = deptName;

            //bu for dongusu databazada var olan designationlari silmek ve editlemek ucundur
            if (designation_id != null && designation_id.Count != 0)
            {
                for (int a = 0; a < designation_id.Count; a++)
                {
                    if (designation[a] != "")
                    {
                        int         des_id             = Convert.ToInt32(designation_id[a]);
                        Designation single_designation = db.Designations.Where(d => d.id == des_id).SingleOrDefault();
                        single_designation.desig_name = designation[a];
                    }
                    else
                    {
                        int des_id = Convert.ToInt32(designation_id[a]);
                        db.Designations.Remove(db.Designations.Find(des_id));
                    }
                    b++;
                }
            }
            //bu for dongusu ise databazada var olmayan yeni elave olunacaq designationlari elave etmek ucundur
            for (int a = b; a < designation.Count; a++)
            {
                Designation new_designation = new Designation()
                {
                    depart_id  = deptId,
                    desig_name = designation[a]
                };
                db.Designations.Add(new_designation);
            }
            db.SaveChanges();
            return(RedirectToAction("Index", "Departaments"));
        }
Ejemplo n.º 26
0
        // GET: Adminpanel/Attendences/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Attendence attendence = db.Attendences.Find(id);

            if (attendence == null)
            {
                return(HttpNotFound());
            }
            ViewBag.atten_emp_id        = new SelectList(db.Employees, "id", "emp_fullname", attendence.atten_emp_id);
            ViewBag.atten_leave_type_id = new SelectList(db.Leave_type, "id", "type_name", attendence.atten_leave_type_id);
            return(View(attendence));
        }
        // GET: Adminpanel/Employees/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employee employee = db.Employees.Find(id);

            if (employee == null)
            {
                return(HttpNotFound());
            }
            ViewBag.emp_dep_id    = new SelectList(db.Departaments, "id", "depart_name", employee.emp_dep_id);
            ViewBag.emp_desig_id  = new SelectList(db.Designations, "id", "desig_name", employee.emp_desig_id);
            ViewBag.emp_gender_id = new SelectList(db.Genders, "id", "gender_name", employee.emp_gender_id);
            return(View(employee));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Departament departament = db.Departaments.Find(id);

            if (departament == null)
            {
                return(HttpNotFound());
            }
            else
            {
                db.Departaments.Remove(departament);
                db.SaveChanges();
                return(Json(new { success = "deleted" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 29
0
        public ActionResult Create(List <int> leaveType, List <string> reasonText, List <int> empId)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            var all_employers = db.Employees.ToList();

            foreach (var item in all_employers)
            {
                Attendence new_attendence = new Attendence();
                new_attendence.atten_date   = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                new_attendence.atten_emp_id = item.id;
                new_attendence.atten_status = true;
                if (empId != null)
                {
                    for (int a = 0; a < leaveType.Count; a++)
                    {
                        if (item.id == empId[a])
                        {
                            new_attendence.atten_leave_type_id = leaveType[a];
                            new_attendence.atten_status        = false;
                            new_attendence.atten_reason        = reasonText[a];
                        }
                    }
                }
                db.Attendences.Add(new_attendence);
            }
            db.SaveChanges();

            List <Employee>   employeers  = db.Employees.ToList();
            List <Leave_type> leave_types = db.Leave_type.ToList();

            return(View(new CreateAttendence {
                Employee = employeers, Leave_type = leave_types
            }));
        }
        public ActionResult Create([Bind(Include = "emp_fullname,emp_fathername,emp_dateof_birth,emp_gender_id,emp_phone,emp_address,emp_email,emp_password,emp_dep_id,emp_desig_id,emp_date_of_joining,emp_exit_date,emp_work_status,emp_salary")] Employee employee, HttpPostedFileBase emp_photo, HttpPostedFileBase emp_resume, HttpPostedFileBase emp_offer_letter, HttpPostedFileBase emp_joining_letter, HttpPostedFileBase emp_contact_and_argue, HttpPostedFileBase emp_ID_proof)
        {
            if (!AdminpanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            ViewBag.emp_dep_id    = new SelectList(db.Departaments, "id", "depart_name");
            ViewBag.emp_desig_id  = new SelectList(db.Designations, "id", "desig_name");
            ViewBag.emp_gender_id = new SelectList(db.Genders, "id", "gender_name");

            Random rand = new Random();

            if (ModelState.IsValid)
            {
                if (emp_photo != null)
                {
                    if (emp_photo.ContentLength < 100 || !emp_photo.ContentType.Contains("image"))
                    {
                        return(View());
                    }
                }
                if (emp_resume != null)
                {
                    if (emp_resume.ContentLength < 100 || !emp_resume.ContentType.Contains("image"))
                    {
                        return(View());
                    }
                }
                if (emp_offer_letter != null)
                {
                    if (emp_offer_letter.ContentLength < 100 || !emp_offer_letter.ContentType.Contains("image"))
                    {
                        return(View());
                    }
                }
                if (emp_joining_letter != null)
                {
                    if (emp_joining_letter.ContentLength < 100 || !emp_joining_letter.ContentType.Contains("image"))
                    {
                        return(View());
                    }
                }
                if (emp_contact_and_argue != null)
                {
                    if (emp_contact_and_argue.ContentLength < 100 || !emp_contact_and_argue.ContentType.Contains("image"))
                    {
                        return(View());
                    }
                }
                if (emp_ID_proof != null)
                {
                    if (emp_ID_proof.ContentLength < 100 || !emp_ID_proof.ContentType.Contains("image"))
                    {
                        return(View());
                    }
                }
                if (emp_photo != null)
                {
                    emp_photo_name = rand.Next(11111, 99999).ToString() + (DateTime.Now.ToString("yyyyMMddHHmmss")) + Path.GetExtension(emp_photo.FileName);
                    var emp_photo_path = Path.Combine(Server.MapPath("~/Areas/Adminpanel/Uploads/"), emp_photo_name);
                    emp_photo.SaveAs(emp_photo_path);
                }
                if (emp_resume != null)
                {
                    emp_resume_name = rand.Next(11111, 99999).ToString() + (DateTime.Now.ToString("yyyyMMddHHmmss")) + Path.GetExtension(emp_resume.FileName);
                    var emp_resume_path = Path.Combine(Server.MapPath("~/Areas/Adminpanel/Uploads/"), emp_resume_name);
                    emp_resume.SaveAs(emp_resume_path);
                }
                if (emp_offer_letter != null)
                {
                    emp_offer_letter_name = rand.Next(11111, 99999).ToString() + (DateTime.Now.ToString("yyyyMMddHHmmss")) + Path.GetExtension(emp_offer_letter.FileName);
                    var emp_offer_letter_path = Path.Combine(Server.MapPath("~/Areas/Adminpanel/Uploads/"), emp_offer_letter_name);
                    emp_offer_letter.SaveAs(emp_offer_letter_path);
                }
                if (emp_joining_letter != null)
                {
                    emp_joining_letter_name = rand.Next(11111, 99999).ToString() + (DateTime.Now.ToString("yyyyMMddHHmmss")) + Path.GetExtension(emp_joining_letter.FileName);
                    var emp_joining_letter_path = Path.Combine(Server.MapPath("~/Areas/Adminpanel/Uploads/"), emp_joining_letter_name);
                    emp_joining_letter.SaveAs(emp_joining_letter_path);
                }
                if (emp_contact_and_argue != null)
                {
                    emp_contact_and_argue_name = rand.Next(11111, 99999).ToString() + (DateTime.Now.ToString("yyyyMMddHHmmss")) + Path.GetExtension(emp_contact_and_argue.FileName);
                    var emp_contact_and_argue_path = Path.Combine(Server.MapPath("~/Areas/Adminpanel/Uploads/"), emp_contact_and_argue_name);
                    emp_contact_and_argue.SaveAs(emp_contact_and_argue_path);
                }
                if (emp_ID_proof != null)
                {
                    emp_ID_proof_name = rand.Next(11111, 99999).ToString() + (DateTime.Now.ToString("yyyyMMddHHmmss")) + Path.GetExtension(emp_ID_proof.FileName);
                    var emp_ID_proof_path = Path.Combine(Server.MapPath("~/Areas/Adminpanel/Uploads/"), emp_ID_proof_name);
                    emp_ID_proof.SaveAs(emp_ID_proof_path);
                }


                employee.emp_work_status       = true;
                employee.emp_photo             = emp_photo_name;
                employee.emp_resume            = emp_resume_name;
                employee.emp_offer_letter      = emp_offer_letter_name;
                employee.emp_joining_letter    = emp_joining_letter_name;
                employee.emp_contact_and_argue = emp_contact_and_argue_name;
                employee.emp_ID_proof          = emp_ID_proof_name;
                employee.emp_dateof_birth      = Convert.ToDateTime(employee.emp_dateof_birth);
                employee.emp_date_of_joining   = Convert.ToDateTime(employee.emp_date_of_joining);
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View());
        }