示例#1
0
        private void updateNhanVien()
        {
            string   ten, sdt, quequan, username;
            int      id, active, quyen;
            bool     gioitinh;
            DateTime ngaysinh;

            id       = int.Parse(txtMa.Text);
            ten      = txtTen.Text;
            sdt      = txtSdt.Text;
            quequan  = txtQueQuan.Text;
            username = txtUsername.Text;
            quyen    = Ham.GetIdFromCombobox(cbQuyen.SelectedItem.ToString());
            gioitinh = Ham.NamNuToTrueFalse(cbGioiTinh.SelectedItem.ToString());
            active   = checkActive.Checked ? 1 : 0;
            ngaysinh = dateTimePicker1.Value;
            string sql = "update HTUser set ten = N'" + ten + "',ngaysinh = '" + ngaysinh + "',sdt = '" + sdt + "',gioitinh = '" + gioitinh + "'" +
                         ",diachi = N'" + quequan + "',taikhoan = '" + username + "',active = " + active + ",roleId =" + quyen + " where id = " + id;

            try
            {
                cn.ExecuteNonQuery(sql);
                getDataNhanVien();
            }
            catch (Exception)
            {
                MessageBox.Show("Kiểm tra lại thông tin", "Thông báo!");
            }
        }
示例#2
0
        private void getDataNhanVien()
        {
            sSearch = txtSearch.Text;
            if (cbTrangThai.SelectedIndex == 0)
            {
                sTrangThai = 2;
            }
            else if (cbTrangThai.SelectedIndex == 1)
            {
                sTrangThai = 1;
            }
            else
            {
                sTrangThai = 0;
            }
            if (cbSearchChucVu.SelectedIndex == 0)
            {
                sRole = 0;
            }
            else
            {
                sRole = Ham.GetIdFromCombobox(cbSearchChucVu.SelectedItem.ToString());
            }

            DataTable tb = cn.getDataTable("select u.id,u.ten,u.ngaysinh,u.sdt,u.gioitinh,u.diachi,u.taikhoan,u.active,(convert(varchar,u.roleId) + ' -' + r.ten) as 'Quyền' from HTUser u " +
                                           "join HTRole r on u.roleId = r.id where (" + sTrangThai + " = 2 or u.active = " + sTrangThai + ") and (" + sRole + " = 0 or u.roleid = " + sRole + ")");

            dataGridView1.DataSource = tb;
        }
示例#3
0
 private void cbQuyen_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (quyen != 3)
     {
         quyen = Ham.GetIdFromCombobox(cbQuyen.SelectedItem.ToString());
     }
 }
示例#4
0
 private void cbSNhanVien_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbSNhanVien.SelectedIndex != 0)
     {
         SIdNV = Ham.GetIdFromCombobox(cbSNhanVien.SelectedItem.ToString());
     }
     else
     {
         SIdNV = 0;
     }
     getAll();
 }
