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 = "SiteID,SiteName,CityID")] Site site) { if (string.IsNullOrEmpty(site.SiteName)) { ModelState.AddModelError("SiteName", "This field is required!"); } if (site.SiteName != null) { if (site.SiteName.Length > 50) { ModelState.AddModelError("SiteName", "String length exceeds!"); } if (CheckDuplicate(site.SiteName)) { ModelState.AddModelError("SiteName", "This Type already exist in record, Please select an unique name"); } } if (ModelState.IsValid) { db.Sites.Add(site); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CityID = new SelectList(db.Cities.OrderBy(s => s.CityName), "CityID", "CityName", site.CityID); return(View(site)); }
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)); }
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)); }
private void AdjustPollData() { int currentYear = DateTime.Today.Date.Year; int StartYear = currentYear - 3; DateTime endDate = DateTime.Today.AddDays(2); DateTime startDate = new DateTime(StartYear, 1, 1); using (var ctx = new TAS2013Entities()) { List <PollData> polls = ctx.PollDatas.Where(aa => aa.EntDate <= startDate && aa.Process == false).ToList(); foreach (var item in polls) { item.Process = true; } ctx.SaveChanges(); polls.Clear(); polls = ctx.PollDatas.Where(aa => aa.EntDate >= endDate && aa.Process == false).ToList(); foreach (var item in polls) { item.Process = true; } ctx.SaveChanges(); ctx.Dispose(); } }
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 = "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)); }
private bool AddLateInMarginAttData(string _empDate, int _empID, DateTime _Date, int _userID, short _WorkCardID, short _CompID) { bool check = false; try { //Late In Job Card short LateInMins = 0; using (var context = new TAS2013Entities()) { AttData _attdata = context.AttDatas.FirstOrDefault(aa => aa.EmpDate == _empDate); if (_attdata != null) { _attdata.StatusAB = false; _attdata.Remarks.Replace("[LI]", ""); _attdata.Remarks = _attdata.Remarks + "[LI Job Card]"; _attdata.LateIn = 0; _attdata.WorkMin = (short)(_attdata.WorkMin + (short)LateInMins); _attdata.StatusLI = false; } context.SaveChanges(); if (context.SaveChanges() > 0) { check = true; } context.Dispose(); } } catch (Exception ex) { } return(check); }
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)); }
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)); }
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)); }
private void RandomGenerator(DateTime date) { TAS2013Entities ctx = new TAS2013Entities(); List <Emp> emps = new List <Emp>(); emps = ctx.Emps.Where(aa => aa.CrewID == 1 && aa.Status == true).ToList(); DateTime ds = new DateTime(2015, 08, 09); DateTime de = new DateTime(2015, 08, 13); while (ds <= de) { foreach (var emp in emps) { AttData attdata = new AttData(); if (ctx.AttDatas.Where(aa => aa.AttDate == ds && aa.EmpID == emp.EmpID).Count() > 0) { attdata = ctx.AttDatas.First(aa => aa.AttDate == ds && aa.EmpID == emp.EmpID); if (attdata != null) { ctx.AttDatas.DeleteObject(attdata); } List <PollData> polls = new List <PollData>(); polls = ctx.PollDatas.Where(aa => aa.EmpID == emp.EmpID && aa.EntDate >= ds && aa.EntDate <= de).ToList(); foreach (var poll in polls) { poll.Process = false; ctx.SaveChanges(); } ctx.SaveChanges(); } } ds = ds.AddDays(1); } }
private bool AddBadliAttData(string _empDate, int _empID, DateTime _Date, int _userID, JobCardApp jcApp) { bool check = false; try { //Normal Duty using (var context = new TAS2013Entities()) { AttData _attdata = context.AttDatas.FirstOrDefault(aa => aa.EmpDate == _empDate); JobCard _jcCard = context.JobCards.FirstOrDefault(aa => aa.WorkCardID == jcApp.CardType); if (_attdata != null) { _attdata.DutyCode = "D"; _attdata.StatusAB = false; _attdata.StatusLeave = false; _attdata.StatusP = true; _attdata.Remarks = _attdata.Remarks + "[Badli][Manual]"; _attdata.StatusMN = true; } context.SaveChanges(); if (context.SaveChanges() > 0) { check = true; } context.Dispose(); } } catch (Exception ex) { } return(check); }
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 = "ID,EmailAddress,CCAddress,CompanyID,DepartmentID,SectionID,CriteriaDepSec,ReportCurrentDate,LocationID,TypID,HasTypeOrCat,HasLoc,CatID")] EmailEntryForm emailentryform) { User LoggedInUser = Session["LoggedUser"] as User; string compval = Request.Form["CriteriaComp"].ToString(); emailentryform.CriteriaComLoc = compval; //string depval = Request.Form["Criteria"].ToString(); //emailentryform.CriteriaDepSec = depval; if (ModelState.IsValid) { emailentryform.UserID = LoggedInUser.UserID; db.EmailEntryForms.Add(emailentryform); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TypID = new SelectList(db.EmpTypes, "TypeID", "TypeName"); ViewBag.CompanyID = new SelectList(db.Companies, "CompID", "CompName", emailentryform.CompanyID); ViewBag.DepartmentID = new SelectList(db.Departments, "DeptID", "DeptName", emailentryform.DepartmentID); ViewBag.LocationID = new SelectList(db.Locations, "LocID", "LocName", emailentryform.LocationID); ViewBag.SectionID = new SelectList(db.Sections, "SectionID", "SectionName", emailentryform.SectionID); ViewBag.CatID = new SelectList(db.Categories, "CatID", "CatName", emailentryform.CatID); ViewBag.CriteriaComp = new SelectList(GetCriteriaComp(), "ID", "Name", emailentryform.CriteriaComLoc); ViewBag.CriteriaDepSec = new SelectList(GetCriteriaDeptSec(), "ID", "Name", emailentryform.CriteriaDepSec); ViewBag.HasTypeOrCat = new SelectList(GetCriteriaTypeCat(), "ID", "Name", emailentryform.HasTypeOrCat); return(View(emailentryform)); }
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)); }
public ActionResult Create([Bind(Include = "DeptID,DeptName,DivID,CompanyID")] Department department) { if (db.Departments.Where(aa => aa.DeptName == department.DeptName && aa.CompanyID == department.CompanyID).Count() > 0) { ModelState.AddModelError("DeptName", "Department Name is must be unique"); } if (department.CompanyID == null) { ModelState.AddModelError("DeptName", "Please selct a Company"); } if (department.DeptName == "") { ModelState.AddModelError("DeptName", "Please enter Department Name"); } if (department.DivID == null) { ModelState.AddModelError("DivID", "Please select Division"); } if (ModelState.IsValid) { db.Departments.Add(department); db.SaveChanges(); int _userID = Convert.ToInt32(Session["LogedUserID"].ToString()); HelperClass.MyHelper.SaveAuditLog(_userID, (byte)MyEnums.FormName.Department, (byte)MyEnums.Operation.Add, DateTime.Now); return(RedirectToAction("Index")); } ViewBag.DivID = new SelectList(db.Divisions.OrderBy(s => s.DivisionName), "DivisionID", "DivisionName", department.DivID); ViewBag.CompanyID = new SelectList(db.Companies.OrderBy(s => s.CompName), "CompID", "CompName"); return(View(department)); }
public ActionResult Create([Bind(Include = "SectionID,SectionName,DeptID,CompanyID")] Section section) { if (db.Sections.Where(aa => aa.SectionName == section.SectionName && aa.DeptID == section.DeptID && aa.CompanyID == section.CompanyID).Count() > 0) { ModelState.AddModelError("SectionName", "Name must be unique"); } if (section.CompanyID == null) { ModelState.AddModelError("CompanyID", "Please selct a Company"); } if (section.SectionName == "") { ModelState.AddModelError("SectionName", "Please enter Section Name"); } if (section.DeptID == null) { ModelState.AddModelError("DeptID", "Please select Department"); } if (ModelState.IsValid) { db.Sections.Add(section); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DeptID = new SelectList(db.Departments.OrderBy(s => s.DeptName), "DeptID", "DeptName", section.DeptID); ViewBag.CompanyID = new SelectList(db.Companies.OrderBy(s => s.CompName), "CompID", "CompName"); return(View(section)); }
public ActionResult Create([Bind(Include = "RdrID,RdrName,RdrDutyID,IpAdd,IpPort,RdrTypeID,Status,LocID,CompanyID")] Reader reader) { // Regex for IP [0-9]+(\.[0-9][0-9]?)? if (string.IsNullOrEmpty(reader.IpAdd)) { ModelState.AddModelError("IpAdd", "Required"); } if (string.IsNullOrEmpty(reader.RdrName)) { ModelState.AddModelError("RdrName", "Required"); } if (string.IsNullOrEmpty(reader.IpPort.ToString())) { ModelState.AddModelError("IpPort", "Required"); } if (reader.IpAdd != null) { if (reader.IpAdd.Length > 15) { ModelState.AddModelError("IpAdd", "String length exceeds!"); } Match match = Regex.Match(reader.IpAdd, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"); if (!match.Success) { ModelState.AddModelError("IpAdd", "Enter a valid IP Address"); } } if (reader.RdrName != null) { if (reader.RdrName.Length > 50) { ModelState.AddModelError("RdrName", "String length exceeds!"); } } if (!string.IsNullOrEmpty(reader.IpPort.ToString())) { if (reader.IpPort.ToString().Length > 4) { ModelState.AddModelError("IpPort", "String length exceeds!"); } } if (ModelState.IsValid) { User LoggedInUser = Session["LoggedUser"] as User; db.Readers.Add(reader); db.SaveChanges(); int _userID = Convert.ToInt32(Session["LogedUserID"].ToString()); HelperClass.MyHelper.SaveAuditLog(_userID, (byte)MyEnums.FormName.Reader, (byte)MyEnums.Operation.Add, DateTime.Now); return(RedirectToAction("Index")); } ViewBag.LocID = new SelectList(db.Locations, "LocID", "LocName", reader.LocID); ViewBag.RdrDutyID = new SelectList(db.RdrDutyCodes, "RdrDutyID", "RdrDutyName", reader.RdrDutyID); ViewBag.RdrTypeID = new SelectList(db.ReaderTypes, "RdrTypeID", "RdrTypeName", reader.RdrTypeID); ViewBag.CompanyID = new SelectList(db.Companies, "CompID", "CompName", reader.CompanyID); return(View(reader)); }
private bool AddJCToAttData(string _empDate, int _empID, DateTime _Date, string dutyCode, bool statusAB, bool statusDO, bool statusLeave, bool statusGZ, bool statusP, string Remarks) { bool check = false; try { using (var context = new TAS2013Entities()) { AttData _attdata = context.AttDatas.FirstOrDefault(aa => aa.EmpDate == _empDate); if (_attdata != null) { if (statusAB == true) { _attdata.PDays = 0; _attdata.LeaveDays = 0; _attdata.ABDays = 1; } if (statusP == true) { _attdata.PDays = 1; _attdata.LeaveDays = 0; _attdata.ABDays = 0; } _attdata.DutyCode = dutyCode; _attdata.StatusAB = statusAB; _attdata.StatusDO = statusDO; _attdata.StatusLeave = statusLeave; _attdata.StatusGZ = statusGZ; _attdata.StatusP = statusP; if (_attdata.StatusAB != true) { _attdata.WorkMin = _attdata.ShifMin; } else { _attdata.WorkMin = 0; } if (_attdata.StatusDO == true) { _attdata.WorkMin = 0; } _attdata.Remarks = Remarks; } context.SaveChanges(); if (context.SaveChanges() > 0) { check = true; } context.Dispose(); } } catch (Exception ex) { } return(check); }
public ActionResult Create([Bind(Include = "DivisionID,DivisionName")] Division division) { if (ModelState.IsValid) { db.Divisions.Add(division); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(division)); }
public ActionResult Create([Bind(Include = "EmpMonthYear,CompanyID,MonthYear,StartDate,EndDate,EmpNo,TotalDays,EarnedDays,RestDays,AbsentDays,SickLeaveDays,AnnualLeaveDays,CasualDays,OtherLeaveDays,LateInMins,OverTimeMins,EmpID,AnnualLVEncashmentDays,BadliPNo,BadliCompanyID,BadliDays,PreparedBy,PreparedDate,Approved,CreatedDate,IsEdited,TransferedToOracle,TransferedDate")] PayRollPrimary payrollprimary) { if (ModelState.IsValid) { db.PayRollPrimaries.Add(payrollprimary); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(payrollprimary)); }
public ActionResult Create([Bind(Include = "EmpDate,JobDataID,EmpID,Dated,SubmittedFrom,WrkCardID,SendTo,Approved,Rejected,DateCreated,Remarks,TimeIn,TimeOut,WorkMin")] JobCardEmp jobcardemp) { if (ModelState.IsValid) { db.JobCardEmps.Add(jobcardemp); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(jobcardemp)); }
public ActionResult Create([Bind(Include = "HolID,HolDate,HolDesc")] Holiday holiday) { if (ModelState.IsValid) { db.Holidays.Add(holiday); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(holiday)); }
public ActionResult Create([Bind(Include = "LvTypeID,LvDesc,FldName,HalfLeave,HalfLvCode,HalfAbCode,MaxDays,UpdateBalance,Enable,CarryForward,CarryForwardYear,CarryForwardDays,CountGZDays,CountRestDays,MaxDaysConsective,MaxDaysMonth")] LvType lvtype) { if (ModelState.IsValid) { db.LvTypes.Add(lvtype); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lvtype)); }
public ActionResult Create([Bind(Include = "SectionID,SectionName,DeptID")] Section section) { if (ModelState.IsValid) { db.Sections.Add(section); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DeptID = new SelectList(db.Departments, "DeptID", "DeptName", section.DeptID); return(View(section)); }
public ActionResult Create([Bind(Include = "CatID,CatName")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind(Include = "JobCardID,DateCreated,DateStarted,DateEnded,CardType,UserID,JobCardCriteria,CriteriaData,Status,TimeIn,TimeOut,WorkMin")] JobCardApp jobcardapp) { if (ModelState.IsValid) { db.JobCardApps.Add(jobcardapp); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(jobcardapp)); }
public ActionResult Create([Bind(Include = "GradeID,GradeName")] Grade grade) { if (ModelState.IsValid) { db.Grades.Add(grade); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(grade)); }
public ActionResult Create([Bind(Include = "JobID,JobTitle1")] JobTitle jobtitle) { if (ModelState.IsValid) { db.JobTitles.Add(jobtitle); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(jobtitle)); }