Exemple #1
0
 public static ApplicationRole AddMap(this LoaiTKDTO dto)
 {
     return(new ApplicationRole
     {
         Name = dto.Name,
         NormalizedName = dto.Name.ToUpper(),
     });
 }
Exemple #2
0
        public bool XoaLoaiTK(LoaiTKDTO DTO)
        {
            string DELETE = "UPDATE LOAI_TAI_KHOAN SET TINHTRANG=0 WHERE  MALOAITK = @MaLoaiTK";

            SqlParameter[] p = new SqlParameter[1];

            p[0] = new SqlParameter("@MaLoaiTK", DTO.MaLoaiTK);
            SqlConnection con = DataProvider.TaoKetNoi();
            int           kq  = DataProvider.ThucThiCauLenh(DELETE, p, con);

            con.Close();
            return(kq > 0);
        }
Exemple #3
0
        public bool SuaLoaiTK(LoaiTKDTO DTO)
        {
            string UPDATE = "UPDATE LOAI_TAI_KHOAN SET TENLOAITK=@TenLoaiTK,TINHTRANG=@TINHTRANG WHERE MALOAITK=@MaLoaiTK";

            SqlParameter[] p = new SqlParameter[3];
            p[0] = new SqlParameter("@MaLoaiTK", DTO.MaLoaiTK);
            p[1] = new SqlParameter("@TenLoaiTK", DTO.TenLoaiTK);
            p[2] = new SqlParameter("@TinhTrang", DTO.TinhTrang);
            SqlConnection con = DataProvider.TaoKetNoi();
            int           kq  = DataProvider.ThucThiCauLenh(UPDATE, p, con);

            con.Close();
            return(kq > 0);
        }
Exemple #4
0
        public bool ThemLoaiTK(LoaiTKDTO DTO)
        {
            string INSERT = "INSERT INTO LOAI_TAI_KHOAN VALUES(@MaLoaiTK,@TenLoaiTK,@TinhTrang)";

            SqlParameter[] p = new SqlParameter[3];
            p[0] = new SqlParameter("@MaLoaiTK", DTO.MaLoaiTK);
            p[1] = new SqlParameter("@TenLoaiTK", DTO.TenLoaiTK);
            p[2] = new SqlParameter("@TinhTrang", DTO.TinhTrang);
            SqlConnection con = DataProvider.TaoKetNoi();
            int           kq  = DataProvider.ThucThiCauLenh(INSERT, p, con);

            con.Close();
            return(kq > 0);
        }
        public async Task <IActionResult> AddPost(LoaiTKDTO dto)
        {
            var message = "";

            if (!ModelState.IsValid)
            {
                return(View("~/Views/Admin/Role/Add.cshtml", dto));
            }

            message         = "Tạo thành công";
            ViewBag.Message = message;
            var loaiTK = dto.AddMap();
            await _roleRepository.Add(loaiTK);

            return(View("~/Views/Admin/Role/Add.cshtml", dto));
        }
Exemple #6
0
        private void dgvDSLoaiTK_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvDSLoaiTK.SelectedRows.Count > 0)
            {
                btnXoaLTK.Enabled  = true;
                btnSuaLTK.Enabled  = true;
                btnThemLTK.Enabled = false;;

                chon1 = (LoaiTKDTO)dgvDSLoaiTK.SelectedRows[0].DataBoundItem;
            }
            else
            {
                chon = null;
            }
            BindLoaiChiTietTK();
        }
Exemple #7
0
 private void luuDuLieuLoaiTK()
 {
     if (chon1 == null)
     {
         chon1 = new LoaiTKDTO();
     }
     chon1.MaLoaiTK  = txtMaLoaiTK.Text;
     chon1.TenLoaiTK = txtTenLoaiTK.Text;
     if (chkTinhTrang.Checked == false)
     {
         chon1.TinhTrang = 0;
     }
     else
     {
         chon1.TinhTrang = 1;
     }
 }
        public async Task <IActionResult> EditPost(string id, LoaiTKDTO dto)
        {
            var message = "";

            if (!ModelState.IsValid)
            {
                return(View("~/Views/Admin/Role/Edit.cshtml", dto));
            }

            var loaiTK = await _roleRepository.getById(id);

            //Update Du Lieu
            loaiTK = dto.EditMap(loaiTK);
            await _roleRepository.Update(loaiTK);

            message         = "Sửa thành công";
            ViewBag.Message = message;
            return(View("~/Views/Admin/Role/Edit.cshtml", dto));
        }
Exemple #9
0
        public List <LoaiTKDTO> LoadDSLoaiTK()
        {
            List <LoaiTKDTO> NXS     = new List <LoaiTKDTO>();
            string           truyvan = "SELECT *  FROM LOAI_TAI_KHOAN WHERE TINHTRANG=1 ";
            SqlConnection    con     = DataProvider.TaoKetNoi();
            SqlDataReader    sr      = DataProvider.TruyVanDuLieu(truyvan, con);

            while (sr.Read())
            {
                LoaiTKDTO NX = new LoaiTKDTO();
                NX.MaLoaiTK  = sr["MaLoaiTK"].ToString();
                NX.TenLoaiTK = sr["TenLoaiTK"].ToString();
                NX.TinhTrang = int.Parse(sr["TinhTrang"].ToString());
                NXS.Add(NX);
            }
            sr.Close();
            con.Close();
            return(NXS);
        }
Exemple #10
0
 private void btnSuaLTK_Click(object sender, EventArgs e)
 {
     if (txtMaLoaiTK.Text != "" && txtTenLoaiTK.Text != "")
     {
         luuDuLieuLoaiTK();
         if (bus1.SuaTTTK(chon1))
         {
             dto1 = bus1.LoadDSLoaiTK();
             dgvDSLoaiTK.DataSource = dto1;
             MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("Cập nhật thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             chon1 = null;
         }
     }
     else
     {
         MessageBox.Show("Làm ơn, nhập đầy đủ thông tin Loại Tài Khoản !!! ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemple #11
0
 private void btnXoaLTK_Click(object sender, EventArgs e)
 {
     if (chon1.TinhTrang == 0)
     {
         MessageBox.Show("Loại tài khoản không tồn tại ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         luuDuLieuLoaiTK();
         if (bus1.XoaTTTK(chon1))
         {
             dto1 = bus1.LoadDSLoaiTK();
             dgvDSLoaiTK.DataSource = dto1;
             MessageBox.Show("Xóa thành công ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtMaLoaiTK.Clear();
             txtTenLoaiTK.Clear();
         }
         else
         {
             MessageBox.Show("Xóa thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             chon1 = null;
         }
     }
 }
        public IActionResult Add()
        {
            LoaiTKDTO dto = new LoaiTKDTO();

            return(View("~/Views/Admin/Role/Add.cshtml", dto));
        }
Exemple #13
0
 public static ApplicationRole EditMap(this LoaiTKDTO dto, ApplicationRole loaiTK)
 {
     loaiTK.Name           = dto.Name;
     loaiTK.NormalizedName = dto.Name.ToUpper();
     return(loaiTK);
 }
Exemple #14
0
        public bool XoaTTTK(LoaiTKDTO DTO)
        {
            LoaiTKDAO dao = new LoaiTKDAO();

            return(dao.XoaLoaiTK(DTO));
        }
Exemple #15
0
        public bool ThemLoaiTK(LoaiTKDTO DTO)
        {
            LoaiTKDAO dao = new LoaiTKDAO();

            return(dao.ThemLoaiTK(DTO));
        }