Ejemplo n.º 1
0
        public async Task <bool> UpdateEmployee(tbl_employee model)
        {
            try
            {
                using (var uow = _unitOfWorkFactory.Create())
                {
                    var result = await FindByIdAmortization(model.autonum);

                    if (result != null)
                    {
                        uow.EmployeeRepository.Update(model);
                        await uow.SaveChangesAsync();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 2
0
 public HttpResponseMessage Edit(int id, [FromBody] tbl_employee employee)
 {
     try
     {
         using (empEntities entities = new empEntities())
         {
             var entity = entities.tbl_employee.FirstOrDefault(e => e.Id == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee with ID" + id.ToString() + " not found"));
             }
             else
             {
                 entity = employee;
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, entity));
             }
             //entity.Id = employee.Id;
             //entity.Name = employee.Name;
             //entity.Gender = employee.Gender;
         }
     }
     catch (Exception e)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
     }
 }
Ejemplo n.º 3
0
        // DELETE api/Employee/5
        public void Delete(int id)
        {
            tbl_employee temp = db.tbl_employee.Where(x => x.Id == id).FirstOrDefault();

            db.tbl_employee.Remove(temp);
            db.SaveChanges();
        }
Ejemplo n.º 4
0
 // PUT api/Employee/5
 public void Put(int id, tbl_employee emp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emp).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 // PUT api/Employee/5
 public void Put(int id, tbl_employee emp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emp).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            tbl_employee tbl_employee = db.tbl_employee.Find(id);

            db.tbl_employee.Remove(tbl_employee);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        public void AddEmployee(tbl_employee emp)
        {
            EFDal dal = new EFDal();

            //tbl_employee employee = new tbl_employee();

            dal.AddEmployee(emp);
        }
        public HttpResponseMessage SaveLabour(HttpRequestMessage request, LabourViewModel savelabour)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    //start of saving to master emp table
                    var codeFormat = _settingsRepository.GetAll().Where(t => t.tenant_id == savelabour.tenant_id).FirstOrDefault();
                    var exsistingEmployees = _EmployeeRepository.GetAll().Where(e => e.tenant_id == savelabour.tenant_id);

                    tbl_employee newEmployeeMaster = new tbl_employee();
                    int empCount = exsistingEmployees.Count();

                    if (empCount <= 0)
                    {
                        newEmployeeMaster.emp_code = codeFormat.emp_code;
                        newEmployeeMaster.code_seperation = codeFormat.code_seperation;
                        newEmployeeMaster.emp_num = codeFormat.emp_num;
                    }
                    else
                    {
                        var lastERec = _EmployeeRepository.GetAll().Where(e => e.tenant_id == savelabour.tenant_id).OrderByDescending(e => e.id).First();
                        // var lastERec = _EmployeeRepository.GetSingle(empCount);
                        newEmployeeMaster.emp_code = lastERec.emp_code;
                        newEmployeeMaster.code_seperation = lastERec.code_seperation;
                        newEmployeeMaster.emp_num = lastERec.emp_num + 1;
                    }

                    newEmployeeMaster.tenant_id = savelabour.tenant_id;
                    newEmployeeMaster.project_id = savelabour.project_id;
                    newEmployeeMaster.Designation = "Labour";
                    newEmployeeMaster.emp_name = savelabour.name;
                    newEmployeeMaster.date_created = DateTime.Now;
                    newEmployeeMaster.CreatedBy = "Admin";

                    _EmployeeRepository.Add(newEmployeeMaster);
                    //_unitOfWork.Commit();


                    //end of saving to master emp table.



                    tbl_labour newlabour = new tbl_labour();
                    newlabour.master_emp_id = _EmployeeRepository.GetAll().Count() + 1;
                    newlabour.AddLabour(savelabour);
                    _labourRepository.Add(newlabour);
                    _unitOfWork.Commit();
                    response = request.CreateResponse <LabourViewModel>(HttpStatusCode.Created, savelabour);
                }
                return response;
            }));
        }
