private void btnXacNhanLoGin_Click(object sender, EventArgs e)
 {
     using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
     {
         TaiKhoan taiKhoan = quanli.TaiKhoans.Where(s => s.TenTaiKhoan == txtTenDangNhap.Text).Where(s => s.MatKhau == txtMatKhau.Text)
                             .FirstOrDefault();
         if (taiKhoan != null)
         {
             if (taiKhoan.ID == 1)
             {
                 frmMAIN frmMAIN = new frmMAIN();
                 frmMAIN.ShowDialog();
             }
             if (taiKhoan.ID == 2)
             {
                 frmMAIN frmMAIN = new frmMAIN();
                 frmMAIN.ShowDialog();
             }
         }
         else
         {
             MessageBox.Show("Khong ton tai tai khoan nay");
         }
     }
 }
        public void timkiem(string s)
        {
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())

            {
                dgvhoadon.DataSource = quanli.seaching_tongtienthang1(s);
            }
        }
        public void timkiem(string s)
        {
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())

            {
                dataGridView1.DataSource = quanli.seaching_nv(s);
            }
        }
 void loadchart()
 {
     using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
     {
         chart1.DataSource = quanli.dttn().ToList();
         chart1.Series["VND"].XValueMember  = "thang";
         chart1.Series["VND"].YValueMembers = "tongtien";
     }
 }
Beispiel #5
0
 private void cbmasp_SelectedIndexChanged(object sender, EventArgs e)
 {
     using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
     {
         SanPham sanPham = quanli.SanPhams.Where(s => s.MaSP == cbmasp.Text).FirstOrDefault();
         if (sanPham != null)
         {
             txtdongia.Text = sanPham.GiaBan.ToString();
         }
     }
 }
 private void btnXoa_Click(object sender, EventArgs e)
 {
     using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
     {
         CTPHIEUNHAP hd = quanli.CTPHIEUNHAPs.Where(p => p.MaPN == cbmaPN.Text).Where(p => p.MaSP == cbmasp.Text).FirstOrDefault();
         if (hd != null)
         {
             quanli.CTPHIEUNHAPs.Remove(hd);
             quanli.SaveChanges();
             MessageBox.Show("Đã xóa!");
             frmCTPhieuNhap_Load(sender, e);
         }
     }
 }
Beispiel #7
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     if (!kiemtra())
     {
         return;
     }
     using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
     {
         quanli.danhmuc123(textBox2.Text);
         quanli.SaveChanges();
         MessageBox.Show("Thêm thành công!");
         frmDanhMuc_Load(sender, e);
     }
 }
 private void button1_Click(object sender, EventArgs e)
 {
     if (!kiemtra())
     {
         return;
     }
     using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
     {
         quanli.INSSERTPN(txtngaynhap.Value, int.Parse(txttongtiennhap.Text), txttinhtrang.Text, cbncc.Text, cbmanv.Text);
         quanli.SaveChanges();
         MessageBox.Show("Thêm!");
         quanlinhaphang_Load(sender, e);
     }
 }
 private void txtsoluong_TextChanged(object sender, EventArgs e)
 {
     if (txtsoluong.Text != "")
     {
         using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
         {
             SanPham sanPham = quanli.SanPhams.Where(s => s.MaSP == cbmasp.Text).FirstOrDefault();
             if (sanPham != null)
             {
                 int i = Convert.ToInt32(sanPham.GiaBan) * Convert.ToInt32(txtsoluong.Text);
                 txtthanhtien.Text = i.ToString();
             }
         }
     }
 }
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (!kiemtra())
            {
                return;
            }
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                quanli.insertSP(txttensp.Text, txtmanhom.Text, int.Parse(txtgiaban.Text), int.Parse(txtslton.Text), ImageToByteArray(pcHinh.Image));

                quanli.SaveChanges();
                MessageBox.Show("Thêm thành công!");
                frmSanPham_Load(sender, e);
            }
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (!kiemtra())
            {
                return;
            }
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                quanli.insertKH(txttenkh.Text, dtngaysinh.Value, int.Parse(txtsdt.Text), txtgmail.Text);

                quanli.SaveChanges();
                MessageBox.Show("Thêm thành công!");
                frmKhachhnag_Load(sender, e);
            }
        }
        private void btnThem_Click_1(object sender, EventArgs e)
        {
            if (!kiemtra())
            {
                return;
            }
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                quanli.insertNV(txtTNV.Text, txtCV.Text, dateTimePicker1.Value, int.Parse(txtLuong.Text), txtGmail.Text, int.Parse(txtSDT.Text));

                quanli.SaveChanges();
                MessageBox.Show("Thêm thành công!");
                frmNhanvien_Load(sender, e);
            }
        }