示例#5
0
        private void Insert()
        {
            int      id, soluong, gianhap, giaban, giaKM, khoId, nccId, loaispId, luotxem, danhgia;
            DateTime ngaynhap;
            string   ten, mausac, manhinh, camera, cpu, ram, rom, baohanh, phukiendikem, mota;
            bool     active;

            ten          = txtTen.Text;
            soluong      = 0;
            gianhap      = Int32.Parse(txtGiaNhap.Text);
            giaban       = Int32.Parse(txtGiaBan.Text);
            giaKM        = Int32.Parse(txtGiaKM.Text);
            mausac       = txtMauSac.Text;
            manhinh      = txtManHinh.Text;
            camera       = txtCamera.Text;
            cpu          = txtCPU.Text;
            ram          = txtRam.Text;
            rom          = txtRom.Text;
            baohanh      = txtBaoHanh.Text;
            phukiendikem = txtPhuKien.Text;
            mota         = txtMoTa.Text;
            active       = ckHoatDong.Checked;
            khoId        = Ham.GetIdFromCombobox(cbKho.SelectedItem.ToString());
            nccId        = Ham.GetIdFromCombobox(cbNCC.SelectedItem.ToString());
            loaispId     = Ham.GetIdFromCombobox(cbLoai.SelectedItem.ToString());
            ngaynhap     = DateTime.Now;
            luotxem      = 0;
            danhgia      = 0;
            string sql   = @"INSERT INTO [dbo].[SanPham]([ten],[soluong],[gianhap],[giaban],[giaKM],[mausac],[manhinh],[camera],[cpu],[ram]  ,[rom]  ,[baohanh] ,[phukiendikem]  ,[ngaynhap]  ,[mota] ,[khoId] ,[nccId],[loaispId],[active],[luotxem],[danhgia]) VALUES
           (N'" + ten + "'," + soluong + "," + gianhap + " ," + giaban + "," + giaKM + ",N'" + mausac + "',N'" + manhinh + "',N'" + camera + "', N'" + cpu + "' , N'" + ram + "', N'" + rom + "', N'" + baohanh + "', N'" + phukiendikem + "', '" + ngaynhap + "',N'" + mota + "' ," + khoId + " ," + nccId + "," + loaispId + ",1," + luotxem + "," + danhgia + ")";
            var    getId = conn.getDataTable("select top 1 id from sanpham where ten = N'" + ten + "' order by ngaynhap desc");

            txtMa.Text = getId.Rows[0][0].ToString();
            conn.ExecuteNonQuery(sql);
            GetSanPham();
        }
示例#6
0
        private void Update()
        {
            int      id, soluong, gianhap, giaban, giaKM, khoId, nccId, loaispId;
            DateTime ngaynhap;
            string   ten, mausac, manhinh, camera, cpu, ram, rom, baohanh, phukiendikem, mota;
            bool     active;

            id           = Int32.Parse(txtMa.Text);
            ten          = txtTen.Text;
            soluong      = Int32.Parse(txtSoLuong.Text);
            gianhap      = Int32.Parse(txtGiaNhap.Text);
            giaban       = Int32.Parse(txtGiaBan.Text);
            giaKM        = Int32.Parse(txtGiaKM.Text);
            mausac       = txtMauSac.Text;
            manhinh      = txtManHinh.Text;
            camera       = txtCamera.Text;
            cpu          = txtCPU.Text;
            ram          = txtRam.Text;
            rom          = txtRom.Text;
            baohanh      = txtBaoHanh.Text;
            phukiendikem = txtPhuKien.Text;
            mota         = txtMoTa.Text;
            active       = ckHoatDong.Checked;
            khoId        = Ham.GetIdFromCombobox(cbKho.SelectedItem.ToString());
            nccId        = Ham.GetIdFromCombobox(cbNCC.SelectedItem.ToString());
            loaispId     = Ham.GetIdFromCombobox(cbLoai.SelectedItem.ToString());
            ngaynhap     = DateTime.Now;
            string sql = "UPDATE [dbo].[SanPham] SET [ten] = N'" + ten + "',[soluong] = " + soluong + ",[gianhap] = " + gianhap + ",[giaban] = " +
                         giaban + ",[giaKM] = " + giaKM + ",[mausac] = N'" + mausac + "',[manhinh] = N'" + manhinh + "',[camera] = N'" + camera +
                         "',[cpu] = N'" + cpu + "',[ram] = N'" + ram + "',[rom] = N'" + rom + "',[baohanh] = N'" + baohanh + "',[phukiendikem] = N'" + phukiendikem +
                         "',[ngaynhap] = N'" + ngaynhap + "',[mota] = N'" + mota + "',[khoId] = " + khoId + ",[nccId] = " + nccId + ",[loaispId] = " + loaispId + ",[active] = '" + active + "'WHERE id = " + id + "";

            conn.ExecuteNonQuery(sql);
            GetSanPham();
            MessageBox.Show("Sửa thành công", "Thông báo");
        }
示例#7
0
 private void cbSLoai_SelectedIndexChanged(object sender, EventArgs e)
 {
     SloaiId = cbSLoai.SelectedIndex != 0 ? Ham.GetIdFromCombobox(cbSLoai.SelectedItem.ToString()) : 0;
     GetSanPham();
 }