Exemple #1
0
        public List <CTPN> GetList()
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            List <CTPN>           ctpn     = (from c in entities.CTPNs where c.MaPhieuNhap == maphieunhap select c).ToList();

            return(ctpn);
        }
Exemple #2
0
        private void LoadData()
        {
            try
            {
                CuaHangDienTuEntities entities = new CuaHangDienTuEntities();

                var cthd = from X in entities.CTHDs
                           where X.MaHD == MaHD
                           select new
                {
                    // MaHD = X.MaHD,
                    TenSP     = X.SanPham.TenSP,
                    MaSP      = X.MaSP,
                    DonGia    = X.DonGia,
                    SoLuong   = X.SoLuong,
                    ThanhTien = X.ThanhTien
                }
                ;


                dgvNhanVien.DataSource = cthd.ToList();
                dgvNhanVien.Show();
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void LoadDuLieu()
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            var lstpn = from c in entities.PhieuNhaps select new { MaPN = c.MaPhieuNhap, TenNV = c.NhanVien.TenNV, NgayLap = c.NgayLap, TongTien = c.TongTien };

            dgvHD.DataSource = lstpn.ToList();
        }
        //List<NhanVien> listNhanVien;
        public void LoadDuLieu()
        {
            CuaHangDienTuEntities db = new CuaHangDienTuEntities();
            var listNhanVien         = from c in db.NhanViens select new { MaNV = c.MaNV, TenNV = c.TenNV, ChucVu = c.ChucVu, NgaySinh = c.NgaySinh, GioiTinh = c.GioiTinh, SDT = c.SDT };

            dgvNhanVien.DataSource = listNhanVien.ToList();
        }
        public void LoadDuLieu()
        {
            CuaHangDienTuEntities db = new CuaHangDienTuEntities();
            var lstNCC = from c in db.NhaCungCaps select new { MaNCC = c.MaNCC, TenNCC = c.TenNCC, DiaChi = c.DiaChi };

            dgvNhanVien.DataSource = lstNCC.ToList();
        }
        public void LoadDuLieu()
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            var lsthd = from c in entities.HoaDons select new { MaHD = c.MaHD, TenKH = c.KhachHang.TenKH, TenNV = c.NhanVien.TenNV, NgayLap = c.NgayLap, TongTien = c.TongTien };

            dgvHD.DataSource = lsthd.ToList();
        }
Exemple #7
0
        private void txtSDT_KeyDown(object sender, KeyEventArgs e)
        {
            bool dem = false;
            CuaHangDienTuEntities entities     = new CuaHangDienTuEntities();
            List <KhachHang>      lstKhachHang = entities.KhachHangs.ToList();

            if (e.KeyCode == Keys.Enter)
            {
                foreach (var kh in lstKhachHang)
                {
                    if (kh.SDT == Convert.ToInt64(txtSDT.Text))
                    {
                        txtTenKH.Text  = kh.TenKH;
                        dem            = true;
                        pnCTHD.Visible = true;
                        entities.HoaDons.Add(new HoaDon
                        {
                            SDT     = long.Parse(txtSDT.Text),
                            MaNV    = manhanvien,
                            NgayLap = DateTime.Now,
                        });

                        entities.SaveChanges();
                        MaHD = entities.HoaDons.ToList().Last().MaHD;
                        LoadData();
                        //btnThemHD.Enabled = false;
                    }
                }
                if (dem == false)
                {
                    MessageBox.Show("Không tìm thấy khách hàng!");
                }
            }
        }
        public void LoadDuLieu()
        {
            CuaHangDienTuEntities db = new CuaHangDienTuEntities();
            var lstkhachhang         = from c in db.KhachHangs select new { SDT = c.SDT, TenKH = c.TenKH, GioiTinh = c.GioiTinh, NamSinh = c.NamSinh, CMND = c.CMND };

            dgvNhanVien.DataSource = lstkhachhang.ToList();
        }
Exemple #9
0
        public void LoadDuLieu()
        {
            CuaHangDienTuEntities db = new CuaHangDienTuEntities();
            var lstLoai = from c in db.LoaiSanPhams select new { MaLoai = c.MaLoai, TenLoai = c.TenLoai };

            dgvNhanVien.DataSource = lstLoai.ToList();
        }
Exemple #10
0
        public void LoadDuLieu()
        {
            CuaHangDienTuEntities db = new CuaHangDienTuEntities();
            var lstSanPham           = from c in db.SanPhams select new { MaSP = c.MaSP, TenSP = c.TenSP, TenLoai =
                                                                              c.LoaiSanPham.TenLoai, TenNCC = c.NhaCungCap.TenNCC, SoLuongTon = c.SoLuongTon };

            dgvNhanVien.DataSource = lstSanPham.ToList();
        }