Beispiel #13
0
        private void Form2_Load(object sender, EventArgs e)
        {
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                cbmahd.DataSource    = quanli.HOADONs.ToList();
                cbmahd.DisplayMember = "MaHD";
                cbmahd.ValueMember   = "MaHD";

                cbmasp.DataSource         = quanli.SanPhams.ToList();
                cbmasp.DisplayMember      = "MaSP";
                cbmasp.ValueMember        = "MaSP";
                dgvhd.AutoGenerateColumns = false;
                dgvhd.DataSource          = quanli.cthoadons.ToList();
            }
        }
Beispiel #14
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
     {
         quanli.inssertCThoadon(txtmact.Text, cbmahd.Text, cbmasp.Text, Convert.ToInt32(txtsl.Text), Convert.ToInt32(txtthanhtien.Text));
         quanli.update_Hd(cbmahd.Text, Convert.ToInt32(txtthanhtien.Text));
         SanPham sanPham = quanli.SanPhams.Where(s => s.MaSP == cbmasp.Text).FirstOrDefault();
         if (sanPham != null)
         {
             sanPham.SoLuongTon -= Convert.ToInt32(txtsl.Text);
         }
         quanli.SaveChanges();
         MessageBox.Show("Thêm thành công!");
         Form2_Load(sender, e);
     }
 }
        private void btnSua_Click(object sender, EventArgs e)
        {
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                CTPHIEUNHAP kh = quanli.CTPHIEUNHAPs.Where(p => p.MaPN == cbmaPN.Text).Where(p => p.MaSP == cbmasp.Text).FirstOrDefault();
                //kh.MaPN = txtmaphieunhap.Text;

                kh.GiaNhap   = Convert.ToInt32(txtgianhap.Text);
                kh.SoLuong   = Convert.ToInt32(txtsoluong.Text);
                kh.ThanhTien = Convert.ToInt32(txtthanhtien.Text);

                quanli.SaveChanges();
                MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                frmCTPhieuNhap_Load(sender, e);
            }
        }
        private void frmCTPhieuNhap_Load(object sender, EventArgs e)

        {
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                cbmasp.DataSource    = quanli.SanPhams.ToList();
                cbmasp.DisplayMember = "MaSP";
                cbmasp.ValueMember   = "MaSP";

                cbmaPN.DataSource    = quanli.PHIEUNHAPs.ToList();
                cbmaPN.DisplayMember = "MaPN";
                cbmaPN.ValueMember   = "MaPN";
            }

            // TODO: This line of code loads data into the 'qLBanXeDataSet12.CTPHIEUNHAP' table. You can move, or remove it, as needed.
            this.cTPHIEUNHAPTableAdapter.Fill(this.qLBanXeDataSet12.CTPHIEUNHAP);
        }
 private void btnXoa_Click_1(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa nhân viên này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
     {
         using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
         {
             NhanVien hd = quanli.NhanViens.FirstOrDefault(p => p.MaNV == manv);
             if (hd != null)
             {
                 quanli.NhanViens.Remove(hd);
                 quanli.SaveChanges();
                 MessageBox.Show("Đã xóa!");
                 frmNhanvien_Load(sender, e);
             }
         }
     }
 }
 private void button2_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa hóa đơn này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
     {
         using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
         {
             PHIEUNHAP hd = quanli.PHIEUNHAPs.FirstOrDefault(p => p.MaPN == mapn);
             if (hd != null)
             {
                 quanli.PHIEUNHAPs.Remove(hd);
                 quanli.SaveChanges();
                 MessageBox.Show("Đã xóa!");
                 quanlinhaphang_Load(sender, e);
             }
         }
     }
 }
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
     {
         using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
         {
             SanPham hd = quanli.SanPhams.FirstOrDefault(p => p.MaSP == txtmasp.Text);
             if (hd != null)
             {
                 quanli.SanPhams.Remove(hd);
                 quanli.SaveChanges();
                 MessageBox.Show("Đã xóa!");
                 frmSanPham_Load(sender, e);
             }
         }
     }
 }
        private void btnThem_Click_1(object sender, EventArgs e)
        {
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                quanli.insertctphieunhap123(cbmaPN.Text, cbmasp.Text, int.Parse(txtgianhap.Text), int.Parse(txtsoluong.Text), int.Parse(txtthanhtien.Text));

                SanPham sanPham = quanli.SanPhams.Where(s => s.MaSP == cbmasp.Text).FirstOrDefault();
                if (sanPham != null)
                {
                    sanPham.SoLuongTon += int.Parse(txtsoluong.Text);
                }


                quanli.SaveChanges();
                MessageBox.Show("Thêm thành công!");
                frmCTPhieuNhap_Load(sender, e);
            }
        }