Ejemplo n.º 9
0
 public static void AddEmployeeMaster(this tbl_employee employee, EmployeeViewModel employeeVm)
 {
     employee.tenant_id   = employeeVm.tenant_id;
     employee.project_id  = employeeVm.project_id;
     employee.Designation = employeeVm.Designation;
     employee.emp_name    = employeeVm.emp_name;
     //employee.date_created = employeeVm.date_created;
     employee.date_created = TimeZoneInfo.ConvertTimeFromUtc(employeeVm.date_created, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
     employee.CreatedBy    = employeeVm.CreatedBy;
 }
Ejemplo n.º 10
0
        // GET api/Employee/5
        public tbl_employee Get(int id)
        {
            tbl_employee emp = db.tbl_employee.Find(id);

            if (emp == null)
            {
                return(null);
            }
            return(emp);
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> PostEmployees([FromBody] tbl_employee model)
        {
            if (model == null)
            {
                return(BadRequest());
            }
            _context.tbl_employee.Add(model);
            await _context.SaveChangesAsync();

            return(Ok(new { message = "saved successfully" }));
        }
 public ActionResult Edit([Bind(Include = "employee_status,Id,employeeName,employeeAge,salary,bouns,rate,hoursWorked")] tbl_employee tbl_employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.employee_status = new SelectList(db.tbl_status, "employee_status", "employee_status", tbl_employee.employee_status);
     return(View(tbl_employee));
 }
Ejemplo n.º 13
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        EFDal dal    = new EFDal();
        var   record = new tbl_employee
        {
            Ecode  = int.Parse(textecode.Text),
            Salary = int.Parse(textsalary.Text),
        };

        dal.updateEmp(record);
        Label1.Text = "Updated Successfully!!!";
    }
Ejemplo n.º 14
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            var record = new tbl_employee
            {
                Ecode  = int.Parse(txtEcode.Text),
                salary = int.Parse(txtSalary.Text)
            };
            var dal = new EFDal();

            dal.UpdateEmp(record);
            MessageBox.Show("record updated");
            dgv.DataSource = dal.GetAllEmps();
        }
Ejemplo n.º 15
0
    protected void btnupdate_Click(object sender, EventArgs e)
    {
        EmpServiceClient proxy = new EmpServiceClient("BasicHttpBinding_IEmpService");
        var result             = new tbl_employee
        {
            Ecode  = int.Parse(txtecode.Text),
            salary = int.Parse(txtsalary.Text)
        };

        proxy.UpdateEmp(result);
        GridView1.DataSource = proxy.GetAllEmps().ToList();
        GridView1.DataBind();
    }
        public async Task <bool> AddEmployee(EmployeeModel employeeModel)
        {
            var employee = new tbl_employee()
            {
                employee_name    = employeeModel.Name,
                employee_email   = employeeModel.Email,
                employee_address = employeeModel.Address,
                employee_phoneNo = employeeModel.Phone
            };

            emp.tbl_employee.Add(employee);
            return(await emp.SaveChangesAsync() > 0);
        }
Ejemplo n.º 17
0
 public void Save()
 {
     using (var context = new CashCarryEntities3())
     {
         if (Username == null && Password == null && LoginType == 0)
         {
             tbl_employee objemp = new tbl_employee()
             {
                 Name         = Name,
                 Fname        = Fname,
                 Gender       = Gender,
                 Password     = null,
                 Qualifiction = Qualifiction,
                 Username     = null,
                 DOB          = DOB,
                 Designation  = Designation,
                 Contact      = Contact,
                 Cnic         = Cnic,
                 Address      = Address,
                 AsignDate    = AsignDate,
                 Salary       = Salary,
                 LoginTypeID  = 0
             };
             context.tbl_employee.Add(objemp);
             context.SaveChanges();
         }
         else
         {
             tbl_employee objemp = new tbl_employee()
             {
                 Name         = Name,
                 Fname        = Fname,
                 Gender       = Gender,
                 Password     = Password,
                 Qualifiction = Qualifiction,
                 Username     = Username,
                 DOB          = DOB,
                 Designation  = Designation,
                 Contact      = Contact,
                 Cnic         = Cnic,
                 Address      = Address,
                 AsignDate    = AsignDate,
                 Salary       = Salary,
                 LoginTypeID  = LoginType
             };
             context.tbl_employee.Add(objemp);
             context.SaveChanges();
         }
     }
 }
