예제 #1
0
        public ActionResult Create_node()
        {
            try
            {
                ViewBag.unit_type = dbcontext.Organization_Unit_Type.ToList().Select(m => new { Code = m.Code + "--[" + m.Name + ']', ID = m.ID });
                ViewBag.location  = dbcontext.work_location.ToList().Select(m => new { Code = m.Code + "--[" + m.Name + ']', ID = m.ID });
                ViewBag.empl      = dbcontext.Employee_Profile.ToList().Select(m => new { Code = m.Code + "->" + m.Name, ID = m.ID });
                ViewBag.cost      = dbcontext.CostCenter.ToList().Select(m => new { Code = m.CostCenterCode + "->" + m.CostCenterDesc, ID = m.ID });
                ViewBag.shift     = dbcontext.Shift_setup.ToList().Select(m => new { Code = m.Code + "->" + m.Name, ID = m.ID });
                var parent = dbcontext.Organization_Chart.ToList();
                ViewBag.parenttt = parent.Select(m => new { Code = m.Code + "--[" + m.unit_Description + ']', ID = m.ID });
                var model = new Organization_Chart();
                if (parent.Count() == 0)
                {
                    model.master_node = "Y";
                }
                else
                {
                    model.master_node = "N";
                }

                model.unit_status = check_status.created;
                model.number_of_direct_positions = 0;

                //////

                var stru   = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Organization).Structure_Code;
                var modell = dbcontext.Organization_Chart.ToList();
                if (modell.Count() == 0)
                {
                    model.Code = stru + "1";
                }
                else
                {
                    model.Code = stru + (modell.LastOrDefault().ID + 1).ToString();
                }
                /////
                return(View(model));
            }
            catch (Exception e)
            {
                return(RedirectToAction("index"));
            }
        }
        public ActionResult special_organization_view_related_to_jobs(string id)
        {
            try
            {
                var list = dbcontext.Organization_Chart.ToList();
                var i    = 0;
                if (list.Count() > 0)
                {
                    i = list.LastOrDefault().ID + 1;
                }
                foreach (var item1 in list)
                {
                    var job_node = new List <Organization_Chart>();
                    var job      = new Organization_Chart();

                    var jobs = dbcontext.job_title_cards.Where(m => m.Organization_unit_codeID == item1.ID.ToString());

                    foreach (var item2 in jobs)
                    {
                        job_node.Add(new Organization_Chart {
                            ID = i, Childs = new List <Organization_Chart>(), unit_Description = item2.name + " ,Hired [" + item2.number_hired + " ]   ,vacant[ " + item2.number_vacant + " ]"
                        });
                        i++;
                    }
                    if (jobs.Count() > 0)
                    {
                        job.ID = i++;
                        job.unit_Description = HR.Resource.organ.jobs;
                        job.Childs           = job_node;
                        item1.Childs.Add(job);
                    }
                }
                List <Organization_Chart> ll = new List <Organization_Chart>();
                int ooo = int.Parse(id);
                ll.Add(list.FirstOrDefault(m => m.ID == ooo));
                return(View("organization_view_related_to_jobs", ll));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
        public ActionResult organization_view_related_to_jobs()
        {
            try
            {
                var list = dbcontext.Organization_Chart.ToList();
                var i    = 0;
                var j    = 0;
                if (list.Count() > 0)
                {
                    i = list.LastOrDefault().ID + 1;
                }
                foreach (var item1 in list)
                {
                    var job_node = new List <Organization_Chart>();
                    var job      = new Organization_Chart();

                    var jobs = dbcontext.job_title_cards.Where(m => m.Organization_unit_codeID == item1.ID.ToString());

                    foreach (var item2 in jobs.ToList())
                    {
                        var list_slot_details = new List <Organization_Chart>();
                        var slots             = dbcontext.Slots.Where(m => m.job_title_cards.ID == item2.ID).ToList();
                        if (slots != null)
                        {
                            foreach (var item3 in slots)
                            {
                                j++;
                                if (item3.EmployeeID == null || item3.EmployeeID == "0")
                                {
                                    list_slot_details.Add(new Organization_Chart {
                                        Childs = new List <Organization_Chart>(), ID = (j + 1000), unit_Description = item3.slot_description + " , " + item3.check_status + " , " + item3.slot_type + " , " + "[ Free Slot ]"
                                    });
                                }
                                else
                                {
                                    list_slot_details.Add(new Organization_Chart {
                                        Childs = new List <Organization_Chart>(), ID = (j + 1000), unit_Description = item3.slot_description + " , " + item3.check_status + " , " + item3.slot_type + " ,  [ " + item3.EmployeeID + "->" + item3.EmployeeName + " ] "
                                    });
                                }
                            }
                        }
                        job_node.Add(new Organization_Chart {
                            ID = i, Childs = list_slot_details, unit_Description = item2.name + " ,Hired [" + item2.number_hired + " ]   ,vacant[ " + item2.number_vacant + " ]"
                        });
                        i++;
                    }
                    if (jobs.Count() > 0)
                    {
                        job.ID = i++;
                        job.unit_Description = HR.Resource.organ.jobs;
                        job.Childs           = job_node;
                        item1.Childs.Add(job);
                    }
                }

                List <Organization_Chart> ll = new List <Organization_Chart>();
                if (list.Count() > 0)
                {
                    ll.Add(list.FirstOrDefault(m => m.parent == "0"));
                }
                return(View(ll));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
예제 #4
0
        public ActionResult Create_node(Organization_Chart model)
        {
            try
            {
                ViewBag.unit_type = dbcontext.Organization_Unit_Type.ToList().Select(m => new { Code = m.Code + "--[" + m.Name + ']', ID = m.ID });
                ViewBag.location  = dbcontext.work_location.ToList().Select(m => new { Code = m.Code + "--[" + m.Name + ']', ID = m.ID });
                ViewBag.empl      = dbcontext.Employee_Profile.ToList().Select(m => new { Code = m.Code + "->" + m.Name, ID = m.ID });
                ViewBag.cost      = dbcontext.CostCenter.ToList().Select(m => new { Code = m.CostCenterCode + "->" + m.CostCenterDesc, ID = m.ID });
                ViewBag.shift     = dbcontext.Shift_setup.ToList().Select(m => new { Code = m.Code + "->" + m.Name, ID = m.ID });

                var parent = dbcontext.Organization_Chart.ToList();
                ViewBag.parenttt = parent.ToList().Select(m => new { Code = m.Code + "--[" + m.unit_Description + ']', ID = m.ID });
                model.Childs     = new List <Organization_Chart>();
                if (model.master_node == "N")
                {
                    var IDd     = int.Parse(model.parent);
                    var parentt = dbcontext.Organization_Chart.FirstOrDefault(m => m.ID == IDd);
                    model.parent = parentt.ID.ToString();
                }
                else
                {
                    model.parent = "0";
                }
                model.unit_type_code = dbcontext.Organization_Unit_Type.FirstOrDefault(m => m.ID == model.unit_type_codeID);
                if (model.worklocationid != null && model.worklocationid != "0")
                {
                    var oi = int.Parse(model.worklocationid);
                    model.work_location = dbcontext.work_location.FirstOrDefault(m => m.ID == oi);
                }

                if (model.Employee_ProfileID == 0)
                {
                    model.Employee_ProfileID = null;
                }
                var new_node = dbcontext.Organization_Chart.Add(model);
                dbcontext.SaveChanges();
                if (new_node.parent != "0")
                {
                    var ID  = int.Parse(new_node.parent);
                    var par = dbcontext.Organization_Chart.FirstOrDefault(m => m.ID == ID);
                    par.Childs.Add(new_node);
                    dbcontext.SaveChanges();
                }
                //=================================check for alert==================================
                var get_result_check = HR.Controllers.check.check_alert("organization chart card", HR.Models.user.Action.Create, HR.Models.user.type_field.form);
                if (get_result_check != null)
                {
                    var inbox = new Models.user.Alert_inbox {
                        send_from_user_id = User.Identity.Name, send_to_user_id = get_result_check.send_to_ID_user, title = get_result_check.Subject, Subject = get_result_check.Message
                    };
                    if (get_result_check.until != null)
                    {
                        if (get_result_check.until.Value.Year != 0001)
                        {
                            inbox.until = get_result_check.until;
                        }
                    }
                    ApplicationDbContext dbcontext = new ApplicationDbContext();
                    dbcontext.Alert_inbox.Add(inbox);
                    dbcontext.SaveChanges();
                }
                //===================================================================================
                return(RedirectToAction("index"));
            }
            catch (DbUpdateException)
            {
                TempData["Message"] = HR.Resource.organ.thiscodeIsalreadyexists;
                return(View(model));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
예제 #5
0
        public ActionResult edit_node(Organization_Chart record)
        {
            try
            {
                var model = dbcontext.Organization_Chart.FirstOrDefault(m => m.ID == record.ID);
                ViewBag.location = dbcontext.work_location.ToList().Select(m => new { Code = m.Code + "--[" + m.Name + ']', ID = m.ID });
                ViewBag.empl     = dbcontext.Employee_Profile.ToList().Select(m => new { Code = m.Code + "->" + m.Name, ID = m.ID });

                ViewBag.unit_type = dbcontext.Organization_Unit_Type.ToList().Select(m => new { Code = m.Code + "--[" + m.Name + ']', ID = m.ID });
                ViewBag.cost      = dbcontext.CostCenter.ToList().Select(m => new { Code = m.CostCenterCode + "->" + m.CostCenterDesc, ID = m.ID });
                ViewBag.shift     = dbcontext.Shift_setup.ToList().Select(m => new { Code = m.Code + "->" + m.Name, ID = m.ID });

                var parentt = dbcontext.Organization_Chart.Where(m => m.ID != model.ID && m.parent != model.ID.ToString()).ToList();
                ViewBag.parenttt = parentt.ToList().Select(m => new { Code = m.Code + "--[" + m.unit_Description + ']', ID = m.ID });

                if (model.master_node == "N")
                {
                    var IDd     = int.Parse(record.parent);
                    var pparent = dbcontext.Organization_Chart.FirstOrDefault(m => m.ID == IDd);
                    model.parent = pparent.ID.ToString();
                    pparent.Childs.Add(model);
                    //foreach(var item in model.Childs)
                    //{
                    //    pparent.Childs.Add(item);
                    //    dbcontext.SaveChanges();
                    //}
                }
                else
                {
                    model.parent = "0";
                }
                model.unit_type_codeID = model.unit_type_codeID;
                model.unit_type_code   = dbcontext.Organization_Unit_Type.FirstOrDefault(m => m.ID == record.unit_type_codeID);
                if (record.worklocationid != null && record.worklocationid != "0")
                {
                    var oi = int.Parse(record.worklocationid);
                    model.work_location = dbcontext.work_location.FirstOrDefault(m => m.ID == oi);
                }
                model.alter_unit_Description = record.alter_unit_Description;
                // model.Code = record.Code;
                model.master_node                = record.master_node;
                model.worklocationid             = record.worklocationid;
                model.number_of_direct_positions = record.number_of_direct_positions;
                model.refrence_number            = record.refrence_number;
                model.unit_Description           = record.unit_Description;
                model.unit_mail      = record.unit_mail;
                model.unit_status    = record.unit_status;
                model.User_unit_code = record.User_unit_code;
                model.cost_center_id = record.cost_center_id;
                model.shift_code_id  = record.shift_code_id;
                if (model.Employee_ProfileID == 0)
                {
                    model.Employee_ProfileID = null;
                }
                else
                {
                    model.Employee_ProfileID = record.Employee_ProfileID;
                }
                dbcontext.SaveChanges();
                //=================================check for alert==================================
                var get_result_check = HR.Controllers.check.check_alert("organization chart card", HR.Models.user.Action.edit, HR.Models.user.type_field.form);
                if (get_result_check != null)
                {
                    var inbox = new Models.user.Alert_inbox {
                        send_from_user_id = User.Identity.Name, send_to_user_id = get_result_check.send_to_ID_user, title = get_result_check.Subject, Subject = get_result_check.Message
                    };
                    if (get_result_check.until != null)
                    {
                        if (get_result_check.until.Value.Year != 0001)
                        {
                            inbox.until = get_result_check.until;
                        }
                    }
                    ApplicationDbContext dbcontext = new ApplicationDbContext();
                    dbcontext.Alert_inbox.Add(inbox);
                    dbcontext.SaveChanges();
                }
                //===================================================================================
                return(RedirectToAction("Details", new { id = model.ID.ToString() }));
            }
            catch (DbUpdateException)
            {
                TempData["Message"] = HR.Resource.organ.thiscodeIsalreadyexists;
                return(View(record));
            }
            catch (Exception e)
            {
                return(View(record));
            }
        }