protected void btnSave_Click(object sender, EventArgs e) { using (DataClassesDataContext objD = new DataClassesDataContext()) { tblEmployee tblEmp = new tblEmployee(); tblEmp.Name = txtEmpName.Text; tblEmp.DeptId = int.Parse(drpDepartment.SelectedValue); tblEmp.Active = Convert.ToBoolean(OptActive.SelectedValue); objD.tblEmployees.InsertOnSubmit(tblEmp); objD.SubmitChanges(); } DisplayData(); bindGrid(); }
public bool TryAddNewEmployee(tblEmployee employee) { try { using (var conn = new CompanyManagementEntities()) { conn.tblEmployees.Add(employee); conn.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public ActionResult Create_post() { if (ModelState.IsValid) { tblEmployee newEmployee = new tblEmployee(); TryUpdateModel(newEmployee); //if(ValidateModel(newEmployee)) using (MyDatabaseEntities dbContext = new MyDatabaseEntities()) { dbContext.tblEmployees.Add(newEmployee); dbContext.SaveChanges(); return(RedirectToAction("Index")); } } return(View()); }
/// <summary> /// Checks if there is any employee in the database with entered username and password. /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> public bool IsEmployee(string userName, string password) { try { using (EmployeeEntities context = new EmployeeEntities()) { tblEmployee employee = (from x in context.tblEmployees where x.UserName == userName && x.Pass == password select x).First(); id = employee.EmployeeID; return(true); } } catch { return(false); } }
public void DeleteEmployee(int idEmployee) { try { using (DAN_XLIIIEntities1 context = new DAN_XLIIIEntities1()) { tblEmployee idEmployeeToDelete = (from e in context.tblEmployees where e.EmployeeID == idEmployee select e).First(); context.tblEmployees.Remove(idEmployeeToDelete); context.SaveChanges(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString()); } }
public void UpdateTest() { InsertTest(); int expected = 1; int actual = 0; tblEmployee updateRow = dc.tblEmployees.Where(a => a.Id == employeeId).FirstOrDefault(); if (updateRow != null) { updateRow.Email = "*****@*****.**"; actual = dc.SaveChanges(); } Assert.AreEqual(expected, actual); }
public ActionResult DeleteConfirmed(int id) { try { tblEmployee tblEmployee = db.tblEmployees.Find(id); db.tblEmployees.Remove(tblEmployee); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { ErrorLog ObjError = new ErrorLog(); ObjError.Log(ex.Message); return(View()); } }
public void DeleteTest() { InsertTest(); int expected = 1; int actual = 0; tblEmployee deleteRow = dc.tblEmployees.Where(a => a.Id == employeeId).FirstOrDefault(); if (deleteRow != null) { dc.tblEmployees.Remove(deleteRow); actual = dc.SaveChanges(); } Assert.AreEqual(expected, actual); }
/// <summary> /// Checks if employee with username and password exists in database BarStock. /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <param name="employee"></param> /// <returns></returns> public bool IsEmployee(string username, string password, out tblEmployee employee) { try { using (BarStockEntities context = new BarStockEntities()) { employee = (from e in context.tblEmployees where e.UserName == username && e.Pass == password select e).First(); return(true); } } catch { employee = null; return(false); } }
internal bool IsEmployee(string userName, string password) { try { using (HotelEntities context = new HotelEntities()) { tblAccount account = (from a in context.tblAccounts where a.UserName == userName && a.Pass == password select a).First(); tblEmployee employee = (from e in context.tblEmployees where e.AccountID == account.AccountID select e).First(); } return(true); } catch { return(false); } }
public JsonResult DeleteEmployee(int EmployeeId) { MvcTutorialEntities db = new MvcTutorialEntities(); bool result = false; tblEmployee emp = db.tblEmployees.SingleOrDefault(x => x.isDeleted == false && x.EmployeeID == EmployeeId); if (emp != null) { emp.isDeleted = true; db.SaveChanges(); result = true; } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Checks if employee with the username and pass exists in tblEmployee in the database. /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> internal bool IsEmployee(string userName, string password) { try { using (CompanyEntities context = new CompanyEntities()) { tblAccount account = GetAccount(userName, password); tblEmployee employee = (from e in context.tblEmployees where e.AccountID == account.AccountID select e).First(); return(true); } } catch { return(false); } }
public async Task <ActionResult> DeleteConfirmed(int id) { if (Session["user"] != null && Session["loginID"] != null) { tblEmployee tblEmployee = await db.tblEmployees.FindAsync(id); db.tblEmployees.Remove(tblEmployee); await db.SaveChangesAsync(); return(RedirectToAction("adminAccountList")); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Create([Bind(Include = "EmpCode,EmpName,Address,Email,DOB,FatherName,MotherName,ContactNo,Gender,Nationality,Religion,NID,JoiningDate,DeptCode,DesigCode,SecCode,DivCode,EmpTypeCode,CurrentSalary,AccNo,BankName")] tblEmployee tblEmployee) { if (ModelState.IsValid) { db.tblEmployees.Add(tblEmployee); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DeptCode = new SelectList(db.tblDepartments, "DeptCode", "DepartmentName", tblEmployee.DeptCode); ViewBag.DesigCode = new SelectList(db.tblDesignations, "DesigCode", "Designation", tblEmployee.DesigCode); ViewBag.DivCode = new SelectList(db.tblDivisions, "DivCode", "Division", tblEmployee.DivCode); ViewBag.EmpTypeCode = new SelectList(db.tblEmployeeTypes, "EmpTypecode", "EmpType", tblEmployee.EmpTypeCode); ViewBag.SecCode = new SelectList(db.tblSections, "SecCode", "SectionName", tblEmployee.SecCode); return(View(tblEmployee)); }
public static tblEmployee GetEmployeeByCredentials(string username, string password) { try { using (DAN_XLIIIEntities1 context = new DAN_XLIIIEntities1()) { tblEmployee employee = (from x in context.tblEmployees where x.Username == username && x.Pasword == password select x).FirstOrDefault(); return(employee); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception " + ex.Message.ToString()); return(null); } }
public List <SP_GetEvaDataByEvaID_Result> getApprove(string EmpID, int EvaID) { //string EmpIDs = EmpID.ToString(); var header = ServiceContainer.GetService <PesWeb.Service.Modules.EvaManage>(); tblEmployee em = header.getEmployees().Where(a => a.EmployeeNo == EmpID).FirstOrDefault(); if (em != null) { if (em.PositionNo == 23) { } } List <tblEvaluation> eva = header.GetAllEvaluation().Where(a => a.EvaStatus == 1).ToList(); return(header.getEvaDataByEvaID(EvaID).ToList()); }
public ActionResult createNewAdminAccount(tblEmployee tblEmployee, tblLogin tblLogin) { if (Session["user"] != null && Session["loginID"] != null) { bool findEmployee = db.tblEmployees.Where(x => x.FirstName.Equals(tblEmployee.FirstName) && x.LastName.Equals(tblEmployee.LastName)).Any(); if (findEmployee) { RedirectToAction("Index", "Home"); } else { if (ModelState.IsValid) { tblLogin newLogin = new tblLogin(); { newLogin.Password = tblEmployee.tblLogin.Password; newLogin.IsDefault = "true"; } db.tblLogins.Add(newLogin); db.SaveChanges(); tblEmployee newEmployee = new tblEmployee(); { newEmployee.LoginID = newLogin.loginID; newEmployee.FirstName = tblEmployee.FirstName; newEmployee.LastName = tblEmployee.LastName; newEmployee.PhoneNumber = tblEmployee.PhoneNumber; newEmployee.Email = tblEmployee.Email; } using (db) { db.tblEmployees.Add(newEmployee); db.SaveChanges(); } return(RedirectToAction("adminAccountList")); } return(View(tblEmployee)); } } else { RedirectToAction("Index", "Home"); } return(View()); }
public MainWindowViewModel(MainWindow mainOpen) { main = mainOpen; employeeList = new List <tblEmployee>(); employee = new tblEmployee(); menagerToAdd = new tblEmployee(); employeeService = new EmployeeService(); roleService = new RoleService(); sectorService = new SectorService(); menagerService = new MenagerService(); //userList = service.GetAllUsers(); roles = roleService.GetAllRoles(); sectors = sectorService.GetAllSectors(); employeeList = employeeService.GetAllEmployees(); }
public void Map(tblEmployee emp) { emp.EmployeeID = this.EmployeeID; emp.FirstName = this.FirstName; emp.LastName = this.LastName; emp.Street = this.Street; emp.City = this.City; emp.State = this.State; emp.ZipCode = this.ZipCode; emp.Phone = this.Phone; emp.Email = this.Email; emp.UserName = this.UserName; emp.Password = this.Password; emp.Key = this.Key; emp.RoleID = this.RoleID; emp.IsActive = this.isActive; }
public ActionResult DeleteConfirmed(int id) { using (dbEmployeeEntities db = new dbEmployeeEntities()) { tblEmployee emp = db.tblEmployee.FirstOrDefault(p => p.ID == id); if (emp != null) { db.tblEmployee.Remove(emp); db.SaveChanges(); return(RedirectToAction("Index")); } else { return(HttpNotFound()); } } }
protected void btnUpdate_Click(object sender, EventArgs e) { tblEmployee result = get_Data_From_Form(); result.EmployeeId = Int32.Parse(Request.QueryString["id"]); Employee repository = new Employee(); if (repository.Update(result)) { this.ShowSuccessfulNotification("Employee updated."); Response.Redirect("~/pages/employee.aspx"); } else { this.ShowErrorNotification("Error occured"); } }
public ActionResult GetDataById(int empId) { tblEmployee mEmployee = new tblEmployee(); var efData = db.tblEmployees.Where(x => x.Id == empId).FirstOrDefault(); if (efData != null) { mEmployee.Name = efData.Name; mEmployee.Id = efData.Id; mEmployee.Surname = efData.Surname; mEmployee.DeptId = efData.DeptId; mEmployee.Address = efData.Address; mEmployee.Qualification = efData.Qualification; mEmployee.ContactNumber = efData.ContactNumber; } return(Json(mEmployee)); }
public tblEmployee AddEmployee(string city, string empname, string gender, int depid, DateTime dob, string contact, string email, string address, int posid) { var addemp = new tblEmployee() { CityName = city, EmployeeName = empname, Gender = gender, DepartmentId = depid, DateofBirth = dob, Contact = contact, Email = email, Address = address, PositionId = posid, }; return(addemp); }
public List <JObject> ApproveFlow(int EvaID) { var header = ServiceContainer.GetService <PesWeb.Service.Modules.EvaManage>(); tblApprove app = header.getApprove().Where(a => a.EvaID == EvaID).OrderByDescending(a => a.ID).FirstOrDefault(); List <tblFlowMaster> FlowList = header.getAllFlow().ToList(); List <tblApproveStatus> ApSList = header.GetApproveStatus().Where(a => a.ApproveID == app.ID).ToList(); List <JObject> Result = new List <JObject>(); List <tblEmployee> emp2 = header.getEmployees().ToList(); List <tblEmployeeOrganization> em = header.getEmployeeOrganization().Where(a => a.PositionNo == 21).ToList(); ApSList.ForEach(a => { JObject tmp = new JObject(); tmp["Date"] = ""; string str = ""; tblEmployee emp = new tblEmployee(); emp = null; if (a.EmployeeNO != null) { emp = emp2.Where(b => b.EmployeeNo.Trim() == a.EmployeeNO.Trim()).FirstOrDefault(); } str = "{\"EN\":\"\",\"TH\":\"\"}"; if (emp != null) { str = "{\"EN\":\"" + emp.EmployeeFirstName + " " + emp.EmployeeLastName + "\",\"TH\":\"" + emp.EmployeeFirstNameThai + " " + emp.EmployeeLastNameThai + "\"}"; } if (a.Status == 1) { tmp["Date"] = a.ApproveDate.ToString().Substring(0, 10).Replace("-", "/") + " " + ((a.ApproveDate.ToString().ElementAt(11) == ':')?'0' + a.ApproveDate.ToString().Substring(10, 4):a.ApproveDate.ToString().Substring(10, 5)); //((a.Date.ToString().ElementAt(11) == ':') ? '0' + a.Date.ToString().Substring(10, 4) : a.Date.ToString().Substring(10, 5)) } tmp["EmployeeNo"] = (emp != null)?a.EmployeeNO.Trim():null; tmp["Name"] = JsonConvert.DeserializeObject <JObject>(str); tmp["ProjectCode"] = app.ProjectCode; tmp["Role"] = "(" + a.FlowOrder + ")" + FlowList[(int)a.FlowOrder - 1].PositionName;; tmp["Status"] = a.Status; //tmp["NO"] = a.FlowOrder; Result.Add(tmp); }); return(Result); }
protected void rptVerifyEmployee_ItemCommand(object source, RepeaterCommandEventArgs e) { try { var DC = new DataClassesDataContext(); if (e.CommandName == "Email") { if (CheckForInternetConnection() == true) { tblEmployee EmpVerify = (from obj in DC.tblEmployees where obj.EmpID == Convert.ToInt32(e.CommandArgument) select obj).Single(); string Code = objVerify.SendMail(EmpVerify.EmailID); EmpVerify.VerifyCode = Code; EmpVerify.IsVerifyByAdmin = true; DC.SubmitChanges(); } else { ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Please Check your Internet Connection');", true); } } //DeleteVerify Employee if (e.CommandName == "Delete") { var Emp = (from obj in DC.tblEmployees where obj.EmpID == Convert.ToInt32(e.CommandArgument) select obj).Single(); DC.tblEmployees.DeleteOnSubmit(Emp); DC.SubmitChanges(); } BindVerifyEmployee(); } catch (Exception ex) { int session = Convert.ToInt32(Session["AdminID"].ToString()); string PageName = System.IO.Path.GetFileName(Request.Url.AbsolutePath); string MACAddress = GetMacAddress(); AddErrorLog(ref ex, PageName, "Admin", 0, session, MACAddress); ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true); } }
// Method that update Employee public vwEmployee EditEmployee(vwEmployee employee) { try { using (HotelDBEntities context = new HotelDBEntities()) { tblUser userToEdit = (from ss in context.tblUsers where ss.UserId == employee.UserId select ss).First(); userToEdit.Name = employee.Name; userToEdit.Surname = employee.Surname; userToEdit.DateOfBirth = employee.DateOfBirth; userToEdit.Email = employee.Email; userToEdit.Username = employee.Username; userToEdit.Password = employee.Password; userToEdit.UserId = employee.UserId; tblUser userEdit = (from ss in context.tblUsers where ss.UserId == employee.UserId select ss).First(); context.SaveChanges(); tblEmployee employeeToEdit = (from ss in context.tblEmployees where ss.UserId == employee.UserId select ss).First(); employeeToEdit.Floor = employee.Floor; employeeToEdit.Gender = employee.Gender; employeeToEdit.Citizenship = employee.Citizenship; employeeToEdit.Responsability = employee.Responsability; employeeToEdit.Salary = employee.Salary; employeeToEdit.EmployeeID = employee.EmployeeID; tblEmployee employeeEdit = (from ss in context.tblEmployees where ss.EmployeeID == employee.EmployeeID select ss).First(); context.SaveChanges(); return(employee); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString()); return(null); } }
public IHttpActionResult PuttblEmployee(int id, EmployeeModel employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employee.ID) { return(BadRequest()); } tblEmployee tblEmployee = new tblEmployee() { ID = employee.ID, DepartmentId = employee.DepartmentId, FirstName = employee.FirstName, LastName = employee.LastName, Gender = employee.Gender, Salary = employee.Salary, JobTitle = employee.JobTitle, JoiningDate = employee.JoiningDate == DateTime.MinValue ? (DateTime)SqlDateTime.Null : (DateTime)employee.JoiningDate, InService = employee.InService, LeavingDate = employee.LeavingDate == null ? (DateTime)SqlDateTime.Null : employee.LeavingDate }; db.Entry(tblEmployee).State = EntityState.Modified; try { db.SaveChanges(); return(Ok(new { Message = "SUCCESS" })); } catch (DbUpdateConcurrencyException) { if (!TblEmployeeExists(id)) { return(NotFound()); } else { throw; } } }
public bool Delete(int id) { try { tblEmployee result = Get(id); if (result != null) { result.Deleted = true; repository.SaveChanges(); return(true); } return(false); } catch (Exception) { return(false); } }
public bool Update(tblEmployee obj) { try { tblEmployee result = Get(obj.EmployeeId); if (result != null) { repository.Entry(result).CurrentValues.SetValues(obj); repository.SaveChanges(); return(true); } return(false); } catch (Exception) { return(false); } }
public tblEmployee GetUsernamePassword(string username, string password) { try { using (ManagerAppEntities context = new ManagerAppEntities()) { tblEmployee emoloyee = (from e in context.tblEmployees where e.UsernameLogin.Equals(username) where e.PasswordLogin.Equals(password) select e).First(); return(emoloyee); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString()); return(null); } }
public tblEmployee GetEmployeeEmail(string email) { try { using (ManagerAppEntities context = new ManagerAppEntities()) { tblEmployee emoloyee = (from e in context.tblEmployees where e.EMail.Equals(email) select e).First(); return(emoloyee); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString()); return(null); } }
partial void DeletetblEmployee(tblEmployee instance);
private void detach_tblEmployees(tblEmployee entity) { this.SendPropertyChanging(); entity.tblDepartment = null; }
partial void InserttblEmployee(tblEmployee instance);
partial void UpdatetblEmployee(tblEmployee instance);