コード例 #1
0
 private void rdbtatca_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbtatca.Checked)
     {
         if (hienthi != null)
         {
             ///////////////////////////////MRK FIX
             List <Entities.BCNhapHangTheoMatHang> tem0 = new List <Entities.BCNhapHangTheoMatHang>();
             int tong0 = 0;
             foreach (Entities.BCNhapHangTheoMatHang item in hienthi)
             {
                 tong0 += item.SoLuong;
                 tem0.Add(item);
             }
             Entities.BCNhapHangTheoMatHang tem1 = new Entities.BCNhapHangTheoMatHang();
             tem1.TenHangHoa = "Tổng: ";
             tem1.SoLuong    = tong0;
             tem0.Add(tem1);
             //////////////////////////////////////
             //dtgvhienthi.DataSource = hienthi;
             dtgvhienthi.DataSource = tem0.ToArray();
         }
         else
         {
             dtgvhienthi.DataSource = new Entities.BCNhapHangTheoMatHang[0];
         }
         dtgvhienthi.Refresh();
         fix();
     }
 }
コード例 #2
0
        private void txttimkiem_TextChanged(object sender, EventArgs e)
        {
            if (rdbtatca.Checked || hienthi == null)
            {
                return;
            }
            else if (hienthi.Length == 0)
            {
                return;
            }
            if (txttimkiem.Text.Equals(""))
            {
                dtgvhienthi.DataSource = new Entities.BCNhapHangTheoMatHang[0];
                return;
            }
            ArrayList arr = new ArrayList();

            if (rdbtheomaHH.Checked)
            {
                foreach (Entities.BCNhapHangTheoMatHang item in hienthi)
                {
                    if (item.MaHangHoa.ToLower().IndexOf(txttimkiem.Text.ToLower()) > -1)
                    {
                        arr.Add(item);
                    }
                }
            }
            else if (rdbtheotenHH.Checked)
            {
                foreach (Entities.BCNhapHangTheoMatHang item in hienthi)
                {
                    if (item.TenHangHoa.ToLower().IndexOf(txttimkiem.Text.ToLower()) > -1)
                    {
                        arr.Add(item);
                    }
                }
            }
            if (arr.Count > 0)
            {
                Entities.BCNhapHangTheoMatHang[] temp = new Entities.BCNhapHangTheoMatHang[arr.Count];
                for (int i = 0; i < temp.Length; i++)
                {
                    temp[i]          = (Entities.BCNhapHangTheoMatHang)arr[i];
                    temp[i].HanhDong = i + 1;
                }
                ///////////////////////////////MRK FIX
                List <Entities.BCNhapHangTheoMatHang> tem0 = new List <Entities.BCNhapHangTheoMatHang>();
                int tong0 = 0;
                foreach (Entities.BCNhapHangTheoMatHang item in temp)
                {
                    tong0 += item.SoLuong;
                    tem0.Add(item);
                }
                Entities.BCNhapHangTheoMatHang tem1 = new Entities.BCNhapHangTheoMatHang();
                tem1.TenHangHoa = "Tổng: ";
                tem1.SoLuong    = tong0;
                tem0.Add(tem1);
                //////////////////////////////////////
                //dtgvhienthi.DataSource = temp;
                dtgvhienthi.DataSource = tem0.ToArray();
            }
            else
            {
                dtgvhienthi.DataSource = new Entities.BCNhapHangTheoMatHang[0];
            }
        }