Exemple #11
0
        private void LoadDuLieu()
        {
            CuaHangDienTuEntities db = new CuaHangDienTuEntities();
            var lstCTPN = from c in db.CTPNs where c.MaPhieuNhap == maphieu select new { MaSP = c.MaSP, TenSP = c.SanPham.TenSP, SoLuong = c.SoLuong, GiaNhap = c.GiaNhap, ThanhTien = c.ThanhTien };

            dgvNhapHang.DataSource = lstCTPN.ToList();
            dgvNhapHang.Show();
        }
Exemple #12
0
        public void LoadcbbLoaiSP()
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            List <LoaiSanPham>    lstloai  = entities.LoaiSanPhams.ToList();

            cbbLoai.DataSource    = lstloai;
            cbbLoai.ValueMember   = "MaLoai";
            cbbLoai.DisplayMember = "TenLoai";
        }
Exemple #13
0
        public void LoadcbbNCC()
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            List <NhaCungCap>     lstNCC   = entities.NhaCungCaps.ToList();

            cbbNCC.DataSource    = lstNCC;
            cbbNCC.ValueMember   = "MaNCC";
            cbbNCC.DisplayMember = "TenNCC";
        }
        public void LoadcbbSP()
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            List <SanPham>        lstloai  = entities.SanPhams.ToList();

            cbbMaSP.DataSource    = lstloai;
            cbbMaSP.ValueMember   = "MaSP";
            cbbMaSP.DisplayMember = "MaSP";
        }
Exemple #15
0
        private void btnThemCTHD_Click(object sender, EventArgs e)
        {
            string strCn = @"Data Source=LAPTOP-OCUUTDBF\SQLEXPRESS;Initial Catalog=CuaHangDienTu;Integrated Security=True";// đây là chuổi kết nối

            SqlConnection         Cn       = new SqlConnection(strCn);
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            List <SanPham>        lstsp    = entities.SanPhams.ToList();

            foreach (var sp in lstsp)
            {
                if (sp.MaSP == long.Parse(cbbMaSP.SelectedValue.ToString()))
                {
                    if (sp.SoLuongTon >= int.Parse(txtSoLuong.Text))
                    {
                        long sl     = long.Parse(txtSoLuong.Text);
                        long DONGIA = long.Parse(txtDonGia.Text);
                        CTHD cTHD   = new CTHD
                        {
                            MaHD      = this.MaHD,
                            MaSP      = long.Parse(cbbMaSP.SelectedValue.ToString()),
                            DonGia    = long.Parse(txtDonGia.Text),
                            SoLuong   = int.Parse(txtSoLuong.Text),
                            ThanhTien = sl * DONGIA
                        };

                        SqlConnection sqlConnection1 = Cn;
                        try
                        {
                            string SQL = string.Format("INSERT INTO CTHD  VALUES" +
                                                       " ('{0}','{1}','{2}','{3}','{4}') ", +cTHD.MaHD, cTHD.MaSP, cTHD.DonGia, cTHD.SoLuong,
                                                       cTHD.ThanhTien);

                            sqlConnection1.Open();
                            SqlCommand command = new SqlCommand(SQL, sqlConnection1);
                            command.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        finally
                        {
                            sqlConnection1.Close();

                            LoadData();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Không đủ số lượng hàng!");
                    }
                }
            }
        }
        private void btnLap_Click(object sender, EventArgs e)
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();

            entities.PhieuBaoHanhs.Add(new PhieuBaoHanh
            {
                SDT        = long.Parse(txtSDT.Text),
                MaSP       = long.Parse(cbbMaSP.SelectedValue.ToString()),
                NgayMua    = DateTime.Now,
                NgayHetHan = dtpHetHan.Value
            });
            entities.SaveChanges();
        }
        private void cbbMaSP_SelectionChangeCommitted(object sender, EventArgs e)
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            var lstSP = entities.SanPhams.ToList();

            foreach (var c in lstSP)
            {
                if (c.MaSP == long.Parse(cbbMaSP.SelectedValue.ToString()))
                {
                    txtTenSP.Text = c.TenSP;
                }
            }
        }
        private void UC_LapPhieuBH_Load(object sender, EventArgs e)
        {
            LoadcbbSP();
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            var lstSP = entities.SanPhams.ToList();

            foreach (var c in lstSP)
            {
                if (c.MaSP == long.Parse(cbbMaSP.SelectedValue.ToString()))
                {
                    txtTenSP.Text = c.TenSP;
                }
            }
        }