Beispiel #21
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (madm == "")
            {
                MessageBox.Show("Hãy chọn Danh mục cần sửa!");
                return;
            }
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                DanhMuc kh = quanli.DanhMucs.FirstOrDefault(p => p.MaNhom == madm);
                //kh.MaPN = txtmaphieunhap.Text;
                kh.TenNhom = textBox2.Text;


                quanli.SaveChanges();
                MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                frmDanhMuc_Load(sender, e);
            }
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (txtmakh.Text == "")
            {
                MessageBox.Show("Hãy chọn khách hàng cần sửa!");
                return;
            }
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                KHACHHANG kh = quanli.KHACHHANGs.FirstOrDefault(p => p.MaKH == txtmakh.Text);

                kh.TenKH    = txttenkh.Text;
                kh.NgaySinh = dtngaysinh.Value;
                kh.SDT      = int.Parse(txtsdt.Text);
                kh.Gmail    = txtgmail.Text;

                quanli.SaveChanges();
                MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                frmKhachhnag_Load(sender, e);
            }
        }
 private void button3_Click(object sender, EventArgs e)
 {
     if (mapn == "")
     {
         MessageBox.Show("Hãy chọn khách hàng cần sửa!");
         return;
     }
     using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
     {
         PHIEUNHAP kh = quanli.PHIEUNHAPs.FirstOrDefault(p => p.MaPN == mapn);
         //kh.MaPN = txtmaphieunhap.Text;
         kh.NgayLapPN = txtngaynhap.Value;
         kh.TongTien  = int.Parse(txttongtiennhap.Text);
         kh.TinhTrang = txttinhtrang.Text;
         kh.MaNCC     = cbncc.Text;
         kh.MaNV      = cbmanv.Text;
         quanli.SaveChanges();
         MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         quanlinhaphang_Load(sender, e);
     }
 }
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (txtmasp.Text == "")
            {
                MessageBox.Show("Hãy chọn dòng cần sửa!");
                return;
            }
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                SanPham kh = quanli.SanPhams.FirstOrDefault(p => p.MaSP == txtmasp.Text);
                // kh.MaSP = txtmasp.Text;
                kh.TenSP      = txttensp.Text;
                kh.MaNhom     = txtmanhom.Text;
                kh.GiaBan     = int.Parse(txtgiaban.Text);
                kh.SoLuongTon = int.Parse(txtslton.Text);
                kh.HinhAnh    = ImageToByteArray(pcHinh.Image);

                quanli.SaveChanges();
                MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                frmSanPham_Load(sender, e);
            }
        }
        private void btnSua_Click_1(object sender, EventArgs e)
        {
            if (manv == "")
            {
                MessageBox.Show("Hãy chọn Nhân Viên cần sửa!");
                return;
            }
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                NhanVien kh = quanli.NhanViens.FirstOrDefault(p => p.MaNV == manv);
                //kh.MaPN = txtmaphieunhap.Text;
                kh.TenNV      = txtTNV.Text;
                kh.ChucVu     = txtCV.Text;
                kh.NgayVaoLam = dateTimePicker1.Value;
                kh.Luong      = int.Parse(txtLuong.Text);
                kh.Gmail      = txtGmail.Text;
                kh.SDT        = int.Parse(txtSDT.Text);

                quanli.SaveChanges();
                MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                frmNhanvien_Load(sender, e);
            }
        }
        private void quanlinhaphang_Load(object sender, EventArgs e)


        {
            using (QLBanXeEntities1 quanli = new QLBanXeEntities1())
            {
                cbncc.DataSource    = quanli.NhaCungCaps.ToList();
                cbncc.DisplayMember = "MaNCC";
                cbncc.ValueMember   = "MaNCC";

                cbmanv.DataSource    = quanli.NhanViens.ToList();
                cbmanv.DisplayMember = "MaNV";
                cbmanv.ValueMember   = "MaNV";
            }
            // TODO: This line of code loads data into the 'qLBanXeDataSet3.PHIEUNHAP' table. You can move, or remove it, as needed.
            this.pHIEUNHAPTableAdapter3.Fill(this.qLBanXeDataSet3.PHIEUNHAP);
            // TODO: This line of code loads data into the 'qLBanXeDataSet2.PHIEUNHAP' table. You can move, or remove it, as needed.
            this.pHIEUNHAPTableAdapter2.Fill(this.qLBanXeDataSet2.PHIEUNHAP);
            //// TODO: This line of code loads data into the 'qLBanXeDataSet1.PhieuNhap' table. You can move, or remove it, as needed.
            //this.phieuNhapTableAdapter1.Fill(this.qLBanXeDataSet1.PhieuNhap);
            //// TODO: This line of code loads data into the 'qLBanXeDataSet.PhieuNhap' table. You can move, or remove it, as needed.
            //this.phieuNhapTableAdapter.Fill(this.qLBanXeDataSet.PhieuNhap);
        }