コード例 #3
0
        public void NhapHangTheoMatHang()
        {
            ArrayList arr        = new ArrayList();
            ArrayList arrChiTiet = new ArrayList();
            int       i          = 1;

            foreach (Entities.HangHoa item in hanghoa)
            {
                int sl = 0;
                foreach (Entities.HoaDonNhap item1 in hoadonnhap)
                {
                    int laynam   = item1.NgayNhap.Year;
                    int laythang = item1.NgayNhap.Month;
                    foreach (Entities.ChiTietHoaDonNhap item2 in chitiethoadonnhap)
                    {
                        if (item1.MaHoaDonNhap == item2.MaHoaDonNhap && nam == laynam && thang == laythang)
                        {
                            if (item.MaHangHoa == item2.MaHangHoa)
                            {
                                sl += item2.SoLuong;
                                arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item2.MaHangHoa, item.TenHangHoa, item2.SoLuong, item2.MaHoaDonNhap, item1.NgayNhap.ToString("dd/MM/yyyy")));
                            }
                        }
                    }
                }

                foreach (Entities.KhachHangTraLai item1 in khachhangtralai)
                {
                    int laynam   = item1.NgayNhap.Year;
                    int laythang = item1.NgayNhap.Month;
                    foreach (Entities.ChiTietKhachHangTraLai item2 in chitietkhachhangtralai)
                    {
                        if (item1.MaKhachHangTraLai == item2.MaKhachHangTraLai && nam == laynam && thang == laythang)
                        {
                            if (item.MaHangHoa == item2.MaHangHoa)
                            {
                                sl += item2.SoLuong;
                                arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item2.MaHangHoa, item.TenHangHoa, item2.SoLuong, item2.MaKhachHangTraLai, item1.NgayNhap.ToString("dd/MM/yyyy")));
                            }
                            ////////////////////////////////////////////////MRK FIX
                            else
                            { //là gói hàng
                                foreach (Entities.GoiHang gh in goihang)
                                {
                                    foreach (Entities.ChiTietGoiHang ctgh in chitietgoihang)
                                    {
                                        if (gh.MaGoiHang.Equals(ctgh.MaGoiHang) && ctgh.MaGoiHang.Equals(item2.MaHangHoa) && ctgh.MaHangHoa.Equals(item.MaHangHoa))
                                        {
                                            sl += item2.SoLuong * ctgh.SoLuong;
                                            arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item.MaHangHoa + " (" + item2.MaHangHoa + ")", item.TenHangHoa, item2.SoLuong * ctgh.SoLuong, item2.MaKhachHangTraLai, item1.NgayNhap.ToString("dd/MM/yyyy")));
                                        }
                                    }
                                }
                            }
                            ////////////////////////////////////////////////MRK FIX
                        }
                    }
                }
                foreach (Entities.PhieuDieuChuyenKhoNoiBo item1 in phieudieuchuyenkhonoibo)
                {
                    int laynam   = item1.NgayDieuChuyen.Year;
                    int laythang = item1.NgayDieuChuyen.Month;
                    foreach (Entities.ChiTietPhieuDieuChuyenKho item2 in chitietphieudieuchuyenkho)
                    {
                        if (item1.MaPhieuDieuChuyenKho == item2.MaPhieuDieuChuyenKho && nam == laynam && thang == laythang && item1.TenKhoDen.Equals(item.MaKho))
                        {
                            if (item.MaHangHoa == item2.MaHangHoa)
                            {
                                sl += item2.SoLuong;
                                arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item2.MaHangHoa, item.TenHangHoa, item2.SoLuong, item2.MaPhieuDieuChuyenKho, item1.NgayDieuChuyen.ToString("dd/MM/yyyy")));
                            }
                            ////////////////////////////////////////////////MRK FIX
                            else
                            { //là gói hàng
                                foreach (Entities.GoiHang gh in goihang)
                                {
                                    foreach (Entities.ChiTietGoiHang ctgh in chitietgoihang)
                                    {
                                        if (gh.MaGoiHang.Equals(ctgh.MaGoiHang) && ctgh.MaGoiHang.Equals(item2.MaHangHoa) && ctgh.MaHangHoa.Equals(item.MaHangHoa))
                                        {
                                            sl += item2.SoLuong * ctgh.SoLuong;
                                            arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item.MaHangHoa + " (" + item2.MaHangHoa + ")", item.TenHangHoa, item2.SoLuong * ctgh.SoLuong, item2.MaPhieuDieuChuyenKho, item1.NgayDieuChuyen.ToString("dd/MM/yyyy")));
                                        }
                                    }
                                }
                            }
                            ////////////////////////////////////////////////MRK FIX
                        }
                    }
                }
                if (sl > 0)
                {
                    arr.Add(new Entities.BCNhapHangTheoMatHang(i, item.MaHangHoa, item.TenHangHoa, sl));
                }
                i++;
            }
            hienthi       = (Entities.BCNhapHangTheoMatHang[])arr.ToArray(typeof(Entities.BCNhapHangTheoMatHang));
            hienthibaocao = (Entities.ChiTietBCNhapHangTheoMatHang[])arrChiTiet.ToArray(typeof(Entities.ChiTietBCNhapHangTheoMatHang));
            ///////////////////////////////MRK FIX
            List <Entities.BCNhapHangTheoMatHang> tem0 = new List <Entities.BCNhapHangTheoMatHang>();
            int tong0 = 0;

            foreach (Entities.BCNhapHangTheoMatHang item in hienthi)
            {
                if (item == null)
                {
                    continue;
                }
                tong0 += item.SoLuong;
                tem0.Add(item);
            }
            Entities.BCNhapHangTheoMatHang tem1 = new Entities.BCNhapHangTheoMatHang();
            tem1.TenHangHoa = "Tổng: ";
            tem1.SoLuong    = tong0;
            tem0.Add(tem1);
            //////////////////////////////////////
            //dtgvhienthi.DataSource = hienthi;
            dtgvhienthi.DataSource = tem0.ToArray();

            if (hienthi.Length > 0)
            {
                enable();
            }
            else
            {
                disable();
            }
            fix();
        }
