Esempio n. 1
0
        private void BtSuaNV_Click(object sender, EventArgs e)
        {
            SuaNhanVien suaNV = new SuaNhanVien();

            this.Hide();
            suaNV.ShowDialog();
            this.Show();
        }
Esempio n. 2
0
 public bool UpdateNhanVien(SuaNhanVien SuaNhanVien)
 {
     try
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@MaNV", SuaNhanVien.MaNV);
         parameters.Add("@IDPB", SuaNhanVien.IDPB);
         parameters.Add("@HoTen", SuaNhanVien.HoTen);
         parameters.Add("@SoDienThoai", SuaNhanVien.SoDienThoai);
         SqlMapper.Execute(con, "UpdateNhanVien", param: parameters, commandType: CommandType.StoredProcedure);
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
 public int SuaNhanVien(SuaNhanVien request)
 {
     try
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@MaNV", request.MaNV);
         parameters.Add("@Ho", request.Ho);
         parameters.Add("@Ten", request.Ten);
         parameters.Add("@DiaChi", request.DiaChi);
         parameters.Add("@DienThoai", request.DienThoai);
         parameters.Add("@Email", request.Email);
         parameters.Add("@PhongBanId", request.PhongBanId);
         var id = SqlMapper.ExecuteScalar <int>(con, "SuaNhanVien", param: parameters, commandType: CommandType.StoredProcedure);
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 4
0
        public IActionResult SuaNhanVien(SuaNhanVien model)
        {
            var editResult     = 0;
            var httpWebRequest = (HttpWebRequest)WebRequest.Create($"{Common.Common.ApiUrl}/nhanvien/suanhanvien");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "PUT";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                var json = JsonConvert.SerializeObject(model);

                streamWriter.Write(json);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                editResult = int.Parse(result);
            }

            ViewBag.PhongBans  = DanhSachPhongBan();
            ViewBag.PhongBanId = phongBanId;

            if (editResult <= 0)
            {
                TempData["Loi"] = "Đã xảy ra lỗi khi cập nhật thông tin nhân viên";
                return(View(model));
            }
            else
            {
                TempData["ThanhCong"] = "Thông tin nhân viên đã được cập nhật";
                ModelState.Clear();
                return(View(new SuaNhanVien()
                {
                    PhongBanId = phongBanId
                }));
            }
        }
Esempio n. 5
0
        public IActionResult SuaNhanVien(SuaNhanVien model)
        {
            int editResult = 0;
            //var url = $"{Common.Common.ApiUrl}/phongban/suaphongban";

            //HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            var httpWebRequest = (HttpWebRequest)WebRequest.Create($"{Common.Common.ApiUrl}/nhanvien/suanhanvien");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "PUT";
            using (var streamWrite = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                var json = JsonConvert.SerializeObject(model);
                streamWrite.Write(json);
            }
            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                editResult = int.Parse(result);
            }
            ViewBag.PhongBans  = DanhSachPhongBan();
            ViewBag.PhongBanId = phongBanId;
            if (editResult <= 0)
            {
                TempData["Loi"] = "TeamData sửa  KHÔNG thành công";
                return(View(model));
            }
            else
            {
                TempData["ThanhCong"] = "TeamData-đã sửa thành công";
                ModelState.Clear();
                return(View(new SuaNhanVien()
                {
                    PhongBanId = phongBanId
                }));
            }
        }
Esempio n. 6
0
        public IActionResult SuaNhanVien(int id)
        {
            var            nhanvien       = new SuaNhanVien();
            var            url            = $"{Common.Common.ApiUrl}/nhanvien/laynhanvien/{id}";
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);

            httpWebRequest.Method = "GET";
            var response = httpWebRequest.GetResponse();

            {
                string responseData;
                Stream responseStream = response.GetResponseStream();
                try
                {
                    StreamReader streamReader = new StreamReader(responseStream);
                    try
                    {
                        responseData = streamReader.ReadToEnd();
                    }
                    finally
                    {
                        ((IDisposable)streamReader).Dispose();
                    }
                }
                finally
                {
                    ((IDisposable)responseStream)?.Dispose();
                }

                nhanvien = JsonConvert.DeserializeObject <SuaNhanVien>(responseData);
            }
            ViewBag.PhongBans     = DanhSachPhongBan();
            ViewBag.PhongBanId    = nhanvien.PhongBanId;
            TempData["Loi"]       = null;
            TempData["ThanhCong"] = null;
            return(View(nhanvien));
        }
Esempio n. 7
0
 public int SuaNhanVien([FromBody] SuaNhanVien request)
 {
     return(_nhanVienService.SuaNhanVien(request));
 }
Esempio n. 8
0
 public int SuaNhanVien(SuaNhanVien request)
 {
     return(_nhanVienResponsitory.SuaNhanVien(request));
 }
Esempio n. 9
0
 public bool UpdateNhanVien(SuaNhanVien SuaNhanVien)
 {
     return(_NhanVienRepository.UpdateNhanVien(SuaNhanVien));
 }
Esempio n. 10
0
 public bool UpdateNV([FromBody] SuaNhanVien SuaNhanVien)
 {
     return(_NhanVienService.UpdateNhanVien(SuaNhanVien));
 }