Esempio n. 1
0
        public ActionResult GetEmployee(int id)
        {
            HttpResponseMessage response = serviceObj.GetResponse("api/employeemanagement/getemployeebyid?id=" + id.ToString());

            response.EnsureSuccessStatusCode();
            Models.EmployeeModel employee = response.Content.ReadAsAsync <Models.EmployeeModel>().Result;
            return(View(employee));
        }
Esempio n. 2
0
        public ActionResult HtmlHelperExample()
        {
            EmployeeModel obj = new Models.EmployeeModel();

            obj.EmpName     = "Suba";
            ViewBag.Student = new SelectList(dbstud.StudentDetails, "StudId", "StudName", 2);
            return(View(obj));
        }
        public ActionResult Delete(Models.EmployeeModel emp)
        {
            var result = Conn.Employees.SingleOrDefault(a => a.ID == emp.ID);

            Conn.Employees.Remove(result);
            Conn.SaveChanges();

            return(View("Index"));
        }
        public PartialViewResult getmeHome9()
        {
            EmployeeModel obj = new Models.EmployeeModel();

            obj.EmpId     = 1;
            obj.EmpName   = "Akshay";
            obj.EmpSalary = 21000;

            return(PartialView("_myPartialView", obj));
        }
Esempio n. 5
0
        public JsonResult DeletePopUp(long id)
        {
            CRUDOperation.Models.EmployeeModel employeeModel = new Models.EmployeeModel()
            {
                EmployeeId = id
            };
            string convertedData = RenderViewToString(this.ControllerContext, "~/Views/Employee/_Delete.cshtml", employeeModel);

            return(Json(new { code = 0, message = convertedData }));
        }
        public ActionResult getmeHome8()
        {
            EmployeeModel obj = new Models.EmployeeModel();

            obj.EmpId     = 1;
            obj.EmpName   = "Akshay";
            obj.EmpSalary = 21000;

            return(View(obj));
        }
        public ActionResult SendinfoByModel()
        {
            EmployeeModel obj = new Models.EmployeeModel();

            obj.EmpId     = 1;
            obj.EmpName   = "Akshay";
            obj.EmpSalary = 21000;

            //object model=obj;
            return(View(obj));
        }
        public ActionResult GetEmployee()
        {
            EmployeeModel obj = new Models.EmployeeModel();

            obj.EmpId     = 1;
            obj.EmpName   = "Hari";
            obj.EmpSalary = 29000;



            return(View(obj));
        }
        public ActionResult SendData()
        {
            EmployeeModel obj = new Models.EmployeeModel();

            obj.EmpId     = 1;
            obj.EmpName   = "Pawan";
            obj.EmpSalary = 21000;

            ViewBag.info = obj;

            return(View());
        }
Esempio n. 10
0
        public ActionResult Create(Models.EmployeeModel model)
        {
            if (ModelState.IsValid)
            {
                int recordsCreated = CreateEmployee(
                    model.FirstName,
                    model.LastName
                    );

                return(RedirectToAction("ViewEmployees"));
            }
            return(View());
        }
Esempio n. 11
0
        public JsonResult sentvalue(int id)
        {
            var db = DBO.GetInstance();
            var st = db.getEmployee(id);

            Models.EmployeeModel emp = new Models.EmployeeModel();
            emp.Id       = st.Id;
            emp.Name     = st.Name;
            emp.Surname  = st.Surname;
            emp.Username = st.UserName;
            emp.Password = st.Password;
            emp.CardId   = st.CardNumber;
            return(Json(emp));
        }
Esempio n. 12
0
        public ViewResult SendMultipleinfoByModel2()
        {
            List <EmployeeModel>   listObj     = new List <EmployeeModel>();
            List <DepartmentModel> listdeptObj = new List <DepartmentModel>();

            EmployeeModel obj = new Models.EmployeeModel();

            obj.EmpId     = 1;
            obj.EmpName   = "Akshay";
            obj.EmpSalary = 21000;


            EmployeeModel obj1 = new Models.EmployeeModel();

            obj1.EmpId     = 2;
            obj1.EmpName   = "Vithal";
            obj1.EmpSalary = 31000;

            EmployeeModel obj2 = new Models.EmployeeModel();

            obj2.EmpId     = 3;
            obj2.EmpName   = "Chaitanya";
            obj2.EmpSalary = 61000;

            listObj.Add(obj);
            listObj.Add(obj1);
            listObj.Add(obj2);


            DepartmentModel dept = new Models.DepartmentModel();

            dept.DeptId   = 1;
            dept.DeptName = "IT";

            DepartmentModel dept1 = new Models.DepartmentModel();

            dept1.DeptId   = 2;
            dept1.DeptName = "Network";

            listdeptObj.Add(dept);
            listdeptObj.Add(dept1);

            EmpDept eobj = new Models.EmpDept();

            eobj.emp  = listObj;
            eobj.dept = listdeptObj;

            //object model=obj;
            return(View(eobj));
        }