コード例 #4
0
        private void txttimkiem_TextChanged(object sender, EventArgs e)
        {
            if (rdbtatca.Checked || hienthi == null)
                return;
            else if (hienthi.Length == 0)
                return;
            if (txttimkiem.Text.Equals(""))
            {
                dtgvhienthi.DataSource = new Entities.BCNhapHangTheoMatHang[0];
                return;
            }
            ArrayList arr = new ArrayList();
            if (rdbtheomaHH.Checked)
            {
                foreach (Entities.BCNhapHangTheoMatHang item in hienthi)
                {
                    if (item.MaHangHoa.ToLower().IndexOf(txttimkiem.Text.ToLower()) > -1)
                    {
                        arr.Add(item);
                    }
                }
            }
            else if (rdbtheotenHH.Checked)
            {
                foreach (Entities.BCNhapHangTheoMatHang item in hienthi)
                {
                    if (item.TenHangHoa.ToLower().IndexOf(txttimkiem.Text.ToLower()) > -1)
                    {
                        arr.Add(item);
                    }
                }
            }
            if (arr.Count > 0)
            {
                Entities.BCNhapHangTheoMatHang[] temp = new Entities.BCNhapHangTheoMatHang[arr.Count];
                for (int i = 0; i < temp.Length; i++)
                {
                    temp[i] = (Entities.BCNhapHangTheoMatHang)arr[i];
                    temp[i].HanhDong = i + 1;
                }
                ///////////////////////////////MRK FIX
                List<Entities.BCNhapHangTheoMatHang> tem0 = new List<Entities.BCNhapHangTheoMatHang>();
                int tong0 = 0;
                foreach (Entities.BCNhapHangTheoMatHang item in temp)
                {
                    tong0 += item.SoLuong;
                    tem0.Add(item);
                }
                Entities.BCNhapHangTheoMatHang tem1 = new Entities.BCNhapHangTheoMatHang();
                tem1.TenHangHoa = "Tổng: ";
                tem1.SoLuong = tong0;
                tem0.Add(tem1);
                //////////////////////////////////////
                //dtgvhienthi.DataSource = temp;
                dtgvhienthi.DataSource = tem0.ToArray();

            }
            else
            {
                dtgvhienthi.DataSource = new Entities.BCNhapHangTheoMatHang[0];
            }
        }
コード例 #5
0
 private void rdbtatca_CheckedChanged(object sender, EventArgs e)
 {
     if (rdbtatca.Checked)
     {
         if (hienthi != null)
         {
             ///////////////////////////////MRK FIX
             List<Entities.BCNhapHangTheoMatHang> tem0 = new List<Entities.BCNhapHangTheoMatHang>();
             int tong0 = 0;
             foreach (Entities.BCNhapHangTheoMatHang item in hienthi)
             {
                 tong0 += item.SoLuong;
                 tem0.Add(item);
             }
             Entities.BCNhapHangTheoMatHang tem1 = new Entities.BCNhapHangTheoMatHang();
             tem1.TenHangHoa = "Tổng: ";
             tem1.SoLuong = tong0;
             tem0.Add(tem1);
             //////////////////////////////////////
             //dtgvhienthi.DataSource = hienthi;
             dtgvhienthi.DataSource = tem0.ToArray();
         }
         else
         {
             dtgvhienthi.DataSource = new Entities.BCNhapHangTheoMatHang[0];
         }
         dtgvhienthi.Refresh();
         fix();
     }
 }
