示例#1
0
        private void TaoMaXacNhan()
        {
            string code = "";
            string email, username;

            email    = txtEmail.Text;
            username = txtUsername.Text;
            code     = Ham.RamdomCode(6);
            cn.ExecuteNonQuery("UPDATE HTUser set Code = '" + code + "' where email = '" + email + "' and taikhoan = '" + username + "'");
            GuiMa(code);
        }
示例#2
0
        private void Delete(int id)
        {
            var confirmResult = MessageBox.Show("Bạn có muốn xóa ??",
                                                "Cảnh báo!!",
                                                MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                con.ExecuteNonQuery("delete loaisanpham where id = " + id);
                GetAll();
            }
        }
示例#3
0
 private void btnCapNhat_Click(object sender, EventArgs e)
 {
     try
     {
         bool gt = cbGioiTinh.SelectedIndex == 0 ? true : false;
         cn.ExecuteNonQuery("UPDATE HTUSER  set ten = N'" + txtTen.Text + "',ngaysinh= '" + datePickNgaySinh.Value.ToString() + "',sdt= '" + txtSdt.Text +
                            "',gioitinh = '" + gt + "',diachi = N'" + txtQueQuan.Text + "' where id = " + id);
         MessageBox.Show("Thay đổi thông tin thành công", "Thông báo");
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#4
0
        //check hoa don
        private void CheckHoaDon()
        {
            var data = conn.getDataTable("select top 1 * from hoadon where khachhangId =" + LuuThongTin.id + " and trangthai =N'" + TrangThai.TaoPhieu + "'");

            if (data.Rows.Count > 0)
            {
                IdHoaDon = Int32.Parse(data.Rows[0][0].ToString());
            }
            else
            {
                // khong co hoa dong nao
                conn.ExecuteNonQuery("insert into hoadon (khachhangId, nhanvienId,ngaydat,noigiaohang,sdt,trangthai) values("
                                     + LuuThongTin.id + ",NULL,NULL,NULL,NULL,N'" + TrangThai.TaoPhieu + "')");
                CheckHoaDon();
            }
        }
示例#5
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!");
            }
        }
示例#6
0
        private void CheckPhieu()
        {
            var data = cn.getDataTable("SELECT top 1 id from phieu where nhanvienId ="
                                       + LuuThongTin.id + " and trangthai =N'" + TrangThai.TaoPhieu + "' and loaiphieuId = 1");

            if (data.Rows.Count > 0)
            {
                phieuId = Int32.Parse(data.Rows[0][0].ToString());
            }
            else
            {
                cn.ExecuteNonQuery("insert into phieu (ngaytao,ngayketthuc,trangthai,nhanvienId,loaiphieuId)" +
                                   " values ('" + DateTime.Now + "',NULL,N'" + trangthai + "'," + LuuThongTin.id + ",1)");
                CheckPhieu();
            }
        }
示例#7
0
        private void TaiTaiKhoan()
        {
            try
            {
                string ten, ngaysinh, sdt, quequan, username, password, email;

                bool active = true;
                bool gioitinh;
                ten      = txtHoTen.Text;
                ngaysinh = dateNgaySinh.Value.ToString();
                gioitinh = cbGioiTinh.SelectedItem.ToString() == "Nam" ? true : false;
                sdt      = txtSDT.Text;
                quequan  = txtDiaChi.Text;
                username = txtTaiKhoan.Text;
                password = Ham.EncodePassword(txtMatKhau.Text);
                email    = txtEmail.Text;
                if (!String.IsNullOrEmpty(txtHoTen.Text) && !String.IsNullOrEmpty(txtMatKhau.Text) && !String.IsNullOrEmpty(txtTaiKhoan.Text))
                {
                    if (txtMatKhau2.Text == txtMatKhau.Text)
                    {
                        if (!CheckUsername(username))
                        {
                            MessageBox.Show("Tài khoản đã tồn tại trong hệ thống!", "Thông báo!");
                        }
                        else
                        {
                            string sql = "Insert into HTUser (ten,ngaysinh,sdt,gioitinh,diachi,taikhoan,matkhau,active,roleId,email) values(N'" + ten +
                                         "','" + ngaysinh + "','" + sdt + "','" + gioitinh + "',N'" + quequan + "','" + username + "','" + password + "','" + active + "'," + quyen + ",'" + email + "')";
                            conn.ExecuteNonQuery(sql);
                            MessageBox.Show("Tạo tài khoản thành công!", "Thông báo");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Mật khẩu không khớp!", "Thông báo!");
                    }
                }
                else
                {
                    MessageBox.Show("Kiểm tra lại thông tin!", "Thông báo!");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Kiểm tra lại thông tin!", "Thông báo!");
            }
        }
示例#8
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");
        }
示例#9
0
 private void HoanThanh(int id)
 {
     cn.ExecuteNonQuery("update hoadon set trangthai =N'" + TrangThai.HoanThanh + "', ngayhoanthanh = '" + DateTime.Now + "' where id = " + id);
 }
示例#10
0
 private void HuyDon(int id)
 {
     cn.ExecuteNonQuery("update hoadon set trangthai =N'" + TrangThai.DaHuy + "' where id = " + id);
 }