Esempio n. 13
0
        // GET: EmployeeController/Edit/5
        public ActionResult Edit(int id)
        {
            var data = LoadOneEmployee(id);

            Models.EmployeeModel employee = new Models.EmployeeModel()
            {
                Id        = data.Id,
                FirstName = data.FirstName,
                LastName  = data.LastName,
                CreatedAt = data.CreatedAt,
                UpdatedAt = data.UpdatedAt
            };

            return(View(employee));
        }
Esempio n. 14
0
 public IHttpActionResult GetEmployeeByName(string id)
 {
     Models.EmployeeModel employee;
     using (SalesDBEntities db = new SalesDBEntities())
     {
         var employeeFromDB = db.Employees.FirstOrDefault(item => item.FirstName.Contains(id) || item.LastName.Contains(id));
         employee = new Models.EmployeeModel()
         {
             EmployeeID    = employeeFromDB.EmployeeID,
             FirstName     = employeeFromDB.FirstName,
             LastName      = employeeFromDB.LastName,
             MiddleInitial = employeeFromDB.MiddleInitial
         };
     }
     return(Ok(employee));
 }
Esempio n. 15
0
        public Models.EmployeeModel CreateEmployee(Models.EmployeeModel Employee)
        {
            // get database connection
            var dbCon = DBConnection;

            if (dbCon.IsConnect()) //check if connected
            {
                //set insert Query
                string query  = string.Format("INSERT INTO employees (name, lastname, idnumber, address, phone, level, rate, photo) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}');", Employee.Name, Employee.Lastname, Employee.IDNumber, Employee.Address, Employee.Phone, Employee.Level, Employee.Rate, Employee.Photo);
                var    cmd    = new MySqlCommand(query, dbCon.Connection); //create mysql to be executed
                var    reader = cmd.ExecuteNonQuery();                     //execute query
                Employee.EmployeeId = (int)cmd.LastInsertedId;             //get last inserted id
                dbCon.Close();                                             //close database connection
            }

            return(Employee); //return employee model
        }
Esempio n. 16
0
        public ActionResult Create(FormCollection frm)
        {
            EmployeeModel emp = new Models.EmployeeModel();

            emp.EmpName   = Convert.ToString(frm["EmpName"]);
            emp.EmpSalary = Convert.ToInt32(frm["EmpSalary"]);
            int i = db.SaveEmployee(emp);

            if (i > 0)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 17
0
        public Models.EmployeeModel UpdateEmployee(Models.EmployeeModel Employee)
        {
            var dbCon = DBConnection; //get database connection

            if (dbCon.IsConnect())    //check if connected
            {
                //Set query to return employee information
                string query = string.Format("UPDATE employees set name='{0}', lastname='{1}', idnumber='{2}', address='{3}', phone='{4}', level='{5}', rate='{6}', photo='{7}' WHERE employeeid={8} and deleted=0;", Employee.Name, Employee.Lastname, Employee.IDNumber, Employee.Address, Employee.Phone, Employee.Level, Employee.Rate, Employee.Photo, Employee.EmployeeId);
                var    cmd   = new MySqlCommand(query, dbCon.Connection); // set mysql command to execute

                var reader = cmd.ExecuteNonQuery();                       //execute query

                dbCon.Close();                                            //close connection
            }

            return(Employee); //return employee
        }
Esempio n. 18
0
        public async Task <IActionResult> Post(List <IFormFile> files)
        {
            long size = files.Sum(f => f.Length);

            // full path to file in temp location
            var filePath = Path.GetTempFileName();
            List <Models.EmployeeModel> empList = new List <Models.EmployeeModel>();

            foreach (var formFile in files)
            {
                if (formFile.Length > 0)
                {
                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        await formFile.CopyToAsync(stream);

                        using (var reader = new StreamReader(formFile.OpenReadStream()))
                        {
                            int counter = 1;
                            while (!reader.EndOfStream)
                            {
                                var line = reader.ReadLine();
                                var data = line.Split(new[] { ',' });

                                var employee = new Models.EmployeeModel {
                                    EmployeeID   = counter,
                                    FirstName    = data[0],
                                    LastName     = data[1],
                                    AnnualSalary = Decimal.Parse(data[2]),
                                    SuperRate    = Int32.Parse(data[3].Replace("%", "")),
                                    PaymentStart = GetStartDate(data[4]),
                                    PayPeriod    = data[4]
                                };

                                empList.Add(employee);
                                counter++;
                            }
                        }
                    }
                }
            }

            return(View("_EmployeeList", empList));
        }