Ejemplo n.º 18
0
        public ActionResult UpdateEmp(Employee emp)
        {
            EFDal        dal = new EFDal();
            tbl_employee e   = new tbl_employee
            {
                Ecode  = emp.Ecode,
                Ename  = emp.Ename,
                salary = emp.salary,
                deptid = emp.deptid
            };

            dal.UpdateEmp(e);
            return(RedirectToAction("DisplayAllEmps"));
        }
        // GET: tbl_employee/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_employee tbl_employee = db.tbl_employee.Find(id);

            if (tbl_employee == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_employee));
        }
Ejemplo n.º 20
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        var record = new tbl_employee
        {
            Ecode  = int.Parse(textecode.Text),
            Ename  = textename.Text,
            Salary = int.Parse(textsalary.Text),
            Deptid = int.Parse(textdepid.Text)
        };
        EFDal dal = new EFDal();

        dal.AddEmployee(record);
        Label1.Text = "Inserted Successfully!!!";
    }
        // GET: tbl_employee/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_employee tbl_employee = db.tbl_employee.Find(id);

            if (tbl_employee == null)
            {
                return(HttpNotFound());
            }
            ViewBag.employee_status = new SelectList(db.tbl_status, "employee_status", "employee_status", tbl_employee.employee_status);
            return(View(tbl_employee));
        }
        public string SaveEmployee(EmployeeModel model)
        {
            string           message = "";
            EmployeeEntities db      = new EmployeeEntities();
            var saveEmployee         = new tbl_employee()
            {
                FirstName  = model.FirstName,
                LastName   = model.LastName,
                Department = model.Department,
            };

            db.tbl_employee.Add(saveEmployee);
            db.SaveChanges();
            message = "Employee Added Succesfully";
            return(message);
        }
Ejemplo n.º 23
0
 private double?CalcEarnings(DB db, tbl_employee emp)
 {
     if (emp.rate != null && emp.hoursWorked != null)
     {
         ptEmployee ptemp = new ptEmployee(emp.Id, emp.employeeName, emp.employeeAge, emp.rate, emp.hoursWorked);
         elist.Add(ptemp);
         return(emp.rate * emp.hoursWorked);
     }
     else if (emp.salary != null && emp.bouns != null)
     {
         FtEmployee ftemp = new FtEmployee(emp.Id, emp.employeeName, emp.employeeAge, emp.bouns, emp.salary);
         elist.Add(ftemp);
         return(emp.salary + emp.bouns);
     }
     return(0);
 }
Ejemplo n.º 24
0
    protected void btninsert_Click(object sender, EventArgs e)
    {
        EmpServiceClient proxy = new EmpServiceClient("BasicHttpBinding_IEmpService");

        var result = new tbl_employee
        {
            Ecode  = int.Parse(txtecode.Text),
            Ename  = txtename.Text,
            salary = int.Parse(txtsalary.Text),
            deptid = int.Parse(txtdeptid.Text)
        };

        proxy.AddEmployee(result);
        GridView1.DataSource = proxy.GetAllEmps().ToList();
        GridView1.DataBind();
    }
Ejemplo n.º 25
0
        public async Task <IActionResult> UpdateEmployees([FromBody] tbl_employee model)
        {
            if (model == null)
            {
                return(BadRequest());
            }
            var res = await _context.tbl_employee.FirstOrDefaultAsync(x => x.EmployeeID == model.EmployeeID);

            if (res == null)
            {
                return(NotFound());
            }
            res.Name = model.Name;
            res.Job  = model.Job;
            await _context.SaveChangesAsync();

            return(Ok(new { message = "updated successfully" }));
        }