コード例 #6
0
        public void NhapHangTheoMatHang()
        {
            ArrayList arr = new ArrayList();
            ArrayList arrChiTiet = new ArrayList();
            int i = 1;
            foreach (Entities.HangHoa item in hanghoa)
            {
                int sl = 0;
                foreach (Entities.HoaDonNhap item1 in hoadonnhap)
                {
                    int laynam = item1.NgayNhap.Year;
                    int laythang = item1.NgayNhap.Month;
                    foreach (Entities.ChiTietHoaDonNhap item2 in chitiethoadonnhap)
                    {
                        if (item1.MaHoaDonNhap == item2.MaHoaDonNhap && nam == laynam && thang == laythang)
                        {
                            if (item.MaHangHoa == item2.MaHangHoa)
                            {
                                sl += item2.SoLuong;
                                arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item2.MaHangHoa, item.TenHangHoa, item2.SoLuong, item2.MaHoaDonNhap, item1.NgayNhap.ToString("dd/MM/yyyy")));
                            }
                        }
                    }
                }

                foreach (Entities.KhachHangTraLai item1 in khachhangtralai)
                {
                    int laynam = item1.NgayNhap.Year;
                    int laythang = item1.NgayNhap.Month;
                    foreach (Entities.ChiTietKhachHangTraLai item2 in chitietkhachhangtralai)
                    {
                        if (item1.MaKhachHangTraLai == item2.MaKhachHangTraLai && nam == laynam && thang == laythang)
                        {
                            if (item.MaHangHoa == item2.MaHangHoa)
                            {
                                sl += item2.SoLuong;
                                arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item2.MaHangHoa, item.TenHangHoa, item2.SoLuong, item2.MaKhachHangTraLai, item1.NgayNhap.ToString("dd/MM/yyyy")));
                            }
                            ////////////////////////////////////////////////MRK FIX
                            else
                            { //là gói hàng
                                foreach (Entities.GoiHang gh in goihang)
                                {
                                    foreach (Entities.ChiTietGoiHang ctgh in chitietgoihang)
                                    {
                                        if (gh.MaGoiHang.Equals(ctgh.MaGoiHang) && ctgh.MaGoiHang.Equals(item2.MaHangHoa) && ctgh.MaHangHoa.Equals(item.MaHangHoa))
                                        {
                                            sl += item2.SoLuong * ctgh.SoLuong;
                                            arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item.MaHangHoa + " (" + item2.MaHangHoa + ")", item.TenHangHoa, item2.SoLuong * ctgh.SoLuong, item2.MaKhachHangTraLai, item1.NgayNhap.ToString("dd/MM/yyyy")));
                                        }
                                    }
                                }
                            }
                            ////////////////////////////////////////////////MRK FIX
                        }
                    }
                }
                foreach (Entities.PhieuDieuChuyenKhoNoiBo item1 in phieudieuchuyenkhonoibo)
                {
                    int laynam = item1.NgayDieuChuyen.Year;
                    int laythang = item1.NgayDieuChuyen.Month;
                    foreach (Entities.ChiTietPhieuDieuChuyenKho item2 in chitietphieudieuchuyenkho)
                    {
                        if (item1.MaPhieuDieuChuyenKho == item2.MaPhieuDieuChuyenKho && nam == laynam && thang == laythang && item1.TenKhoDen.Equals(item.MaKho))
                        {
                            if (item.MaHangHoa == item2.MaHangHoa)
                            {
                                sl += item2.SoLuong;
                                arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item2.MaHangHoa, item.TenHangHoa, item2.SoLuong, item2.MaPhieuDieuChuyenKho, item1.NgayDieuChuyen.ToString("dd/MM/yyyy")));
                            }
                            ////////////////////////////////////////////////MRK FIX
                            else
                            { //là gói hàng
                                foreach (Entities.GoiHang gh in goihang)
                                {
                                    foreach (Entities.ChiTietGoiHang ctgh in chitietgoihang)
                                    {
                                        if (gh.MaGoiHang.Equals(ctgh.MaGoiHang) && ctgh.MaGoiHang.Equals(item2.MaHangHoa) && ctgh.MaHangHoa.Equals(item.MaHangHoa))
                                        {
                                            sl += item2.SoLuong * ctgh.SoLuong;
                                            arrChiTiet.Add(new Entities.ChiTietBCNhapHangTheoMatHang(item.MaHangHoa + " (" + item2.MaHangHoa + ")", item.TenHangHoa, item2.SoLuong * ctgh.SoLuong, item2.MaPhieuDieuChuyenKho, item1.NgayDieuChuyen.ToString("dd/MM/yyyy")));
                                        }
                                    }
                                }
                            }
                            ////////////////////////////////////////////////MRK FIX
                        }
                    }
                }
                if (sl > 0)
                    arr.Add(new Entities.BCNhapHangTheoMatHang(i, item.MaHangHoa, item.TenHangHoa, sl));
                i++;
            }
            hienthi = (Entities.BCNhapHangTheoMatHang[])arr.ToArray(typeof(Entities.BCNhapHangTheoMatHang));
            hienthibaocao = (Entities.ChiTietBCNhapHangTheoMatHang[])arrChiTiet.ToArray(typeof(Entities.ChiTietBCNhapHangTheoMatHang));
            ///////////////////////////////MRK FIX
            List<Entities.BCNhapHangTheoMatHang> tem0 = new List<Entities.BCNhapHangTheoMatHang>();
            int tong0 = 0;
            foreach (Entities.BCNhapHangTheoMatHang item in hienthi)
            {
                if (item == null)
                {
                    continue;
                }
                tong0 += item.SoLuong;
                tem0.Add(item);
            }
            Entities.BCNhapHangTheoMatHang tem1 = new Entities.BCNhapHangTheoMatHang();
            tem1.TenHangHoa = "Tổng: ";
            tem1.SoLuong = tong0;
            tem0.Add(tem1);
            //////////////////////////////////////
            //dtgvhienthi.DataSource = hienthi;
            dtgvhienthi.DataSource = tem0.ToArray();

            if (hienthi.Length > 0)
            {
                enable();
            }
            else
            {
                disable();
            }
            fix();
        }