Ejemplo n.º 1
0
        public void DeleteEmployee(int id)
        {
            EmpDetails e = _context.EmpDetails.Find(id);

            _context.Remove(e);
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
        public ActionResult PersonalDetails(EmpDetails empDetails)
        {
            SqlHelper obj = new SqlHelper();

            connection();
            //db.EmployeeDetails.Add(empDetails);
            //db.SaveChanges();


            //string date = DateTime.Now.ToString();
            //string date = DateTime.Now.ToString();
            //DateTime dateTime = Convert.ToDateTime(date);

            string entryDate = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
            string dob       = empDetails.dob.ToString("MM/dd/yyyy hh:mm:ss");

            SqlCommand sqlcmd = new SqlCommand("Insert into emp_details (emp_code, emp_name, emp_fname, dob, gender, religion, category, subcategory, pan, aadhar, entry_date, emp_height, emp_idy, emp_martial, cat_sel, office_Code, blood_Group, voterCard_No) values('"
                                               + empDetails.emp_code + "','" + empDetails.emp_name + "','" + empDetails.emp_fname + "','" + dob + "','" + empDetails.gender + "','" + empDetails.religion + "'," + "'" + empDetails.category + "','"
                                               + empDetails.subcategoryName + "','" + empDetails.pan + "','" + empDetails.aadhar.ToString() + "','" + entryDate + "','" + empDetails.emp_height + "','" + empDetails.emp_idy + "','" + empDetails.emp_martial +
                                               "','" + empDetails.cat_sel + "','" + empDetails.office_code + "','" + empDetails.blood_Group + "','" + empDetails.voterCard_No + "')", con);

            sqlcmd.CommandType = CommandType.Text;
            con.Open();
            sqlcmd.ExecuteNonQuery();
            Session["empCode"] = empDetails.emp_code;

            con.Close();

            //lstemp = GetDatas();
            //return View("Index", lstemp);
            //return View("EmpHomeDistrict","Employee",new {id=TempData["mydata"]});
            // RedirectToAction(");    return RedirectToAction("Details","Student",new { id = StudentId });
            return(RedirectToAction("EmpHomeDistrict"));
        }
        public EmpDetails GetEmpByEmail(string email)
        {
            try
            {
                using (IDbConnection con = Connection)
                {
                    con.Open();
                    var param = new DynamicParameters();
                    param.Add("@EmpEMail", email);
                    //return con.Query<UserDetails>("dbo.usp_EmployeeDetails", param, null, true, 0, CommandType.StoredProcedure).FirstOrDefault();
                    EmpDetails empDetails = new EmpDetails();
                    using (var multi = con.QueryMultiple("dbo.usp_EmployeeDetails", param, commandType: CommandType.StoredProcedure))
                    {
                        //empDetails = multi.Read<EmpDetails>().First();
                        //empDetails.Roles = multi.Read<EmpRoles>().ToList();
                        empDetails = multi.Read <EmpDetails>().SingleOrDefault();
                        if (empDetails != null)
                        {
                            empDetails.Roles = multi.Read <EmpRoles>().ToList();
                        }
                    }

                    return(empDetails);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        public async Task Put(int id, [FromBody] EmpDetails value)
        {
            var entry = await _db.Entries.FindAsync(id);

            entry = value;
            await _db.SaveChangesAsync();
        }
Ejemplo n.º 5
0
        public HttpResponseMessage CheckEmpExists(string EmpMobile)
        {
            EmpDetails resEmpDet = null;

            try
            {
                DBConnection dbConn = new DBConnection();
                resEmpDet = dbConn.GetUserDetails(EmpMobile);
                if (resEmpDet.IsAuthorized)
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(JsonConvert.SerializeObject("Success"), Encoding.UTF8, "application/json")
                    });
                }
                else
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(JsonConvert.SerializeObject("Error"), Encoding.UTF8, "application/json")
                    });
                }
            }
            catch
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }
        }