Ejemplo n.º 26
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            //take user input for insert
            var record = new tbl_employee
            {
                Ecode  = int.Parse(txtEcode.Text),
                Ename  = txtEname.Text,
                salary = int.Parse(txtSalary.Text),
                deptid = int.Parse(txtDeptid.Text)
            };
            //insert using dal
            var dal = new EFDal();

            dal.AddEmployee(record);
            MessageBox.Show("record inserted");

            //referesh the data
            dgv.DataSource = dal.GetAllEmps();
        }
Ejemplo n.º 27
0
        public HttpResponseMessage Insert([FromBody] tbl_employee employee)
        {
            try
            {
                using (empEntities entities = new empEntities())
                {
                    entities.tbl_employee.Add(employee);
                    entities.SaveChanges();

                    var message = Request.CreateResponse(HttpStatusCode.Created, employee);
                    message.Headers.Location = new Uri(Request.RequestUri + employee.Id.ToString());
                    return(message);
                }
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
            }
        }
        public HttpResponseMessage AddEmployee(HttpRequestMessage request, EmployeeViewModel employee)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var codeFormat = _settingsRepository.GetAll().Where(t => t.tenant_id == employee.tenant_id).FirstOrDefault();
                    var exsistingEmployees = _EmployeeRepository.GetAll().Where(e => e.tenant_id == employee.tenant_id);

                    tbl_employee newEmployeeMaster = new tbl_employee();
                    int empCount = exsistingEmployees.Where(t => t.tenant_id == employee.tenant_id).Count();

                    if (empCount <= 0)
                    {
                        newEmployeeMaster.emp_code = codeFormat.emp_code;
                        newEmployeeMaster.code_seperation = codeFormat.code_seperation;
                        newEmployeeMaster.emp_num = codeFormat.emp_num;
                    }
                    else
                    {
                        // var lastERec = _EmployeeRepository.GetAll().Where(e=>e.tenant_id==employee.tenant_id).GroupBy(e=>e.tenant_id).Select(y=>new { tenant_id=y.Key,  lastrecord=y.OrderByDescending(e=>e.emp_num).FirstOrDefault()});
                        var lastERec = _EmployeeRepository.GetAll().Where(e => e.tenant_id == employee.tenant_id).OrderByDescending(e => e.id).First();
                        newEmployeeMaster.emp_code = lastERec.emp_code;
                        newEmployeeMaster.code_seperation = lastERec.code_seperation;
                        newEmployeeMaster.emp_num = lastERec.emp_num + 1;
                    }


                    newEmployeeMaster.AddEmployeeMaster(employee);
                    _EmployeeRepository.Add(newEmployeeMaster);
                    _unitOfWork.Commit();
                    response = request.CreateResponse <EmployeeViewModel>(HttpStatusCode.Created, employee);
                }
                return response;
            }));
        }
Ejemplo n.º 29
0
        private string ShowVehicleInEmployee(DB db, tbl_employee emp)
        {
            string             output = "";
            List <tbl_vehicle> vlist  = db.GetVehicles(emp);

            if (vlist.Count > 0)
            {
                foreach (tbl_vehicle vehicle in vlist)
                {
                    output += SPACES + "PLate Number" + SPACES + vehicle.plateNumber + NL
                              + SPACES + "Make" + SPACES + vehicle.make + NL
                              + SPACES + "Modle" + SPACES + vehicle.model + NL;
                }
            }
            else
            {
                output += "Employee Does Not have a vehicle" + NL;
            }
            output += "-------------------------------" + NL;
            return(output);
        }
        // PUT: api/EmpService/5
        public void Put(int id, [FromBody] tbl_employee emp)
        {
            EFDal dal = new EFDal();

            dal.UpdateEmp(emp);
        }
        // POST: api/EmpService
        public void Post([FromBody] tbl_employee emp)
        {
            EFDal dal = new EFDal();

            dal.AddEmployee(emp);
        }
 // POST api/Employee
 public void Post(tbl_employee emp)
 {
     db.tbl_employee.Add(emp);
     db.SaveChanges();
 }