public frmChiTietDonNhapHang(Form parent, string maphieuhang)
        {
            InitializeComponent();
            _parent = parent;
            var context      = new QLKHContext();
            var maphieuparam = new SqlParameter("@maphieunhanhang", maphieuhang);

            _phieunhaphang   = context.DanhsachNhapHangs.FromSqlRaw("getDonNhapHang @maphieunhanhang", maphieuparam).ToList().FirstOrDefault();
            txtMaPhieu.Text  = _phieunhaphang.MaPhieu;
            txtNgayTao.Text  = _phieunhaphang.NgayNhap.ToString();
            txtNhapTu.Text   = _phieunhaphang.NhapTu;
            txtTongTien.Text = _phieunhaphang.GiaTri.ToString();
            txtNguoiTao.Text = _phieunhaphang.NhanVienNhap;
            rtMoTa.Text      = _phieunhaphang.MoTa;

            dataGridMatHang.DataSource = context.DanhSachMatHangNhapKhos.Where(x => x.MaPhieu == maphieuhang).ToList();
            dataGridMatHang.Columns["MaPhieu"].Visible = false;
            dataGridHangHoa.DataSource = context.HangHoas.Where(x => x.MpNhapHang == maphieuhang).ToList();
            dataGridHangHoa.Columns["MaNvKiemKe"].Visible            = false;
            dataGridHangHoa.Columns["NgayKiemKe"].Visible            = false;
            dataGridHangHoa.Columns["MaMatHang"].Visible             = false;
            dataGridHangHoa.Columns["MpNhapHang"].Visible            = false;
            dataGridHangHoa.Columns["MpXuatHang"].Visible            = false;
            dataGridHangHoa.Columns["MaNvXuatKho"].Visible           = false;
            dataGridHangHoa.Columns["MaMatHangNavigation"].Visible   = false;
            dataGridHangHoa.Columns["MaNvNhapKhoNavigation"].Visible = false;
            dataGridHangHoa.Columns["MaNvXuatKhoNavigation"].Visible = false;
            dataGridHangHoa.Columns["MpNhapHangNavigation"].Visible  = false;
            dataGridHangHoa.Columns["MpXuatHangNavigation"].Visible  = false;
            dataGridHangHoa.Columns["TinhTrangs"].Visible            = false;
        }
Пример #2
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            var context = new QLKHContext();

            switch (e.ColumnIndex)
            {
            case 0:
                var paramMaMatHang = new SqlParameter("@mamathang", dataGridView1.Rows[e.RowIndex].Cells[0].Value);
                var temp           = context.MatHangs.FromSqlRaw("TimMatHangTheoMa @mamathang", paramMaMatHang).ToList();
                if (temp.Count > 0)
                {
                    var mathang = temp[0];
                    dataGridView1.Rows[e.RowIndex].Cells[1].Value = mathang.TenMatHang.ToString();
                    if (dataGridView1.Rows[e.RowIndex].Cells[2].Value != null)
                    {
                        dataGridView1.Rows[e.RowIndex].Cells[3].Value = mathang.GiaTri * int.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString());
                    }
                }
                break;

            case 2:

                break;
            }
        }
        public frmDanhSachMatHang(frmQuanLyManHinhChinh parent)
        {
            InitializeComponent();
            var context = new QLKHContext();

            dataGridView1.DataSource = context.MatHangs.ToList();
            _parent = parent;
        }
Пример #4
0
 private void txtSearch_TextChanged(object sender, EventArgs e)
 {
     using (var context = new QLKHContext())
     {
         var paramSearch = new SqlParameter("@searchtext", txtSearch.Text.Trim());
         dataGridView1.DataSource = context.DanhsachNhapHangs.FromSqlRaw("SearchDonNhanHang @searchtext", paramSearch).ToList();
     }
 }
Пример #5
0
        public frmQLNhapHang(frmQuanLyManHinhChinh parent)
        {
            _parent = parent;
            InitializeComponent();
            var context = new QLKHContext();

            dataGridView1.DataSource = context.DanhsachNhapHangs.ToList();
        }
Пример #6
0
 private void textBox1_TextChanged(object sender, EventArgs e)
 {
     using (var context = new QLKHContext())
     {
         var parasearch = new SqlParameter("@SearchText", txtSearch.Text.Trim());
         dataGridView1.DataSource = context.NV_PhieuXuatHangs.FromSqlRaw("SearchNhanVienXuatHang @SearchText", parasearch).ToList();
     }
 }
Пример #7
0
        public frmNvXuatHang(frmNhanVienManHinhChinh parent)
        {
            InitializeComponent();
            _parent = parent;
            var context = new QLKHContext();

            dataGridView1.DataSource = context.NV_PhieuXuatHangs.ToList();
        }
Пример #8
0
        public frmNvNhapHang(frmNhanVienManHinhChinh parent)
        {
            _parent = parent;
            InitializeComponent();
            var context = new  QLKHContext();

            dataGridView1.DataSource = context.NhanVienNhapHangs.ToList();
        }
Пример #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            var context       = new QLKHContext();
            var paramUserName = new SqlParameter("@username", txtUserName.Text.Trim());
            var paramPassword = new SqlParameter("@password", txtUserName.Text.Trim());
            var nv            = context.NhanViens.FromSqlRaw("Login @username, @password", paramUserName, paramPassword).ToList();

            if (nv.Count != 0)
            {
                Round.nhanVien    = nv[0];
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                Round.nhanVien = null;
                MessageBox.Show("Xin kiểm tra lại!", "Có lỗi");
                return;
            }
        }
Пример #10
0
        private void btnTao_Click(object sender, EventArgs e)
        {
            var context = new QLKHContext();
            List <SqlParameter> PhieuNhapHangParameters = new List <SqlParameter>();

            PhieuNhapHangParameters.Add(new SqlParameter("@maphieu", txtMaDonHang.Text));
            PhieuNhapHangParameters.Add(new SqlParameter("@NgayNhap", DateTime.Now.ToString("yyyy-MM-dd")));
            PhieuNhapHangParameters.Add(new SqlParameter("@mota", rtMoTa.Text));
            PhieuNhapHangParameters.Add(new SqlParameter("@nhanvien_nhap", Round.nhanVien.MaNhanVien));
            context.Database.ExecuteSqlRaw("ThemPhieuNhap @maphieu, @NgayNhap, @mota, @nhanvien_nhap", PhieuNhapHangParameters);
            foreach (DataGridViewRow item in dataGridView1.Rows)
            {
                if (item.Cells[0].Value != null)
                {
                    List <SqlParameter> hangnhapPara = new List <SqlParameter>();
                    hangnhapPara.Add(new SqlParameter("@soluong", item.Cells[2].Value));
                    hangnhapPara.Add(new SqlParameter("@mpnhap", txtMaDonHang.Text));
                    hangnhapPara.Add(new SqlParameter("@mahangnhap", item.Cells[0].Value));
                    context.Database.ExecuteSqlRaw("ThemHangNhap @soluong, @mpnhap, @mahangnhap", hangnhapPara);
                }
            }
            _parent.AddChild(new frmChiTietDonNhapHang(_parent, txtMaDonHang.Text));
        }