Esempio n. 19
0
        public EmployeeModel GetEmployeesById(int?id)
        {
            EmployeeModel emp = new Models.EmployeeModel();
            SqlCommand    cmd = new SqlCommand("spr_getEmployeeDetailsbyId", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@empid", id);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            foreach (DataRow dr in dt.Rows)
            {
                emp.EmpId     = Convert.ToInt32(dr[0]);
                emp.EmpName   = Convert.ToString(dr[1]);
                emp.EmpSalary = Convert.ToInt32(dr[2]);
            }
            return(emp);
        }
Esempio n. 20
0
 public JsonResult Delete(long id)
 {
     try
     {
         Employee employee = db.Employees.Find(id);
         //if (employee == null)
         //    throw new Exception("Equipment Not Exist");
         db.Employees.Remove(employee);
         db.SaveChanges();
         CRUDOperation.Models.EmployeeModel employeeModel = new Models.EmployeeModel();
         employeeModel.EmployeeList = GetAllEmployeeDetails();
         string text = RenderViewToString(this.ControllerContext, "_Delete", employeeModel);
         return(Json(new { Code = 0, Message = text }));
     }
     catch (Exception ex)
     {
         return(Json(new { Code = -1, Message = "Failed" }));
     }
 }
Esempio n. 21
0
        public List <CRUDOperation.Models.EmployeeModel> GetAllEmployeeDetails()
        {
            IQueryable <Employee> IQuery    = db.Employees;
            List <Employee>       employees = IQuery.ToList();
            List <CRUDOperation.Models.EmployeeModel> employeeModels = new List <Models.EmployeeModel>();

            foreach (var item in employees)
            {
                CRUDOperation.Models.EmployeeModel employeeModel = new Models.EmployeeModel()
                {
                    EmployeeId = item.EmployeeId,
                    FirstName  = item.FirstName,
                    LastName   = item.LastName,
                    Salary     = item.Salary
                };
                employeeModels.Add(employeeModel);
            }
            return(employeeModels);
        }
Esempio n. 22
0
        public JsonResult GetJsonData()
        {
            List <EmployeeModel> objlist = new List <EmployeeModel>();
            EmployeeModel        obj     = new Models.EmployeeModel();

            obj.Empid     = 12;
            obj.Empname   = "Kaushik";
            obj.EmpSalary = 25000;

            EmployeeModel obj1 = new Models.EmployeeModel();

            obj1.Empid     = 1;
            obj1.Empname   = "Mounika";
            obj1.EmpSalary = 256000;
            objlist.Add(obj);
            objlist.Add(obj1);

            return(Json(objlist, JsonRequestBehavior.AllowGet));
        }
Esempio n. 23
0
        public Models.EmployeeModel GetEmployee(Models.EmployeeModel Employee)
        {
            var dbCon = DBConnection; // get database connection

            if (dbCon.IsConnect())    //check if database connected
            {
                //set mysql Query join employees and access table
                string query  = string.Format("SELECT employees.employeeid, employees.name, employees.lastname, employees.idnumber, employees.address, employees.phone, employees.level, employees.rate, employees.photo, accesstable.username, accesstable.password, accesstable.isadmin FROM employees left JOIN accesstable on accesstable.employeeid=employees.employeeid where employees.employeeid={0} and deleted=0", Employee.EmployeeId);
                var    cmd    = new MySqlCommand(query, dbCon.Connection); //set mysql command
                var    reader = cmd.ExecuteReader();                       //execute mysql query

                while (reader.Read())                                      //read returned reader
                {                                                          //set property values from database values
                    Employee.EmployeeId = int.Parse(reader["employeeid"].ToString());
                    Employee.Name       = reader["name"].ToString();
                    Employee.Photo      = reader["photo"].ToString();
                    Employee.Lastname   = reader["lastname"].ToString();
                    Employee.Fullname   = reader["name"].ToString() + " " + reader["lastname"].ToString();
                    Employee.IDNumber   = reader["idnumber"].ToString();
                    Employee.Address    = reader["address"].ToString();
                    Employee.Phone      = reader["phone"].ToString();
                    Employee.Level      = int.Parse(reader["level"].ToString());
                    Employee.Rate       = decimal.Parse(reader["rate"].ToString());

                    Employee.Username = reader["username"].ToString();
                    Employee.Password = reader["password"].ToString();
                    if (string.IsNullOrEmpty(reader["isadmin"].ToString())) //if admin was not set on create parsing a null cause error,
                    {
                        Employee.IsAdmin = false;
                    }
                    else
                    {
                        Employee.IsAdmin = bool.Parse(reader["isadmin"].ToString());
                    }
                }
                dbCon.Close();//close database connection
            }

            return(Employee); //return employee
        }
Esempio n. 24
0
        public void DepartmentFileImport(HttpPostedFileBase departmentExcelFile)
        {
            string ExcuteMsg      = string.Empty;
            int    NumberOfColume = 0;

            try
            {
                //HttpPostedFileBase file = Request.Files["ProductExcel"];
                HttpPostedFileBase file = departmentExcelFile;
                //Extaintion Check
                if (departmentExcelFile.FileName.EndsWith("xls") || file.FileName.EndsWith("xlsx") ||
                    file.FileName.EndsWith("XLS") ||
                    file.FileName.EndsWith("XLSX"))
                {
                    //Null Exp Check
                    if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName))
                    {
                        string fileName        = file.FileName;
                        string fileContentType = file.ContentType;
                        byte[] fileBytes       = new byte[file.ContentLength];
                        var    data            = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength));
                        List <DepartmentImportModel> departmentImportList = new List <DepartmentImportModel>();
                        using (var package = new ExcelPackage(file.InputStream))
                        {
                            var currentSheet = package.Workbook.Worksheets;
                            var workSheet    = currentSheet.First();
                            var noOfCol      = workSheet.Dimension.End.Column;
                            var noOfRow      = workSheet.Dimension.End.Row;
                            for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++)
                            {
                                if (workSheet.Cells[rowIterator, 1].Value != null &&
                                    workSheet.Cells[rowIterator, 3].Value != null)
                                {
                                    DepartmentImportModel departmentModel = new DepartmentImportModel();
                                    departmentModel.DepartmentName =
                                        workSheet.Cells[rowIterator, 1].Value == null
                                            ? null
                                            : workSheet.Cells[rowIterator, 1].Value.ToString();
                                    departmentModel.DepartmentHead =
                                        workSheet.Cells[rowIterator, 2].Value == null
                                            ? null
                                            : workSheet.Cells[rowIterator, 2].Value.ToString();
                                    departmentModel.CompanyName =
                                        workSheet.Cells[rowIterator, 3].Value == null
                                            ? null
                                            : workSheet.Cells[rowIterator, 3].Value.ToString();
                                    departmentImportList.Add(departmentModel);
                                }
                            }
                        }
                        //List data saving
                        if (departmentImportList.Count > 0)
                        {
                            foreach (var item in departmentImportList)
                            {
                                //item.companyImportList();
                                if (!string.IsNullOrEmpty(item.CompanyName))
                                {
                                    var company = new CompanyModel().GetAllCompanies().FirstOrDefault(x => x.IsDelete == false && x.Name == item.CompanyName);
                                    if (company != null)
                                    {
                                        item.CompanyId = company.Id;
                                    }
                                }
                                if (!string.IsNullOrEmpty(item.DepartmentHead))
                                {
                                    var employee = new Models.EmployeeModel().GetAllEmployee().SingleOrDefault(x => x.IsDelete == false && x.FirstName.ToLower() == item.DepartmentHead.ToLower());
                                    if (employee != null)
                                    {
                                        item.DepartmentHeadId = employee.Id;
                                    }
                                }
                                _departmentManagementService.AddDepartment(item.DepartmentName, item.CompanyId, item.DepartmentHeadId);
                            }
                        }
                    }
                }
            }
            catch (Exception r)
            {
                ExcuteMsg = r.Message;
            }
        }
