Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(long id)
        {
            HRMS_DESG_MS hRMS_DESG_MS = db.HRMS_DESG_MS.Find(id);

            db.HRMS_DESG_MS.Remove(hRMS_DESG_MS);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        // GET: HRMS_DESG_MS/Delete/5
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HRMS_DESG_MS hRMS_DESG_MS = db.HRMS_DESG_MS.Find(id);

            if (hRMS_DESG_MS == null)
            {
                return(HttpNotFound());
            }
            return(View(hRMS_DESG_MS));
        }
Ejemplo n.º 3
0
        // GET: HRMS_DESG_MS/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HRMS_DESG_MS hRMS_DESG_MS = db.HRMS_DESG_MS.Find(id);

            if (hRMS_DESG_MS == null)
            {
                return(HttpNotFound());
            }
            var dropdowndata = db.HRMS_DESG_MS.Where(rec => rec.Desg_Parent_ID == null && rec.IsActive == true);

            if (dropdowndata != null)
            {
                ViewBag.DropdownData = dropdowndata;
            }
            return(View(hRMS_DESG_MS));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Desg_Id,Desg_Name,Desg_Short_Name,Desg_Parent_ID,IsActive,CreatedBy,CreateDate,ModifyBy,ModifyDate")] HRMS_DESG_MS hRMS_DESG_MS)
        {
            if (ModelState.IsValid)
            {
                //db.HRMS_DESG_MS.Add(hRMS_DESG_MS);
                //db.SaveChanges();
                //return RedirectToAction("Index");

                //*********************************************
                if (hRMS_DESG_MS.Desg_Parent_ID == null)
                {
                    var AlreadyParent = db.HRMS_DESG_MS.FirstOrDefault(rec => rec.Desg_Name == hRMS_DESG_MS.Desg_Name);
                    if (AlreadyParent == null)
                    {
                        db.HRMS_DESG_MS.Add(hRMS_DESG_MS);
                        db.SaveChanges();
                        ModelState.Clear();

                        ViewBag.Designation_Status = "Parent Designation added successfully.";
                        var dropdowndata = db.HRMS_DESG_MS.Where(rec => rec.Desg_Parent_ID == null && rec.IsActive == true);
                        if (dropdowndata != null)
                        {
                            ViewBag.DropdownData = dropdowndata;
                        }

                        return(View());
                    }
                    else
                    {
                        ViewBag.Designation_Status = "This parent Designation is already exist";
                        var dropdowndata = db.HRMS_DESG_MS.Where(rec => rec.Desg_Parent_ID == null && rec.IsActive == true);
                        if (dropdowndata != null)
                        {
                            ViewBag.DropdownData = dropdowndata;
                        }
                        return(View());
                    }
                }
                else
                {
                    var alreadySubDesg = db.HRMS_DESG_MS.FirstOrDefault(rec => rec.Desg_Name == hRMS_DESG_MS.Desg_Name && rec.Desg_Parent_ID == hRMS_DESG_MS.Desg_Parent_ID);
                    if (alreadySubDesg == null)
                    {
                        var parentDesg = db.HRMS_DESG_MS.FirstOrDefault(rec => rec.Desg_Id == hRMS_DESG_MS.Desg_Parent_ID);
                        if (hRMS_DESG_MS.Desg_Name == parentDesg.Desg_Name)
                        {
                            ViewBag.Designation_Status = "Parent Designation and Sub Designation can not have Same Names!";
                            var dropdowndatanew = db.HRMS_DESG_MS.Where(rec => rec.Desg_Parent_ID == null && rec.IsActive == true);
                            if (dropdowndatanew != null)
                            {
                                ViewBag.DropdownData = dropdowndatanew;
                            }
                            return(View());
                        }
                        else
                        {
                            db.HRMS_DESG_MS.Add(hRMS_DESG_MS);
                            db.SaveChanges(); ModelState.Clear();

                            ViewBag.Designation_Status = "Sub Designation added successfully.";
                            var dropdowndata = db.HRMS_DESG_MS.Where(rec => rec.Desg_Parent_ID == null && rec.IsActive == true);
                            if (dropdowndata != null)
                            {
                                ViewBag.DropdownData = dropdowndata;
                            }
                            return(View());
                        }
                    }
                    else
                    {
                        ViewBag.Designation_Status = "This Sub Designation is already exist!";
                        var dropdowndata = db.HRMS_DESG_MS.Where(rec => rec.Desg_Parent_ID == null && rec.IsActive == true);
                        if (dropdowndata != null)
                        {
                            ViewBag.DropdownData = dropdowndata;
                        }
                        return(View());
                    }
                }
            }

            return(View(hRMS_DESG_MS));
        }