Ejemplo n.º 1
0
        public bool UpdateEmployeeWithoutPassword(TblEmployee Employee)
        {
            string StoreProc = "spUpdateEmployeeWithoutPass";

            object[] parms = new object[]
            {
                "@EmpID", Employee.EmployeeID,
                "@Name", Employee.Name,
                "@DOB", Employee.DOB,
                "@Address", Employee.Address,
                "@Phone", Employee.Phone,
                "@RoleID", Employee.RoleID
            };
            return(db.Update(StoreProc, parms) > 0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Posts the employee asynchronous.
        /// </summary>
        /// <param name="employee">The employee.</param>
        /// <returns></returns>
        public async Task <bool> PostEmployeeAsync(TblEmployee employee)
        {
            try
            {
                await _context.TblEmployees.AddAsync(employee);

                await _context.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        //To Delete the record of a particular employee
        public int DeleteEmployee(int id)
        {
            try
            {
                TblEmployee emp = db.TblEmployee.Find(id);
                db.TblEmployee.Remove(emp);
                db.SaveChanges();

                return(1);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Deletes the employee asynchronous.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public async Task <bool> DeleteEmployeeAsync(int id)
        {
            try
            {
                TblEmployee employee = await GetEmployeeById(id);

                _context.TblEmployees.Remove(employee);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
    public void AddEmployee(TblEmployee employee)
    {
        try
        {
            IHttpContextAccessor httpContextAccessor = MyServiceLocator.Instance.GetService <IHttpContextAccessor>();
            IHostingEnvironment  hostingEnvironment  = MyServiceLocator.Instance.GetService <IHostingEnvironment>();;


            string folderName = "UploadFile/";
            string sPath      = "";
            sPath = Path.Combine(_hostingEnvironment.WebRootPath, "~/" + folderName);

            var hfc = _httpContextAccessor.HttpContext.Request.Form.Files;
        }
        catch {}
    }
Ejemplo n.º 6
0
        public ActionResult Employee([FromBody] Authorization login)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            TblEmployee tblEmployee = _context.TblEmployee.Where(x => x.EmployeeEmail == login.UserName & x.EmployeePassword == login.UserPassword).FirstOrDefault();

            if (tblEmployee == null)
            {
                return(NotFound());
            }

            return(Ok(tblEmployee));
        }
 public TblEmployee InsertTblEmployeeToDataBase(TblEmployee nEmp)
 {
     try
     {
         if (nEmp != null)
         {
             this.Context.TblEmployee.Add(nEmp);
             return(this.Context.SaveChanges() > 0 ? this.GetTblEmployeeWithKey(nEmp.EmployeeId) : null);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Has error " + ex.ToString());
     }
     return(null);
 }
Ejemplo n.º 8
0
        public ActionResult Delete(int id)
        {
            try
            {
                TblEmployee ob = uow.Modules.Employee.Get(id);
                if (ob == null)
                {
                    return(RedirectToAction("Index", MVCController, new { msg = "ไม่พบข้อมูลที่ต้องการ", msgType = AlertMsgType.Warning }));
                }

                uow.Modules.Employee.Delete(ob);
                uow.SaveChanges();
                return(RedirectToAction("Index", MVCController, new { msg = "ลบข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success }));
            }
            catch (Exception ex)
            { return(RedirectToAction("Index", MVCController, new { msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); }
        }
 public TblEmployee UpdateTblEmployeeToDataBase(int EmployeeID, TblEmployee uEmployee)
 {
     try
     {
         var dbEmployee = this.Context.TblEmployee.Find(EmployeeID);
         if (dbEmployee != null)
         {
             this.Context.Entry(dbEmployee).CurrentValues.SetValues(uEmployee);
             return(this.Context.SaveChanges() > 0 ? this.GetTblEmployeeWithKey(EmployeeID) : null);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Has error " + ex.ToString());
     }
     return(null);
 }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nMemoGroupID"></param>
        public frmReceipientGroupEntries(int nMemoGroupID)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            this.nMemoGroupID = nMemoGroupID;

            TblEmployee employee = new TblEmployee();
            DataTable   empTable = employee.SelectAll();

            new XtraUtils.LookupEditBuilder.EmployeeIDLookupEditBuilder(lkpEdtStaffID.Properties);
        }
Ejemplo n.º 11
0
        public bool CreateEmployee(TblEmployee empdata)
        {
            bool result = false;

            try
            {
                TblEmployee newEmployee = new TblEmployee();
                newEmployee.Name       = empdata.Name;
                newEmployee.Gender     = empdata.Gender;
                newEmployee.City       = empdata.City;
                newEmployee.Department = empdata.Department;
                dbContext.TblEmployee.Add(newEmployee);
                dbContext.SaveChanges();
                result = true;
            }
            catch
            {
            }
            return(result);
        }
Ejemplo n.º 12
0
 // POST api/values
 public HttpResponseMessage Post([FromBody] Employee emp)
 {
     try
     {
         if (emp == null)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, "Invalid data"));
         }
         else
         {
             var table = new TblEmployee();
             table.Name    = emp.Name;
             table.City    = emp.City;
             table.Address = emp.Address;
             db.TblEmployees.Add(table);
             db.SaveChanges();
             return(Request.CreateResponse(HttpStatusCode.OK, "Insertion Successful"));
         }
     }
     catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, "Error:" + ex.Message)); }
 }
 public int CreateEmployee(TblEmployee model)
 {
     try
     {
         var IsEmployeeExists = dbContext.TblEmployee.Where(x => x.FullName == model.FullName || x.UserName == model.UserName || x.PhoneNo == model.PhoneNo).FirstOrDefault();
         if (IsEmployeeExists != null)
         {
             return(0);
         }
         else
         {
             dbContext.Add(model);
             return(dbContext.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         StaticHelper.LogException(path: up.GetLogFilePath(), errorMessage: ex.Message, methodName: $"Repository name: {nameof(EmployeeRepository)} - Method name:  {nameof(CreateEmployee)}", stackTrace: ex.StackTrace);
         return(0);
     }
 }
Ejemplo n.º 14
0
 public int DeleteEmployee(int id)
 {
     try
     {
         TblEmployee employee = db.TblEmployee.Find(id);
         if (employee != null)
         {
             db.TblEmployee.Remove(employee);
             db.SaveChanges();
         }
         else
         {
             // Log
         }
         return(1);
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 15
0
        private ActionResult ViewDetail(TblEmployee ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                ViewData["optPrefix"]     = uow.Modules.Enum.PrefixGets();
                ViewData["optDepartment"] = uow.Modules.Department.Gets();
                ViewData["optPosition"]   = uow.Modules.Position.Gets(1, 0);
                ViewData["optLead"]       = uow.Modules.Employee.Gets();
                ViewData["optAccount"]    = uow.Modules.Account.Gets();

                ViewData["optEmpPermission"] = uow.Modules.EmployeeUserPermission.Gets(src: ob.AccountId.ToString());
                return(View(ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", MVCController, new
                {
                    area = MVCArea,
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Ejemplo n.º 16
0
        private void cloneData()
        {
            if (Session["HostelID"] != null)
            {
                TblHostelinformation obj = new TblHostelinformation(Session["HostelID"]);
                txtHostelName.Text      = obj.HostelName;
                txtHostelContact.Text   = obj.HostelContact;
                txtHostelFee.Text       = obj.HostelFee.ToString();
                txtHostelLocation.Text  = obj.HostelLocation;
                ddlStatus.SelectedValue = obj.IsActive.ToString();
                LoadDesignation();
                TblEmployee objemp = new TblEmployee(obj.EmployeeID);
                ddlDesignation.SelectedValue = objemp.DesignationID.ToString();
                BindEmployees(ddlDesignation.SelectedValue);
                ddlEmployees.SelectedValue = obj.EmployeeID.ToString();

                hfHostelID.Value    = obj.HostelID.ToString();
                Session["HostelID"] = null;
            }
            else
            {
                hfHostelID.Value = "";
            }
        }
Ejemplo n.º 17
0
 public int Edit(TblEmployee employee)
 {
     return(objemployee.UpdateEmployee(employee));
 }
Ejemplo n.º 18
0
 public int Create(TblEmployee employee)
 {
     return(objemployee.AddEmployee(employee));
 }
 public int Edit([FromBody] TblEmployee employee)
 {
     return(objemployee.UpdateEmployee(employee));
 }
 public int Create([FromBody] TblEmployee employee)
 {
     return(objemployee.AddEmployee(employee));
 }
Ejemplo n.º 21
0
 public int Edit(TblEmployee employee)
 {
     return(_employeeService.UpdateEmployee(employee));
 }
Ejemplo n.º 22
0
 public int Create(TblEmployee employee)
 {
     return(_employeeService.AddEmployee(employee));
 }
Ejemplo n.º 23
0
 public int updateEmployee([FromForm] TblEmployee employee)
 {
     return(this.objemployee.UpdateEmployee(employee));
 }
Ejemplo n.º 24
0
 public bool AddEmployee(TblEmployee Employee)
 {
     return(tblEmployeeDAO.AddEmployee(Employee));
 }
Ejemplo n.º 25
0
 public bool UpdateEmployeeWithPassword(TblEmployee Employee)
 {
     return(tblEmployeeDAO.UpdateEmployeeWithPassword(Employee));
 }
Ejemplo n.º 26
0
 public IActionResult Put(string id, [FromBody] TblEmployee uEmployee)
 {
     return(new JsonResult(this.repository.UpdateAsync(uEmployee, id).Result, this.DefaultJsonSettings));
 }
Ejemplo n.º 27
0
 public IActionResult Post([FromBody] TblEmployee nEmployee)
 {
     return(new JsonResult(this.repository.AddAsync(nEmployee).Result, this.DefaultJsonSettings));
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Updates the employee asynchronous.
        /// </summary>
        /// <param name="employee">The employee.</param>
        /// <returns></returns>
        public async Task <bool> UpdateEmployeeAsync(EmployeeViewModel employee)
        {
            TblEmployee Employee = _mapper.Map <TblEmployee>(employee);

            return(await _employeeRepository.UpdateEmployeeAsync(Employee));
        }
Ejemplo n.º 29
0
 public int CreateEmployee([FromForm]  TblEmployee employee)
 {
     return(this.objemployee.AddNewEmployee(employee));
 }
Ejemplo n.º 30
0
        public ActionResult SetDetail()
        {
            int        accountId = Request.Form["account_id"].ParseInt();
            int        empId     = Request.Form["EmpId"].ParseInt();
            SysAccount ob        = uow.Modules.Account.Get(accountId);

            if (ob.AccountId <= 0)
            {
                ob.AccountUsername = Request.Form["account_username"];
                ob.AccountPassword = Request.Form["account_password"];
                ob.AccountEmail    = Request.Form["account_email"];
                ob.CreatedBy       = CurrentUID;
                ob.CreatedDate     = CurrentDate;
            }
            ob.AccountFirstName = Request.Form["account_firstname"];
            ob.AccountLastName  = Request.Form["account_lastname"];
            ob.FlagStatus       = Request.Form["flag_status"].ParseInt();
            ob.UpdatedBy        = CurrentUID;
            ob.UpdatedDate      = CurrentDate;
            int roleId = Request.Form["role_id"].ParseInt();

            try
            {
                if (!ob.IsValid(out string errMsg))
                {
                    throw new Exception(errMsg);
                }

                if (Request.Files.Count > 0 && Request.Files["AccountAvatar"] != null && Request.Files["AccountAvatar"].ContentLength > 0)
                {
                    HttpPostedFileBase uploadedFile = Request.Files["AccountAvatar"];
                    string             FilePath     = string.Format("files/avatar/{0}{1}", CurrentDate.ParseString(DateFormat._yyyyMMddHHmmssfff), Path.GetExtension(uploadedFile.FileName));
                    if (!Directory.Exists(Server.MapPath("~/files")))
                    {
                        Directory.CreateDirectory(Server.MapPath("~/files"));
                    }
                    if (!Directory.Exists(Server.MapPath("~/files/avatar")))
                    {
                        Directory.CreateDirectory(Server.MapPath("~/files/avatar"));
                    }
                    uploadedFile.SaveAs(Server.MapPath("~/" + FilePath));

                    ob.AccountAvatar = FilePath;
                }

                if ((ob.AccountId <= 0 && ob.AccountPassword != Request.Form["account_passwordre"]) ||
                    (ob.AccountId > 0 && !string.IsNullOrWhiteSpace(Request.Form["account_password"]) && Request.Form["account_password"] != Request.Form["account_passwordre"]))
                {
                    throw new Exception("รหัสผ่านไม่ตรงกัน");
                }

                //if (!ob.FlagSystem)
                //{
                //    SysAccountRole roleMapped = ob.AccountId > 0 ?
                //        ((from d in uow.db.SysAccountRole
                //          join r in uow.db.SysRole on d.RoleId equals r.RoleId
                //          where
                //              d.AccountId == ob.AccountId
                //              && r.SiteId == SITE_ID
                //          select d).FirstOrDefault() ?? new SysAccountRole() { SysAccount = ob }) :
                //        new SysAccountRole() { SysAccount = ob };
                //    roleMapped.RoleId = Request.Form["role_id"].ParseInt();
                //    if (roleMapped.Id <= 0) { uow.db.SysAccountRole.Add(roleMapped); }
                //    else { uow.db.Entry(roleMapped).State = System.Data.Entity.EntityState.Modified; }
                //}


                if (ob.AccountId <= 0)
                {
                    ob.AccountPassword = Crypto.HashPassword(ob.AccountPassword);
                }
                else if (ob.AccountId > 0 && !string.IsNullOrWhiteSpace(Request.Form["account_password"]))
                {
                    ob.AccountPassword = Crypto.HashPassword(Request.Form["account_password"]);
                }


                uow.Modules.Account.Set(ob);


                //  employee.UpdatedDate = DateTime.Now;

                uow.Modules.Account.SetRole(SiteId, roleId, ob);
                uow.SaveChanges();

                if (empId > 0)
                {
                    TblEmployee employee = uow.Modules.Employee.Get(empId);

                    employee.AccountId = ob.AccountId;

                    uow.Modules.Employee.Set(employee);
                }
                uow.SaveChanges();
                return(RedirectToAction("Index", new
                {
                    area = "",
                    controller = "Account",
                    msg = "บันทึกข้อมูลเรียบร้อยแล้ว",
                    msgType = AlertMsgType.Success
                }));
            }
            catch (Exception ex)
            {
                string msg = ex.GetMessage();
                return(ViewDetail(ob, msg, AlertMsgType.Danger));
            }
        }
Ejemplo n.º 31
0
 public void PostEmployee(TblEmployee emp)
 {
     obj.TblEmployees.InsertOnSubmit(emp);
     obj.SubmitChanges();
 }