Ejemplo n.º 1
0
        // Xóa Nguyên liệu
        public void xoaNguyenLieu(string maNL)
        {
            QL_NguyenLieu xoaNL = ff.QL_NguyenLieus.Where(n => n.MaNL == maNL).FirstOrDefault();

            if (xoaNL != null)
            {
                ff.QL_NguyenLieus.DeleteOnSubmit(xoaNL);
                ff.SubmitChanges();
            }
        }
 private bool ktSLNL(QL_SanPham sp)
 {
     foreach (QL_NguyenLieu_SanPham item in qlsp.QL_NguyenLieu_SanPhams.Where(t => t.MaSP == sp.MaSP))
     {
         QL_NguyenLieu nl = qlsp.QL_NguyenLieus.SingleOrDefault(t => t.MaNL == item.MaNL);
         if (nl.SoLuong == 0)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 3
0
        // Thêm Nguyên liệu
        public void themNguyenLieu(string maNL, string tenNL, string donVi, int soLuong, DateTime hanSD, string maLoaiNL)
        {
            QL_NguyenLieu nl = new QL_NguyenLieu();

            nl.MaNL     = maNL;
            nl.TenNL    = tenNL;
            nl.DVT      = donVi;
            nl.SoLuong  = soLuong;
            nl.ThoiHan  = hanSD;
            nl.MaLoaiNL = maLoaiNL;
            ff.QL_NguyenLieus.InsertOnSubmit(nl);
            ff.SubmitChanges();
        }
Ejemplo n.º 4
0
        // Sửa nguyên liệu
        public void suaNguyenLieu(string maNL, string tenNL, string donVi, int soLuong, DateTime hanSD, string maLoaiNL)
        {
            QL_NguyenLieu suaNL = ff.QL_NguyenLieus.Where(n => n.MaNL == maNL).FirstOrDefault();

            if (suaNL != null)
            {
                suaNL.TenNL    = tenNL;
                suaNL.DVT      = donVi;
                suaNL.SoLuong  = soLuong;
                suaNL.ThoiHan  = hanSD;
                suaNL.MaLoaiNL = maLoaiNL;
                ff.SubmitChanges();
            }
        }
Ejemplo n.º 5
0
        private void btnThemNL_Click(object sender, EventArgs e)
        {
            if (gvNguyenLieu.SelectedRows == null)
            {
                MessageBox.Show("Chưa chọn nguyện liệu");
            }
            foreach (DataGridViewRow item in gvNguyenLieu.SelectedRows)
            {
                QL_NguyenLieu nl = lstNL.Single(t => t.MaNL == item.Cells["MaNL"].Value.ToString());
                lstNLHienTai.Add(nl);

                gvNL_SP.DataSource      = loadNL_SP();
                gvNguyenLieu.DataSource = lstNL_KoThuocSP();
            }
        }
Ejemplo n.º 6
0
        public List <QL_NguyenLieu> lstNLCuaSP()
        {
            List <QL_NguyenLieu> lst = new List <QL_NguyenLieu>();

            gvNL_SP.AllowUserToAddRows = false;
            if (gvNL_SP.Rows.Count == 0)
            {
                gvNL_SP.AllowUserToAddRows = true;
                return(lst);
            }
            foreach (DataGridViewRow item in gvNL_SP.Rows)
            {
                QL_NguyenLieu nl = lstNL.Single(t => t.MaNL == item.Cells["MaNL"].Value.ToString());
                lst.Add(nl);
            }
            return(lst);
        }
Ejemplo n.º 7
0
        public void xuatKho(DateTime from, DateTime to)
        {
            // so luong sp
            int slsp = 0;
            // so luong nguyen lieu de lam ra sp
            int slnl = 0;
            List <QL_HoaDon_BanHang> lstHD = layDSHDTheoNgay(from, to);

            foreach (QL_HoaDon_BanHang sp in lstHD)
            {
                if (sp.TinhTrang == true)
                {
                    continue;
                }
                else
                {
                    // lay tung san pham cua hoa don
                    foreach (QL_ChiTietHoaDon chitietHD in qlhd.QL_ChiTietHoaDons.Where(t => t.MaHD == sp.MaHD))
                    {
                        slsp = (int)chitietHD.Soluong;

                        // lay tung nguyen lieu cua san pham do
                        foreach (QL_NguyenLieu_SanPham nlsp in qlhd.QL_NguyenLieu_SanPhams.Where(t => t.MaSP == chitietHD.MaSP))
                        {
                            slnl = (int)nlsp.SoLuong;

                            QL_NguyenLieu nl = qlhd.QL_NguyenLieus.SingleOrDefault(t => t.MaNL == nlsp.MaNL);
                            nl.SoLuong -= slnl * slsp;
                            if (nl.SoLuong <= 0)
                            {
                                nl.SoLuong = 0;
                            }
                        }
                    }
                    sp.TinhTrang = true;
                }
                qlhd.SubmitChanges();
            }
        }