Esempio n. 25
0
 public ActionResult Index(Models.EmployeeModel employee)
 {
     return(View("Details", employee));
 }
Esempio n. 26
0
        public ActionResult Index()
        {
            var employees = new Models.EmployeeModel().GetAllEmployee().Where(x => x.IsDelete == false);

            return(View(employees));
        }
Esempio n. 27
0
        public async Task <ActionResult> EditEmployee(Models.EmployeeModel model)
        {
            if (ModelState.IsValid)
            {
                JneCommSitesDataLayer.JneCommSitesDataBaseEntities _dbContext = new JneCommSitesDataLayer.JneCommSitesDataBaseEntities();

                var aspNetUserQuery = (from p in _dbContext.AspNetUsers
                                       where p.UserName == model.UserName
                                       select p).FirstOrDefault();

                var actualRol = (from p in _dbContext.T_CrewRoles
                                 from d in p.AspNetUsers
                                 where d.Id == aspNetUserQuery.Id
                                 select p).FirstOrDefault();

                aspNetUserQuery.T_CrewRoles.Clear();

                aspNetUserQuery.T_CrewRoles.Add(actualRol);

                if (!string.IsNullOrEmpty(model.Password))
                {
                    var token = await UserManager.GeneratePasswordResetTokenAsync(aspNetUserQuery.Id);

                    var result = await UserManager.ResetPasswordAsync(aspNetUserQuery.Id, token, model.Password);
                }
                var userInf = (from p in _dbContext.T_UsersData
                               where p.Id == aspNetUserQuery.Id
                               select p).First();

                userInf.UserFirstName = model.firstName;
                userInf.UserLastName  = model.LastName;
                userInf.LaborHourPay  = Convert.ToDecimal(model.laborHour);
                userInf.IsBilingual   = model.isBilingual;
                //userInf.NumDaysForPassChange = model.daysChangePass;

                _dbContext.SaveChanges();

                JneCommSitesDataLayer.JneCommSitesDataBaseEntities _Context = new JneCommSitesDataLayer.JneCommSitesDataBaseEntities();


                var queryCertificationsByUser = (from p in _Context.T_CertificationsByUserCrew
                                                 where p.Id == aspNetUserQuery.Id
                                                 select p);

                foreach (var item in queryCertificationsByUser)
                {
                    _Context.T_CertificationsByUserCrew.Remove(item);
                }
                _Context.SaveChanges();


                foreach (var item in model._ListCertifications)
                {
                    if (item.isActive)
                    {
                        JneCommSitesDataLayer.T_CertificationsByUserCrew newCertificationByUser = new JneCommSitesDataLayer.T_CertificationsByUserCrew();
                        newCertificationByUser.vCertificationName = item.certificationName;
                        newCertificationByUser.Id = aspNetUserQuery.Id; if (item.expirationTime != null)
                        {
                            newCertificationByUser.dExpirationTime = Convert.ToDateTime(item.expirationTime);
                        }
                        if (item.documentToUpload != null)
                        {
                            newCertificationByUser.vDocumentName = (model.UserName + "_" + item.certificationName + Path.GetExtension(item.documentToUpload.FileName)).Replace(" ", "");

                            string path = System.IO.Path.Combine(
                                Server.MapPath("~/Documents/Certifications/"), (model.UserName + "_" + item.certificationName + Path.GetExtension(item.documentToUpload.FileName)).Replace(" ", ""));
                            // file is uploaded
                            item.documentToUpload.SaveAs(path);
                        }
                        _dbContext.T_CertificationsByUserCrew.Add(newCertificationByUser);
                        _dbContext.SaveChanges();
                    }
                }
                model._UserCrewGroup = Helper.Helper.GetSubRoles("CrewRole");
                model._StatesList    = Helper.Helper.GetUSAStates();
                return(RedirectToAction("CrewEmployeeIndex", "Administration"));
            }
            model._UserCrewGroup = Helper.Helper.GetSubRoles("CrewRole");
            model._StatesList    = Helper.Helper.GetUSAStates();
            return(View(model));
        }
        public ActionResult SaveEmployee(Models.EmployeeModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.EmpID == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDEmployee code = _db.MDEmployee.Where(p => p.EmpCode == data.EmpCode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.MDEmployee.Add(new DAL.MDEmployee
                        {
                            EmpID          = data.EmpID,
                            EmpCode        = data.EmpCode,
                            EmpHead        = data.EmpHead,
                            EmpTitle       = data.EmpTitle,
                            EmpNameEng     = data.EmpNameEng,
                            EmpName        = data.EmpName,
                            EmpType        = data.EmpType,
                            Tel            = data.Tel,
                            Email          = data.Email,
                            EmpStartDate   = data.EmpStartDate,
                            EmpPromoteDate = data.EmpPromoteDate,
                            EmpResignDate  = data.EmpResignDate,
                            EmpAddr1       = data.EmpAddr1,
                            District       = data.District,
                            Amphur         = data.Amphur,
                            Province       = data.Province,
                            PostCode       = data.PostCode,
                            EmpStatus      = data.EmpStatus,
                            EmpTitleEng    = data.EmpTitleEng,
                            EmpSignature   = data.EmpSignature,
                            Username       = data.Username,
                            DeptID         = data.DeptID,
                            EmpGroupID     = data.EmpGroupID,
                            PostID         = data.PostID,
                            TaxID          = data.TaxID,
                            IDCard         = data.IDCard,
                            Remark         = data.Remark,
                            ccode          = data.ccode
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.EmpID != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.MDEmployee code = _db.MDEmployee.Where(p => p.EmpCode == data.EmpCode && p.EmpID != data.EmpID).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.MDEmployee edit = _db.MDEmployee.Where(p => p.EmpID == data.EmpID).FirstOrDefault();

                        edit.EmpID          = data.EmpID;
                        edit.EmpCode        = data.EmpCode;
                        edit.EmpHead        = data.EmpHead;
                        edit.EmpTitle       = data.EmpTitle;
                        edit.EmpNameEng     = data.EmpNameEng;
                        edit.EmpName        = data.EmpName;
                        edit.EmpType        = data.EmpType;
                        edit.Tel            = data.Tel;
                        edit.Email          = data.Email;
                        edit.EmpStartDate   = data.EmpStartDate;
                        edit.EmpPromoteDate = data.EmpPromoteDate;
                        edit.EmpResignDate  = data.EmpResignDate;
                        edit.EmpAddr1       = data.EmpAddr1;
                        edit.District       = data.District;
                        edit.Amphur         = data.Amphur;
                        edit.Province       = data.Province;
                        edit.PostCode       = data.PostCode;
                        edit.EmpStatus      = data.EmpStatus;
                        edit.EmpTitleEng    = data.EmpTitleEng;
                        edit.EmpSignature   = data.EmpSignature;
                        edit.Username       = data.Username;
                        edit.DeptID         = data.DeptID;
                        edit.EmpGroupID     = data.EmpGroupID;
                        edit.PostID         = data.PostID;
                        edit.TaxID          = data.TaxID;
                        edit.IDCard         = data.IDCard;
                        edit.Remark         = data.Remark;
                        edit.ccode          = data.ccode;
                        _db.SaveChanges();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(View());
        }
Esempio n. 29
0
        /// <summary>
        /// DEBUG FOR QUERY
        /// </summary>
        /// <param name="tt"></param>
        public static void DebugCommand(string tt)
        {
            //actual SQL query
            tt = "INSERT INTO `EMPLOYEE`(`EmpUserName`,`EmpFName`,`EmpLName`, `EmpPassword`) VALUES (@param1,@param2,@param3, @param4);";
            // Multiple rows use: VALUES (@param1,@param2,@param3, @param4),(@param1,@param2,@param3, @param4), etc;
            //In the case we assume in code that we used the models to populate date beforehand in the forms
            Models.EmployeeModel employee = new Models.EmployeeModel
            {
                EmpUserName = "******",
                EmpFName    = "dbubugug",
                EmpLName    = "",
                EmpPassword = "******"
            };

            //example
            try
            {
                //New SQLite Command to be executed, passing in string for query and the connection
                SQLiteCommand comm = new SQLiteCommand(tt, dbConnection);

                //the constructor above should have already set this field, but just in case we can do it again but not necessary
                comm.CommandText = tt;
                //Set how the command will be processed
                comm.CommandType = System.Data.CommandType.Text;

                //TEST
                //SQLiteParameter pa = new SQLiteParameter("EmpUserName");

                //Adding Parameters to the string query assuming it is set up correctly and also setting their values
                //comm.Parameters.Add("EmpUserName", System.Data.DbType.String).Value = employee.EmpUserName;
                comm.Parameters.Add("@param1", System.Data.DbType.String).Value = employee.EmpUserName;
                comm.Parameters.Add("@param2", System.Data.DbType.String).Value = employee.EmpFName;
                comm.Parameters.Add("@param3", System.Data.DbType.String).Value = employee.EmpLName;

                //Alternatively
                //SQLiteParameter param = new SQLiteParameter("@param3", System.Data.DbType.String);
                //param.Value = employee.EmpLName;

                //exception thrown
                //comm.Parameters.Add(new SQLiteParameter("@param1", System.Data.DbType.String).Value = employee.EmpUserName);
                //comm.Parameters.Add(new SQLiteParameter("@param2", System.Data.DbType.String).Value = employee.EmpFName);
                //comm.Parameters.Add(new SQLiteParameter("@param3", System.Data.DbType.String).Value = employee.EmpLName);

                //Execute the non-Query(ie: not select) command, function passes back rows affected by the insert in this case
                int rows = comm.ExecuteNonQuery();

                Console.WriteLine("Rows affected {0}", rows);
            }
            catch (SQLiteException ex)
            {
                switch ((SQLiteErrorCode)ex.ErrorCode)
                {
                //DB Constraint errors
                case SQLiteErrorCode.Constraint:
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    break;

                //File is busy reading or writing by another process
                case SQLiteErrorCode.Busy:
                    MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    break;

                //Spit out an error since an exception threw anyways
                default:
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    break;
                }
            }
            catch (Exception ex) //Everything else
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 30
0
        public ActionResult EditEmployee(string employeeName)
        {
            if (string.IsNullOrEmpty(employeeName))
            {
                return(RedirectToAction("UsersIndex", "Maintenance"));
            }
            JneCommSitesDataLayer.JneCommSitesDataBaseEntities _dbContext = new JneCommSitesDataLayer.JneCommSitesDataBaseEntities();

            var aspNetUserQuery = (from p in _dbContext.AspNetUsers
                                   where p.UserName == employeeName
                                   select p).FirstOrDefault();

            var rolQUery = (from p in _dbContext.T_CrewRoles
                            from d in p.AspNetUsers
                            where d.Id == aspNetUserQuery.Id
                            select p).FirstOrDefault();

            var userInf = (from p in _dbContext.vwUserData
                           where p.UserID == aspNetUserQuery.Id
                           select p).First();

            Models.EmployeeModel model = new Models.EmployeeModel();

            model._UserCrewGroup = Helper.Helper.GetSubRoles("CrewRole");
            model.UserCrewGroup  = rolQUery.vCrewRoleName;
            model._StatesList    = Helper.Helper.GetUSAStates();
            model.states         = userInf.vStateCode;
            model.UserName       = aspNetUserQuery.UserName;
            model.firstName      = userInf.UserFirstName;
            model.LastName       = userInf.UserLastName;
            model.Email          = aspNetUserQuery.Email;
            model.lockedOutUser  = aspNetUserQuery.LockoutEnabled;
            model.laborHour      = Convert.ToDouble(userInf.LaborHourPay);
            model.isBilingual    = Convert.ToBoolean(userInf.IsBilingual);

            var queryCertifications = (from p in _dbContext.T_Certifications
                                       select p);

            model._ListCertifications = new List <Models.CertificationsByEmployee>();

            foreach (var item in queryCertifications)
            {
                bool   isActive     = false;
                string actualDate   = "";// DateTime.Now.ToString("yyyy-MM-dd");
                string documentName = "NoFileUpload.png";

                var queryCertificationByUser = (from p in _dbContext.T_CertificationsByUserCrew
                                                where p.vCertificationName == item.vCertificationName &&
                                                p.Id == aspNetUserQuery.Id
                                                select p).FirstOrDefault();

                if (queryCertificationByUser != null)
                {
                    isActive     = true;
                    actualDate   = Convert.ToDateTime(queryCertificationByUser.dExpirationTime).ToString("yyyy-MM-dd");
                    documentName = queryCertificationByUser.vDocumentName;
                }
                model._ListCertifications.Add(new Models.CertificationsByEmployee
                {
                    certificationName = item.vCertificationName,
                    documentName      = documentName,
                    expirationTime    = actualDate,
                    isActive          = isActive
                });
            }
            return(View(model));
        }