Exemple #19
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();

            entities.CTPNs.Add(new CTPN
            {
                MaPhieuNhap = this.maphieu,
                MaSP        = long.Parse(cbbMaSP.SelectedValue.ToString()),
                SoLuong     = int.Parse(txtSL.Text),
                GiaNhap     = long.Parse(txtGiaNhap.Text),
                ThanhTien   = (long)(int.Parse(txtSL.Text) * long.Parse(txtGiaNhap.Text))
            });
            entities.SaveChanges();
            LoadDuLieu();
        }
Exemple #20
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     using (CuaHangDienTuEntities entities = new CuaHangDienTuEntities())
     {
         entities.KhachHangs.Add(new KhachHang
         {
             SDT      = long.Parse(txtSDT.Text),
             TenKH    = txtTen.Text,
             GioiTinh = cbbGioiTinh.Text,
             NamSinh  = int.Parse(txtNS.Text),
             CMND     = txtcmnd.Text
         });
         entities.SaveChanges();
     }
 }
        private void txttimkiem_KeyDown(object sender, KeyEventArgs e)
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();

            if (e.KeyCode == Keys.Enter)
            {
                foreach (var u in entities.PhieuNhaps.ToList())
                {
                    if (u.MaPhieuNhap == long.Parse(txttimkiem.Text))
                    {
                        var hd = from c in entities.PhieuNhaps where c.MaPhieuNhap == u.MaPhieuNhap select new { MaPN = c.MaPhieuNhap, TenNV = c.NhanVien.TenNV, NgayLap = c.NgayLap, TongTien = c.TongTien };
                        dgvHD.DataSource = hd.ToList();
                    }
                }
            }
        }
Exemple #22
0
        private void LoadData(long mahd)
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();

            var cthd = from X in entities.CTHDs
                       where X.MaHD == mahd
                       select new
            {
                // MaHD = X.MaHD,
                TenSP     = X.SanPham.TenSP,
                MaSP      = X.MaSP,
                DonGia    = X.DonGia,
                SoLuong   = X.SoLuong,
                ThanhTien = X.ThanhTien
            };
            List <CTHD1> cTHDs = new List <CTHD1>();

            foreach (var item in cthd)
            {
                CTHD1 cTHD = new CTHD1();
                cTHD.TenSP1     = item.TenSP;
                cTHD.Soluong1   = (int)item.SoLuong;
                cTHD.Dongia1    = (long)item.DonGia;
                cTHD.ThanhTien1 = (long)item.ThanhTien;
                cTHDs.Add(cTHD);
            }

            entities.HoaDons.Find(mahd);

            ReportParameter[] param = new ReportParameter[4];
            param[0] = new ReportParameter("MaHD", "" + entities.HoaDons.Find(mahd).MaHD);
            param[3] = new ReportParameter("NgayLap", string.Format("Ngày " +
                                                                    entities.HoaDons.Find(mahd).NgayLap));
            param[1] = new ReportParameter("KhachHang", "" + entities.HoaDons.Find(mahd).KhachHang.TenKH);
            param[2] = new ReportParameter("NhanVien", "" + entities.HoaDons.Find(mahd).NhanVien.TenNV);


            var reportDataSource = new ReportDataSource("DataSet1", cTHDs);

            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource);
            //tên hiển thị
            // this.reportViewer1.LocalReport.DisplayName = "Phiếu giao hàng";

            this.reportViewer1.LocalReport.SetParameters(param);
            this.reportViewer1.RefreshReport();
        }
Exemple #23
0
        private void btnPhieuNhap_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Thêm phiếu nhập mới", "Thông báo", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
                entities.PhieuNhaps.Add(new PhieuNhap
                {
                    MaNV    = manhanvien,
                    NgayLap = DateTime.Now
                });
                entities.SaveChanges();
                UC_NhapHang nh = new UC_NhapHang(entities.PhieuNhaps.ToList().Last().MaPhieuNhap);
                AddControl(nh);
            }
        }
Exemple #24
0
        private void frmPhieuNhap_Load(object sender, EventArgs e)
        {
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();

            ReportParameter[] param = new ReportParameter[4];
            param[0] = new ReportParameter("MaPN", Convert.ToString(maphieunhap));
            param[1] = new ReportParameter("TenNV", entities.PhieuNhaps.Find(maphieunhap).NhanVien.TenNV);
            param[2] = new ReportParameter("NgayLap", string.Format("Ngày " + entities.PhieuNhaps.Find(maphieunhap).NgayLap));
            param[3] = new ReportParameter("TongTien", Convert.ToString(entities.PhieuNhaps.Find(maphieunhap).TongTien));
            this.reportViewer1.LocalReport.SetParameters(param);
            List <CTPN>      ctpn = GetList();
            ReportDataSource rds  = new ReportDataSource("DatasetPhieuNhap", ctpn);

            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(rds);
            this.reportViewer1.RefreshReport();
        }