Ejemplo n.º 6
0
        public async Task <string> Post([FromBody] EmpDetails value)
        {
            await _db.Entries.AddAsync(value);

            await _db.SaveChangesAsync();

            return(value.EmployeeId + " - " + value.Name + " : " + value.Surname);
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Edit(EmpDetails emp)
        {
            if (ModelState.IsValid)
            {
                _db.Update(emp);
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(emp));
        }
Ejemplo n.º 8
0
 public ActionResult Index(EmpDetails model)
 {
     if (!string.IsNullOrWhiteSpace(model.Name))
     {
         ViewBag.WordsNo = model.Name + " " + NumberToWords.ConvertAmount(model.Number)?.ToUpper();
     }
     else
     {
         ViewBag.WordsNo = "";
     }
     return(View(model));
 }
        public ActionResult Edit(EmpDetails empDetail)
        {
            var empDetails = employeeContext.EmpDetailss.Find(empDetail.EmployeeId);

            empDetails.Name     = empDetail.Name;
            empDetails.MobileNo = empDetail.MobileNo;
            empDetails.Email    = empDetail.Email;
            empDetails.Address  = empDetail.Address;
            employeeContext.SaveChanges();

            return(RedirectToAction("EmpDetailsList"));
        }
Ejemplo n.º 10
0
 public IActionResult AddEmployee(EmpDetails emp)
 {
     try
     {
         _repo.AddEmployee(emp);
         return(Ok());
     }
     catch (Exception e)
     {
         return(Ok(e.InnerException.Message));
     }
 }
Ejemplo n.º 11
0
        protected void AddUserInfo(object sender, EventArgs e)
        {
            try
            {
                DBConnection dbConn     = new DBConnection();
                EmpDetails   empDetails = new EmpDetails();
                empDetails.EmpFirstName = empFirstName.Text;
                empDetails.EmpLastName  = empLastName.Text;
                empDetails.EmpEmail     = empEmail.Text;
                empDetails.EmpMobile    = Session["mobileNo"].ToString();
                //if (!resEmpDet.IsAuthorized)
                //{
                try
                {
                    HttpClient client = new HttpClient();

                    client.BaseAddress = new Uri("http://localhost:52668//Employee");
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/pdf"));
                    string              reqUrl      = "api/AddEmployee";
                    var                 param       = Newtonsoft.Json.JsonConvert.SerializeObject(empDetails);
                    HttpContent         contentPost = new StringContent(param, Encoding.UTF8, "application/json");
                    HttpResponseMessage response    = client.PostAsync(reqUrl, contentPost).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        EmpDetails newEmpDet = response.Content.ReadAsAsync <EmpDetails>().Result;
                        if (newEmpDet.messageType == "success")
                        {
                            successMessage.InnerText = newEmpDet.message;
                            empDet.Visible           = false;
                        }
                        else
                        {
                            errorMessage.InnerText = newEmpDet.message;
                            empDet.Visible         = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    errorMessage.InnerText = ex.Message;
                    Console.WriteLine(ex.Message);
                }
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 12
0
        public EmpDetails Add(EmpDetails emp)
        {
            var Result = _db.Add(emp);

            _db.SaveChanges();

            if (Result != null)
            {
                return(emp);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 13
0
        public EmpDetails GetUserDetails(string EmpMobile)
        {
            EmpDetails empDet = new EmpDetails();
            SqlCommand cmd    = null;

            try
            {
                cmd             = new SqlCommand("GetUserInfo", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@EmpMobile", SqlDbType.VarChar)).Value = EmpMobile;

                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        empDet.IsAuthorized = true;
                    }
                }
                else
                {
                    empDet.IsAuthorized = false;
                }
            }
            catch (Exception ex)
            {
                empDet.IsAuthorized = false;
                Console.WriteLine(ex.Message);
            }
            finally
            {
                cmd.Dispose();
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(empDet);
        }
Ejemplo n.º 14
0
 public IActionResult Add(EmpDetails emp)
 {
     try
     {
         EmpDetails data = _IUser.Add(emp);
         if (!data.Equals(null))
         {
             return(Ok(new { success = true, Message = "Added successfully", Data = emp }));
         }
         else
         {
             return(Ok(new { success = false, Message = "failed to add", Data = emp }));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(new { success = false, Message = ex.Message }));
     }
 }
        public EmpResponse GetEmpByEmail(string email)
        {
            EmpResponse response = new EmpResponse();

            try
            {
                EmpDetails empDetails = this._employeeDetailServices.GetEmpByEmail(email);
                if (empDetails != null)
                {
                    response.Result = true;
                    response.Data   = empDetails;
                }
                else
                {
                    response.Result = false;
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(response);
        }
Ejemplo n.º 16
0
        public IHttpActionResult AddEmployee(EmpDetails empDetails)
        {
            EmpDetails resEmpDet = empDetails;

            try
            {
                DBConnection dbConn = new DBConnection();
                string       status = dbConn.AddEmployeeDetails(empDetails);
                if (status == "Successfully Uploaded")
                {
                    resEmpDet.messageType = "success";
                    resEmpDet.message     = "Successfully added user's info";
                    return(Ok(resEmpDet));
                }
            }
            catch (Exception ex)
            {
                resEmpDet             = new EmpDetails();
                resEmpDet.messageType = "error";
                resEmpDet.message     = ex.Message;
                return(Ok(resEmpDet));
            }
            return(Ok(resEmpDet));
        }
Ejemplo n.º 17
0
        public string AddEmployeeDetails(EmpDetails empDetails)
        {
            string     status = "";
            SqlCommand cmd    = null;

            try
            {
                cmd             = new SqlCommand("AddEmployeeDet", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value          = empDetails.EmpFirstName;
                cmd.Parameters.Add("@LastName", SqlDbType.VarChar).Value           = empDetails.EmpLastName;
                cmd.Parameters.Add("@Mobile", SqlDbType.VarChar).Value             = empDetails.EmpMobile;
                cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value              = empDetails.EmpEmail;
                cmd.Parameters.Add("@returnVal", SqlDbType.VarChar, 500).Direction = ParameterDirection.Output;

                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                cmd.ExecuteNonQuery();
                status = cmd.Parameters["@returnVal"].Value.ToString();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                cmd.Dispose();
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(status);
        }
Ejemplo n.º 18
0
 public ActionResult AddEmployee(EmpDetails empDetails)
 {
     employeeContext.EmpDetailss.Add(empDetails);
     employeeContext.SaveChanges();
     return(RedirectToAction("EmpDetailsList"));
 }
Ejemplo n.º 19
0
 public void UpdateEmployee(EmpDetails emp)
 {
     _context.Update(emp);
 }
Ejemplo n.º 20
0
 public void UpdateEmployee(EmpDetails emp)
 {
     _repo.UpdateEmployee(emp);
 }
Ejemplo n.º 21
0
 public void AddEmployee(EmpDetails emp)
 {
     _context.EmpDetails.Add(emp);
     _context.SaveChanges();
 }
Ejemplo n.º 22
0
 static void Main(string[] args)
 {
     var datacontext = new EmpDetails();
     var emp         = new BaseRepository <EmpDetails>(data);
 }