Example #1
0
 public ActionResult Create([Bind(Include = "TypeID,TypeName,CatID")] EmpType emptype)
 {
     //if (emptype.CatID == null)
     //    ModelState.AddModelError("CatID", "Please select Category");
     if (string.IsNullOrEmpty(emptype.TypeName))
     {
         ModelState.AddModelError("TypeName", "This field is required!");
     }
     if (emptype.TypeName != null)
     {
         if (emptype.TypeName.Length > 50)
         {
             ModelState.AddModelError("TypeName", "String length exceeds!");
         }
         if (!myClass.IsAllLetters(emptype.TypeName))
         {
             ModelState.AddModelError("TypeName", "This field only contain Alphabets");
         }
     }
     if (ModelState.IsValid)
     {
         db.EmpTypes.Add(emptype);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emptype));
 }
        public ActionResult Create([Bind(Include = "RdrTypeID,RdrTypeName,VendorID")] ReaderType readertype)
        {
            if (string.IsNullOrEmpty(readertype.RdrTypeName))
            {
                ModelState.AddModelError("RdrTypeName", "Reader Type field is required!");
            }
            if (readertype.RdrTypeName != null)
            {
                if (readertype.RdrTypeName.Length > 50)
                {
                    ModelState.AddModelError("RdrTypeName", "String length exceeds!");
                }
                if (!myClass.IsAllLetters(readertype.RdrTypeName))
                {
                    ModelState.AddModelError("RdrTypeName", "This field only contain Alphabets");
                }
            }
            if (ModelState.IsValid)
            {
                db.ReaderTypes.Add(readertype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(readertype));
        }
 public ActionResult Create([Bind(Include = "LocID,LocName,CityID")] Location location)
 {
     if (string.IsNullOrEmpty(location.LocName))
     {
         ModelState.AddModelError("LocName", "This field is required!");
     }
     if (location.LocName != null)
     {
         if (location.LocName.Length > 50)
         {
             ModelState.AddModelError("LocName", "String length exceeds!");
         }
         if (!myClass.IsAllLetters(location.LocName))
         {
             ModelState.AddModelError("LocName", "This field only contain Alphabets");
         }
         //if (CheckDuplicate(location.LocName))
         //    ModelState.AddModelError("SectionName", "This Type already exist in record, Please select an unique name");
     }
     if (ModelState.IsValid)
     {
         db.Locations.Add(location);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CityID = new SelectList(db.Cities.OrderBy(s => s.CityName), "CityID", "CityName");
     //ViewBag.SiteID = new SelectList(db.Sites, "SiteID", "SiteName", location.SiteID);
     return(View(location));
 }
Example #4
0
        public ActionResult Create([Bind(Include = "CityID,CityName,RegionID")] City city)
        {
            if (string.IsNullOrEmpty(city.CityName))
            {
                ModelState.AddModelError("CityName", "Required!");
            }
            if (city.CityName != null)
            {
                if (city.CityName.Length > 50)
                {
                    ModelState.AddModelError("CityName", "String length exceeds!");
                }
                if (!myClass.IsAllLetters(city.CityName))
                {
                    ModelState.AddModelError("CityName", "This field only contain Alphabets");
                }
                if (CheckDuplicate(city.CityName))
                {
                    ModelState.AddModelError("CityName", "This name already exist in record, Please select an unique name");
                }
            }

            if (ModelState.IsValid)
            {
                db.Cities.Add(city);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RegionID = new SelectList(db.Regions, "RegionID", "RegionName", city.RegionID);
            return(View(city));
        }
Example #5
0
 public ActionResult Create([Bind(Include = "TypeID,TypeName,CatID,CompanyID")] EmpType emptype)
 {
     if (string.IsNullOrEmpty(emptype.TypeName))
     {
         ModelState.AddModelError("TypeName", "This field is required!");
     }
     if (emptype.TypeName != null)
     {
         if (emptype.TypeName.Length > 50)
         {
             ModelState.AddModelError("TypeName", "String length exceeds!");
         }
         if (!myClass.IsAllLetters(emptype.TypeName))
         {
             ModelState.AddModelError("TypeName", "This field only contain Alphabets");
         }
         if (CheckDuplicate(emptype.TypeName))
         {
             ModelState.AddModelError("TypeName", "This Type already exist in record, Please select an unique name");
         }
     }
     if (ModelState.IsValid)
     {
         db.EmpTypes.Add(emptype);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CatID     = new SelectList(db.Categories, "CatID", "CatName");
     ViewBag.CompanyID = new SelectList(db.Companies, "CompID", "CompName");
     return(View(emptype));
 }
        public ActionResult Create([Bind(Include = "RegionID,RegionName")] Region region)
        {
            if (string.IsNullOrEmpty(region.RegionName))
            {
                ModelState.AddModelError("RegionName", "Required");
            }
            if (region.RegionName != null)
            {
                if (region.RegionName.Length > 50)
                {
                    ModelState.AddModelError("RegionName", "Length exceeds");
                }
                if (!myClass.IsAllLetters(region.RegionName))
                {
                    ModelState.AddModelError("RegionName", "This field only contains Alphabets");
                }
                if (CheckDuplicate(region.RegionName))
                {
                    ModelState.AddModelError("RegionName", "This name already exist in record");
                }
            }
            if (ModelState.IsValid)
            {
                db.Regions.Add(region);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(region));
        }
Example #7
0
 public ActionResult Create([Bind(Include = "DesignationID,DesignationName,CompanyID")] Designation designation)
 {
     if (string.IsNullOrEmpty(designation.DesignationName))
     {
         ModelState.AddModelError("DesignationName", "This field is required!");
     }
     if (designation.DesignationName != null)
     {
         if (designation.DesignationName.Length > 100)
         {
             ModelState.AddModelError("DesignationName", "String length exceeds!");
         }
         if (!myClass.IsAllLetters(designation.DesignationName))
         {
             ModelState.AddModelError("DesignationName", "This field only contain Alphabets");
         }
         if (CheckDuplicate(designation.DesignationName, (short)designation.CompanyID))
         {
             ModelState.AddModelError("DesignationName", "This Designation already exist in record, Please select an unique name");
         }
         // on test basis
     }
     designation.CompanyID = designation.CompanyID;
     if (ModelState.IsValid)
     {
         db.Designations.Add(designation);
         db.SaveChanges();
         int _userID = Convert.ToInt32(Session["LogedUserID"].ToString());
         HelperClass.MyHelper.SaveAuditLog(_userID, (byte)MyEnums.FormName.Designation, (byte)MyEnums.Operation.Add, DateTime.Now);
         return(RedirectToAction("Index"));
     }
     ViewBag.CompanyID = new SelectList(db.Companies, "CompID", "CompName", designation.CompanyID);
     return(View(designation));
 }
 public ActionResult Create([Bind(Include = "DesignationID,DesignationName")] Designation designation)
 {
     if (string.IsNullOrEmpty(designation.DesignationName))
     {
         ModelState.AddModelError("DesignationName", "This field is required!");
     }
     if (designation.DesignationName != null)
     {
         if (designation.DesignationName.Length > 100)
         {
             ModelState.AddModelError("DesignationName", "String length exceeds!");
         }
         if (!myClass.IsAllLetters(designation.DesignationName))
         {
             ModelState.AddModelError("DesignationName", "This field only contain Alphabets");
         }
         // on test basis
     }
     if (ModelState.IsValid)
     {
         db.Designations.Add(designation);
         db.SaveChanges();
         int _userID = Convert.ToInt32(Session["LogedUserID"].ToString());
         HelperClass.MyHelper.SaveAuditLog(_userID, (byte)MyEnums.FormName.Designation, (byte)MyEnums.Operation.Add, DateTime.Now);
         return(RedirectToAction("Index"));
     }
     return(View(designation));
 }
Example #9
0
 public ActionResult Create([Bind(Include = "RegionID,RegionName,ZoneID")] Region region)
 {
     if (string.IsNullOrEmpty(region.RegionName))
     {
         ModelState.AddModelError("RegionName", "Required");
     }
     if (region.RegionName != null)
     {
         if (region.RegionName.Length > 50)
         {
             ModelState.AddModelError("RegionName", "Length exceeds");
         }
         if (!myClass.IsAllLetters(region.RegionName))
         {
             ModelState.AddModelError("RegionName", "This field only contains Alphabets");
         }
         if (CheckDuplicate(region.RegionName))
         {
             ModelState.AddModelError("RegionName", "This name already exist in record");
         }
     }
     if (ModelState.IsValid)
     {
         Zone zone = db.Zones.Where(aa => aa.ZoneID == region.ZoneID).FirstOrDefault();
         region.ZoneName = zone.ZoneName;
         db.Regions.Add(region);
         db.SaveChanges();
         ViewBag.ZoneID = new SelectList(db.Zones, "ZoneID", "ZoneName");
         return(RedirectToAction("Index"));
     }
     ViewBag.ZoneID = new SelectList(db.Zones, "ZoneID", "ZoneName");
     return(View(region));
 }
Example #10
0
 public ActionResult Create([Bind(Include = "LocID,LocName")] Location location)
 {
     if (string.IsNullOrEmpty(location.LocName))
     {
         ModelState.AddModelError("LocName", "This field is required!");
     }
     if (location.LocName != null)
     {
         if (location.LocName.Length > 50)
         {
             ModelState.AddModelError("LocName", "String length exceeds!");
         }
         if (!myClass.IsAllLetters(location.LocName))
         {
             ModelState.AddModelError("LocName", "This field only contain Alphabets");
         }
         if (ModelState.IsValid)
         {
             db.Locations.Add(location);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         //ViewBag.SiteID = new SelectList(db.Sites, "SiteID", "SiteName", location.SiteID);
     }
     return(View(location));
 }
Example #11
0
 public ActionResult Create([Bind(Include = "TypeID,TypeName,CatID,CompanyID")] EmpType emptype)
 {
     if (emptype.CompanyID == null)
     {
         ModelState.AddModelError("CompanyID", "Please selct a Company");
     }
     if (emptype.CatID == null)
     {
         ModelState.AddModelError("CatID", "Please select Category");
     }
     if (string.IsNullOrEmpty(emptype.TypeName))
     {
         ModelState.AddModelError("TypeName", "This field is required!");
     }
     if (db.EmpTypes.Where(aa => aa.TypeName == emptype.TypeName && aa.CompanyID == emptype.CompanyID && aa.CatID == emptype.CatID).Count() > 0)
     {
         ModelState.AddModelError("TypeName", "Type Name must be unique");
     }
     if (emptype.TypeName != null)
     {
         if (emptype.TypeName.Length > 50)
         {
             ModelState.AddModelError("TypeName", "String length exceeds!");
         }
         if (!myClass.IsAllLetters(emptype.TypeName))
         {
             ModelState.AddModelError("TypeName", "This field only contain Alphabets");
         }
     }
     if (ModelState.IsValid)
     {
         db.EmpTypes.Add(emptype);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CatID     = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName");
     ViewBag.CompanyID = new SelectList(db.Companies.OrderBy(s => s.CompName), "CompID", "CompName");
     return(View(emptype));
 }