Exemple #25
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            using (CuaHangDienTuEntities entities = new CuaHangDienTuEntities())
            {
                long         input_Id     = Convert.ToInt64(txtmanv.Text.Trim());
                NhanVien     nv           = entities.NhanViens.Where(p => p.MaNV == input_Id).FirstOrDefault();
                DialogResult dialogResult = MessageBox.Show("Bạn có chắc chăn thực hiện thao tác?", "Thông báo", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    if (nv == null)
                    {
                        entities.NhanViens.Add(new NhanVien
                        {
                            MaNV     = input_Id,
                            TenNV    = txttennv.Text,
                            ChucVu   = cbbChucVu.Text,
                            NgaySinh = dtpngaysinh.Value,
                            GioiTinh = cbbgioitinh.Text,
                            SDT      = txtsdt.Text
                        });

                        entities.SaveChanges();

                        Reset();
                    }
                    else
                    {
                        nv.TenNV    = txttennv.Text;
                        nv.ChucVu   = cbbChucVu.Text;
                        nv.NgaySinh = dtpngaysinh.Value;
                        nv.GioiTinh = cbbgioitinh.Text;

                        entities.SaveChanges();
                        Reset();
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    Reset();
                }
            }
            LoadDuLieu();
        }
Exemple #26
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn muốn xóa?", "Thông báo", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                using (CuaHangDienTuEntities db = new CuaHangDienTuEntities())
                {
                    int input_Id = int.Parse(txtmanv.Text.Trim());
                    db.NhanViens.Remove(db.NhanViens.Where(p => p.MaNV == input_Id).FirstOrDefault());
                    db.SaveChanges();
                    Reset();
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                Reset();
            }
            LoadDuLieu();
        }
Exemple #27
0
        private void btnlogin_Click(object sender, EventArgs e)
        {
            bool check = false;
            CuaHangDienTuEntities entities = new CuaHangDienTuEntities();
            List <User>           lst      = entities.Users.ToList();

            foreach (var u in lst)
            {
                if (Convert.ToString(u.TaiKhoan) == txtUsername.Text && u.MatKhau == txtPassword.Text)
                {
                    Form1 frm = new Form1(Convert.ToInt64(txtUsername.Text), u.NhanVien.TenNV, u.NhanVien.ChucVu);
                    frm.Show();
                    check = true;
                    UC_LapHoaDon lhd = new UC_LapHoaDon(Convert.ToInt64(txtUsername.Text));
                }
            }
            if (check == false)
            {
                MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng!");
            }
        }
        private void txtSDT_KeyDown(object sender, KeyEventArgs e)
        {
            bool dem = false;
            CuaHangDienTuEntities entities     = new CuaHangDienTuEntities();
            List <KhachHang>      lstKhachHang = entities.KhachHangs.ToList();

            if (e.KeyCode == Keys.Enter)
            {
                foreach (var kh in lstKhachHang)
                {
                    if (kh.SDT == Convert.ToInt64(txtSDT.Text))
                    {
                        txtTenKH.Text = kh.TenKH;
                        dem           = true;
                    }
                }
                if (dem == false)
                {
                    MessageBox.Show("Không tìm thấy khách hàng!");
                }
            }
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            using (CuaHangDienTuEntities entities = new CuaHangDienTuEntities())
            {
                long         input_Id     = Convert.ToInt64(txtmancc.Text.Trim());
                NhaCungCap   ncc          = entities.NhaCungCaps.Where(p => p.MaNCC == input_Id).FirstOrDefault();
                DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn thực hiện thao tác?", "Thông báo", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    if (ncc == null)
                    {
                        entities.NhaCungCaps.Add(new NhaCungCap
                        {
                            MaNCC  = input_Id,
                            TenNCC = txttenncc.Text,
                            DiaChi = txtdiachi.Text
                        });

                        entities.SaveChanges();

                        Reset();
                    }
                    else
                    {
                        ncc.TenNCC = txttenncc.Text;
                        ncc.DiaChi = txtdiachi.Text;


                        entities.SaveChanges();
                        Reset();
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    Reset();
                }
            }
            LoadDuLieu();
        }