private static void AddEmploy() { try { Employ newEmploy = new Employ(); //Console.WriteLine("Enter GuestID :"); //newGuest.GuestID = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Employ Name :"); newEmploy.EmployName = Console.ReadLine(); Console.WriteLine("Enter Department :"); newEmploy.Department = Console.ReadLine(); Console.WriteLine("Enter Salary "); newEmploy.Salary = Convert.ToInt32(Console.ReadLine()); bool employAdded = EmployBL.AddEmployBL(newEmploy); if (employAdded) { Console.WriteLine("Employ Added"); } else { Console.WriteLine("Employ not Added"); } } catch (EmployException ex) { Console.WriteLine(ex.Message); } catch (Exception e) { Console.WriteLine(e.Message); } }
private void FConst1_Load(object sender, EventArgs e) { Employ employee = new Employ(); employee.FName = "Ysf"; employee.LName = "Bzkr"; employee.Phone = "5555555"; employee.Mail = "*****@*****.**"; employee.Address = "ist"; Employ emp1 = new Employ("Murat"); emp1.LName = "Vrnk"; emp1.Phone = "5555555"; emp1.Mail = "*****@*****.**"; emp1.Address = "ist"; Employ emp2 = new Employ("Murat", "Vrnk"); emp2.Phone = "5555555"; emp2.Mail = "*****@*****.**"; emp2.Address = "ist"; Employ emp3 = new Employ("Murat", "Vrnk", "5555555"); emp3.Mail = "*****@*****.**"; emp3.Address = "ist"; Employ emp4 = new Employ("Murat", "Vrnk", "5555555", "*****@*****.**"); emp4.Address = "ist"; Employ emp5 = new Employ("Murat", "Vrnk", "5555555", "*****@*****.**", "ist"); }
private static void DeleteEmploy() { try { int deleteEmployID; Console.WriteLine("Enter EmployID to Delete:"); deleteEmployID = Convert.ToInt32(Console.ReadLine()); Employ deleteEmploy = EmployBL.SearchEmployBL(deleteEmployID); if (deleteEmploy != null) { bool guestdeleted = EmployBL.DeleteEmployBL(deleteEmployID); if (guestdeleted) { Console.WriteLine("Employ Deleted"); } else { Console.WriteLine("Employ not Deleted "); } } else { Console.WriteLine("No Employ Details Available"); } } catch (EmployException ex) { Console.WriteLine(ex.Message); } }
private static void SearchEmployByID() { try { int searchEmployID; Console.WriteLine("Enter EmployID to Search:"); searchEmployID = Convert.ToInt32(Console.ReadLine()); Employ searchEmploy = EmployBL.SearchEmployBL(searchEmployID); if (searchEmploy != null) { Console.WriteLine("******************************************************************************"); Console.WriteLine("EmployID\t\tName\t\tDepartment\t\tSalary"); Console.WriteLine("******************************************************************************"); Console.WriteLine("{0}\t\t{1}\t\t{2}{3}", searchEmploy.EmployID, searchEmploy.EmployName, searchEmploy.Department, searchEmploy.Salary); Console.WriteLine("******************************************************************************"); } else { Console.WriteLine("No Employ Details Available"); } } catch (EmployException ex) { Console.WriteLine(ex.Message); } }
public bool UpdateEmployDAL(Employ employ) { bool employupdated = false; try { Employ oldEmploy = null; oldEmploy = context.Employs.Where(e => e.EmployID == employ.EmployID).Select(e => e).FirstOrDefault(); if (oldEmploy != null) { oldEmploy.EmployName = employ.EmployName; oldEmploy.Department = employ.Department; oldEmploy.Salary = employ.Salary; int status = context.SaveChanges(); if (status > 0) { employupdated = true; } } } catch (Exception ex) { throw new EmployException(ex.Message); } return(employupdated); }
protected void btnAdd_Click(object sender, EventArgs e) { if (txtEmpno.Text == string.Empty) { ScriptManager.RegisterStartupScript(this, this.GetType(), "m2", "alert('Please enter id to search')", true); } else { try { int searchid = Convert.ToInt32(txtEmpno.Text); Employ employ = EmployBLL.GetEmployBLL(searchid); if (employ != null) { txtname.Text = employ.Name; txtDept.Text = employ.Department; txtDesig.Text = employ.Designation; txtbasic.Text = employ.Basic.ToString(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "m4", "alert('Employ not available')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "error1", "alert('" + ex.Message + "')", true); } } }
public IHttpActionResult PutEmploy(int id, Employ employ) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employ.ID) { return(BadRequest()); } db.Entry(employ).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Dept")] Employ employ) { if (id != employ.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employ); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployExists(employ.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(employ)); }
protected void btnAdd_Click(object sender, EventArgs e) { Employ employ = new Employ(); try { employ.Empno = Convert.ToInt32(txtEmpno.Text); employ.Name = txtname.Text; employ.Department = txtDept.Text; employ.Designation = txtDesig.Text; employ.Basic = Convert.ToInt32(txtbasic.Text); bool status = EmployBLL.AddEmployBLL(employ); if (status) { ScriptManager.RegisterStartupScript(this, this.GetType(), "M1", "alert('Employ Details Added')", true); txtEmpno.Text = ""; txtname.Text = ""; txtDept.Text = ""; txtDesig.Text = ""; txtbasic.Text = ""; } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "M1", "alert('" + ex.Message + "')", true); } }
public async Task <string> CreateOrUpdateEmploy(Employ employs) { string Message = ""; using (_unitOfWork) { using (var transaction = _dbw.Database.BeginTransaction()) { try { var userId = employs.id; //var userId = 18; if (employs.id == 0) { //employs.Date = DateTime.Now; employs.Date = employs.Date; employs.empname = employs.empname; employs.empid = employs.empid; await _dbw.employs.AddAsync(employs); _dbw.SaveChanges(); Message = "created successfully"; //auditTraildata.ExecuteAudit("Role", role.Id, role.CreatedById, role.LoginUSerPlantId, role.RoleName, null, 0, (int)EnumDBActions.Create, "Role Name", role.Comments, role.LoginUSerPlant, role.LoginUSerName, _batchContext); } else { var roleExist = await _dbw.employs.AsNoTracking().Where(w => w.id == employs.id).FirstOrDefaultAsync(); if (roleExist != null) { roleExist.empname = employs.empname; //roleExist.Date = DateTime.Now; roleExist.Date = employs.Date; roleExist.empid = employs.empid; } _dbw.employs.Update(roleExist); _dbw.SaveChanges(); Message = "created successfully"; } transaction.Commit(); return(Message); } catch (Exception Ex) { Message = "issue"; // Message = "TransactionFail"; transaction.Rollback(); return(Message); } } return(Message); } }
public static void SearchEmploy() { try { Employ empSearch = null; int empno; Console.WriteLine("Enter Employ no "); empno = Convert.ToInt32(Console.ReadLine()); empSearch = objValidation.SearchEmployBLL(empno); if (empSearch != null) { Console.WriteLine("Name " + empSearch.Name); Console.WriteLine("Mobile " + empSearch.Mobile); Console.WriteLine("Department " + empSearch.Dept); Console.WriteLine("Designation " + empSearch.Desig); Console.WriteLine("Salary " + empSearch.Salary); } } catch (EmployException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } }
public bool DeleteEmployDAL(int employID) { bool employDeleted = false; try { Employ employ = null; employ = context.Employs.Where(e => e.EmployID == employID).Select(e => e).FirstOrDefault(); if (employ != null) { context.Employs.Remove(employ); int status = context.SaveChanges(); if (status > 0) { employDeleted = true; } } } catch (Exception ex) { throw new EmployException(ex.Message); } return(employDeleted); }
private static bool Validate(Employ employ) { StringBuilder sb = new StringBuilder(); bool validateEmploy = true; if (employ.EmployName == string.Empty) { validateEmploy = false; sb.Append(Environment.NewLine + "Employ Name Required"); } if (employ.Salary < 1000) { validateEmploy = false; sb.Append(Environment.NewLine + "Salary cannot be less than 1000"); } if (employ.Salary > 99999) { validateEmploy = false; sb.Append(Environment.NewLine + "Salary cannot cross 99999"); } if (validateEmploy == false) { throw new EmployException(sb.ToString()); } return(validateEmploy); }
public static void UpdateEmploy() { try { Employ emp = new Employ(); Console.WriteLine("Enter Employee Id to be updated:"); emp.Empno = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter Employee Name :"); emp.Name = Console.ReadLine(); Console.WriteLine("Enter Employee Department :"); emp.Dept = Console.ReadLine(); Console.WriteLine("Enter Employee Salary :"); emp.Salary = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Employee DOJ :"); emp.Doj = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Enter Employee Designation :"); emp.Desig = Console.ReadLine(); Console.WriteLine("Enter Employee Mobile :"); emp.Mobile = Console.ReadLine(); if (objValidation.UpdateEmployBLL(emp)) { Console.WriteLine("Employ Updated..."); } } catch (EmployException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } }
public int AddEmployee(Employ emp) { con = new SqlConnection(constring); cmd = new SqlCommand("usp_addEmployee", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Employ_id", emp.Emp_id); cmd.Parameters.AddWithValue("@Employ_name", emp.Emp_name); cmd.Parameters.AddWithValue("@Employ_salary", emp.Emp_salary); cmd.Parameters.AddWithValue("@Employ_dept", emp.Emp_dept); SqlParameter param = new SqlParameter("@emp_out", SqlDbType.Int); param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); con.Open(); int n = cmd.ExecuteNonQuery(); int emp_out = 0; if (n > 0) { emp_out = Convert.ToInt32(cmd.Parameters["@emp_out"].Value); } return(emp_out); }
public void InsertEmploy(Employ employ) { rowsAffected = 0; string sql = "INSERT INTO Employ (ID,Name,Age,Salary)"; sql += $"VALUES ({employ.ID},'{employ.Name}',{employ.Age},{employ.Salary})"; try { using (SqlConnection con = new SqlConnection("Server=DESKTOP-GNPRQ15\\SUSI;Database=HR;Trusted_Connection=True;")) { using (SqlCommand cmd = new SqlCommand(sql, con)) { cmd.CommandType = CommandType.Text; con.Open(); rowsAffected = cmd.ExecuteNonQuery(); ResultText = "Rows Affected: " + rowsAffected.ToString(); } } } catch (Exception ex) { ResultText = ex.ToString(); } }
public static bool ValidateEmploy(Employ employ) { bool result = true; StringBuilder sb = new StringBuilder(); if (employ.Empno <= 0 || employ.Empno == null) { result = false; sb.Append("Empno cannot be blank or negative"); } if (employ.Name == string.Empty) { result = false; sb.Append("Employ Name cannot be blank"); } if (employ.Department == string.Empty) { result = false; sb.Append("Department cannot be blank"); } if (employ.Designation == string.Empty) { result = false; sb.Append("Designation cannot be blank"); } if (result == false) { throw new EmployExceptions.EmployException(sb.ToString()); } return(result); }
/*private void OnMouseUp() * { * if(GameManager.Instance.mouseIsDragging && (!isOccupied)) * { * SetOccupant(GameManager.Instance.mousePayLoad); * GameManager.Instance.MouseDropPickUp(); * } * }*/ public void SetOccupant(Employ e) { occupant = e; isOccupied = true; occupantGraphic.SetActive(true); occupant.currentWorkSpace = this; }
public bool ValidateEmploy(Employ newEmploy) { bool isValidEmploy = true; StringBuilder sb = new StringBuilder(); if (newEmploy.Empno <= 0) { isValidEmploy = false; sb.Append("Employ No Cannot be Zero or Negative " + Environment.NewLine); } if (newEmploy.Name.Length == 0) { isValidEmploy = false; sb.Append("Name Cannot be Empty..." + Environment.NewLine); } if (newEmploy.Doj >= DateTime.Now) { isValidEmploy = false; sb.Append("Doj cannot be tomorrow's date..." + Environment.NewLine); } if (!(Regex.IsMatch(newEmploy.Mobile, "[0-9]{10}"))) { isValidEmploy = false; sb.Append("Employee Mobile should have 10 digits " + Environment.NewLine); } if (!isValidEmploy) { throw new EmployException(sb.ToString()); } return(isValidEmploy); }
//public IActionResult Search(int id) //{ // Employ emp1 = empr.GetEmploy(id); //if we give id respective details will be printed // if (emp1 != null) // { // return Content(emp1.Id + "\n" + emp1.Name + "\n" + emp1.Email + "\n" + emp1.dept); // } // else // return Content("employ does not exist"); public IActionResult Search(int?id) { int ID = (int)((id == null) ? 1 : id); Employ emp1 = empr.GetEmploy(ID); //if (emp1 != null) //{ // return Content(emp1.Id + "\n" + emp1.Name + "\n" + emp1.Email + "\n" + emp1.dept); //} //else // return Content("employ does not exist"); //ViewData["id"] = emp1.Id; //ViewData["name"] = emp1.Name; //ViewData["email"] = emp1.Email; //ViewData["dept"] = emp1.dept; ViewData["Employ"] = emp1; ViewBag.Employ = emp1; //ViewBag.id = emp1.Id; //ViewBag.name = emp1.Name; //ViewBag.email = emp1.Email; //ViewBag.dept = emp1.dept; return(View(emp1)); }
public ActionResult DeleteConfirmed(int id) { Employ employ = db.Employs.Find(id); db.Employs.Remove(employ); db.SaveChanges(); return(RedirectToAction("Index")); }
//Interface empr = new Employr(); public ActionResult Search(int?id) { int ID = (int)((id == null) ? 1 : id); Employ emp1 = empr.GetEmploy(ID); ViewData["Employ"] = "emp1"; return(View(emp1)); }
public async void AllocateTechnician(string id, string techid) { Employ NewEmploy = new Employ(); NewEmploy.TechnicianID = techid; NewEmploy.ProjectID = id; _context.Employ.Add(NewEmploy); await _context.SaveChangesAsync(); }
static void Main(string[] args) { Employ employ = new Employ(); Console.Write("请输入月工资:"); int monthmoney = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("年工资为:{0}", employ.Getyearmoney(monthmoney)); }
public ViewResult AboutEmp() { Employ emp = empr.GetEmploy(2); //ViewBag.projectname = "employee"; EmployProjectViewModel ep = new EmployProjectViewModel(); ep.employ = emp; ep.projectname = "CBSE"; return(View(ep)); }
public async Task <string> DeleteDepartment(Employ employs) { string Message = ""; Employ emp = await _dbw.employs.Where(a => a.id == employs.id).FirstOrDefaultAsync(); _dbw.employs.Remove(emp); await _dbw.SaveChangesAsync(); Message = "deleted successfully"; return(Message); }
public Employ ShowDetail(int?eid) { Employ employ = new Employ(); using (var dbContext = new CasemanaContext()) { employ = dbContext.Employ.FirstOrDefault(x => x.Eid == eid); } return(employ); }
//public ActionResult GridModifyHandler(FormCollection post,TestEmployeeCs TEC) public ActionResult GridModifyHandler(FormCollection post) { //var qq = post.NameA; //沒有beginform的要用formcollection var employees = new Employ().GetEmployeeList <TestEmployeeCs>().ToList(); var empQuery = from emp in employees where emp.Age > 20 select emp; return(Json(employees, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(Employ employ) { bool status = EmployBLL.UpdateEmployBLL(employ); if (status) { return(RedirectToAction("Index", "Employ")); } return(View()); }
public ViewResult AboutEmploy() { Employ emp1 = empr.GetEmploy(2); // ViewBag.projectname = "BOOKHIVE"; Employprojviewmodel ep = new Employprojviewmodel(); ep.employ = emp1; ep.projectname = "BOOK HIVE"; return(View(ep)); }