Exemplo n.º 1
0
        //nút thêm (sửa chi tiết phiếu nhập)
        private void button32_Click(object sender, EventArgs e)
        {
            TONKHO entity = new TONKHO();

            entity.MANHAPHANG = madonnhap;
            entity.MASP       = label53.Text;

            //xem sản phẩm có thuộc loại có hạn sử dụng không
            if (dateTimePicker3.Enabled == true)
            {
                entity.NGAYHETHAN = dateTimePicker3.Value.Date;
            }

            entity.SOLUONGNHAP = Convert.ToInt32(numericUpDown2.Value);
            entity.SOLUONGTON  = entity.SOLUONGNHAP;
            entity.DONGIANHAP  = common.ktdecimal(textBox10.Text);

            tonkhobus bus = new tonkhobus();

            common.successorerror(bus.add(entity));
            thongtindonnhap1dgv.DataSource = bus.findall(madonnhap);
            thongtindonnhap1dgv.Columns["PHIEUNHAPHANG"].Visible = false;
            thongtindonnhap1dgv.Columns["SANPHAM"].Visible       = false;
            thongtindonnhap1dgv.Columns["XUATKHOes"].Visible     = false;
        }
Exemplo n.º 2
0
 public static void ChuyenKhoTong(KaraokeEntities kara, TONKHO tonkho, int?khoDen, int soluong)
 {
     if (soluong <= tonkho.SoLuongTon)
     {
         tonkho.SoLuongTon -= soluong;
         TONKHO tonkhoDen = new TONKHO();
         tonkhoDen.KhoID              = khoDen;
         tonkhoDen.MonID              = tonkho.MonID;
         tonkhoDen.LoaiBanID          = tonkho.LoaiBanID;
         tonkhoDen.DonViID            = tonkho.DonViID;
         tonkhoDen.DonViTinh          = tonkho.DonViTinh;
         tonkhoDen.PhatSinhTuTonKhoID = tonkho.TonKhoID;
         tonkhoDen.SoLuongNhap        = soluong;
         tonkhoDen.SoLuongTon         = soluong;
         tonkhoDen.NgayNhap           = tonkho.NgayNhap;
         tonkhoDen.NgaySanXuat        = tonkho.NgaySanXuat;
         tonkhoDen.NgayHetHan         = tonkho.NgayHetHan;
         tonkhoDen.GiaBan             = tonkho.GiaBan;
         tonkhoDen.GiaNhap            = tonkho.GiaNhap;
         tonkhoDen.LoaiPhatSinhID     = 2;
         tonkhoDen.SoLuongPhatSinh    = soluong;
         tonkhoDen.Visual             = true;
         kara.TONKHOes.AddObject(tonkhoDen);
         kara.SaveChanges();
     }
 }
        //nhập tồn kho
        private void luutonkhobtn_Click(object sender, EventArgs e)
        {
            TONKHO entity = new TONKHO();

            entity.MANHAPHANG = madonnhap;
            entity.MASP       = masplbl.Text;

            //xem sản phẩm có thuộc loại có hạn sử dụng không
            if (ngayhethan.Enabled == true)
            {
                entity.NGAYHETHAN = ngayhethan.Value.Date;
            }

            entity.SOLUONGNHAP = Convert.ToInt32(soluongnhap.Value);
            entity.SOLUONGTON  = entity.SOLUONGNHAP;
            entity.DONGIANHAP  = common.ktdecimal(dongianhaptxt.Text);

            tonkhobus bus = new tonkhobus();

            common.successorerror(bus.add(entity));
            thongtindonnhapdgv.DataSource = bus.findall(madonnhap);

            thongtindonnhapdgv.Columns[0].HeaderText = "Số thứ tự";
            thongtindonnhapdgv.Columns[1].HeaderText = "Mã nhập hàng";
            thongtindonnhapdgv.Columns[2].HeaderText = "Mã sản phẩm";
            thongtindonnhapdgv.Columns[3].HeaderText = "Ngày hết hạn";
            thongtindonnhapdgv.Columns[4].HeaderText = "Số lượng nhập";
            thongtindonnhapdgv.Columns[5].HeaderText = "Số lượng tồn";
            thongtindonnhapdgv.Columns[6].HeaderText = "Đơn giá nhập";

            thongtindonnhapdgv.Columns["PHIEUNHAPHANG"].Visible = false;
            thongtindonnhapdgv.Columns["SANPHAM"].Visible       = false;
            thongtindonnhapdgv.Columns["XUATKHOes"].Visible     = false;
        }
 public void TonKho1Sach(int? MaSach, DateTime Ngay)
 {
     TONKHO tk = db.TONKHOes.Where(n => n.MaSach == MaSach && n.ThoiGian <= Ngay && n.SLTon != 0 && n.TangGiam != 0).OrderByDescending(n => n.ThoiGian).FirstOrDefault();
         list.Add(tk);
         ViewBag.TonKho = list;
         ViewBag.Ngay = Ngay.ToString("dd-MM-yyyy");
 }
Exemplo n.º 5
0
 public BOXuLyKhoChiTiet()
 {
     XuLyKhoChiTiet = new XULYKHOCHITIET();
     MenuMon        = new MENUMON();
     LoaiBan        = new LOAIBAN();
     TonKho         = new TONKHO();
     XuLyKho        = new XULYKHO();
 }
Exemplo n.º 6
0
 public BOChiTietChuyenKho()
 {
     ChiTietChuyenKho = new CHITIETCHUYENKHO();
     MenuMon          = new MENUMON();
     LoaiBan          = new LOAIBAN();
     TonKho           = new TONKHO();
     ChuyenKho        = new CHUYENKHO();
 }
Exemplo n.º 7
0
 public bool add(TONKHO entity)
 {
     if (validate(entity))
     {
         return(tonkhorepository.Add(entity));
     }
     return(false);
 }
Exemplo n.º 8
0
 public bool delete(TONKHO entity)
 {
     if (admin.phanquyen)
     {
         return(tonkhorepository.Delete(entity));
     }
     return(false);
 }
Exemplo n.º 9
0
        private static TONKHO LayBaoCao()
        {
            TONKHO tk = (from t in db.TONKHOes
                         orderby t.MaTonKho descending
                         select t).FirstOrDefault();

            return(tk);
        }
Exemplo n.º 10
0
        public void UpdateTonKhoNhap(string id, string maSP)
        {
            QLQuanAoDBContent db = new QLQuanAoDBContent();
            int    soluong       = new ModifierNhapKho().GetSoLuongByID(id);
            TONKHO tk            = db.TONKHOes.SingleOrDefault(x => x.maSanPham == maSP);

            tk.soLuong += soluong;
            db.SaveChanges();
        }
Exemplo n.º 11
0
        public void InsertTonKho(string maSP)
        {
            QLQuanAoDBContent db = new QLQuanAoDBContent();
            TONKHO            tk = new TONKHO();

            tk.maSanPham = maSP;
            tk.soLuong   = 0;
            db.TONKHOes.Add(tk);
            db.SaveChanges();
        }
Exemplo n.º 12
0
        public void Insert(string productID)
        {
            QuanLyDTDBContent db = new QuanLyDTDBContent();
            TONKHO            wh = new TONKHO();

            wh.maSanPham = productID;
            wh.soLuong   = 0;
            db.TONKHOes.Add(wh);
            db.SaveChanges();
        }
 public void TonKhoTatCa()
 {
     foreach (SACH s in db.SACHes)
         {
             TONKHO tk = db.TONKHOes.Where(n => n.MaSach == s.MaSach && n.ThoiGian <= Ngay && n.SLTon != 0 && n.TangGiam != 0).OrderByDescending(n => n.ThoiGian).FirstOrDefault();
             list.Add(tk);
         }
         ViewBag.TonKho = list;
         ViewBag.Ngay = Ngay.ToString("dd-MM-yyyy");
 }
Exemplo n.º 14
0
 public bool update(TONKHO entity)
 {
     if (entity.STT != 0)
     {
         if (validate(entity))
         {
             return(tonkhorepository.Attach(entity));
         }
     }
     return(false);
 }
Exemplo n.º 15
0
        public Boolean KiemTraSoLuongTon(SACH s, FormCollection f)
        {
            TONKHO tk = db.TONKHOes.Where(n => n.MaSach == s.MaSach && n.ThoiGian <= date && n.SLTon != 0 && n.TangGiam != 0).OrderByDescending(n => n.ThoiGian).FirstOrDefault();
            int    sl = int.Parse(f["SLXuat"].ToString());

            if (sl > tk.SLTon)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 16
0
        public static bool TimBaoCao(int thang, int nam)
        {
            TONKHO tk = (from t in db.TONKHOes
                         where t.NgayBatDau.Value.Month == thang && t.NgayBatDau.Value.Year == nam
                         select t).FirstOrDefault();

            if (tk == null)
            {
                return(false);
            }
            return(true);
        }
 public void insertSL(int idsp)
 {
     foreach (THONGTINKHO item in quanLyKho.THONGTINKHOs)
     {
         TONKHO tonkho = new TONKHO();
         tonkho.ID_KHO     = item.ID_KHO;
         tonkho.ID_SP      = idsp;
         tonkho.SOLUONGTON = 0;
         quanLyKho.TONKHOs.InsertOnSubmit(tonkho);
     }
     quanLyKho.SubmitChanges();
 }
Exemplo n.º 18
0
        public bool validate(TONKHO entity)
        {
            if (entity.DONGIANHAP <= 0)
            {
                validatedictionary.Add("DONGIANHAP", "Nhập sai đơn giá nhập");
            }
            if (validatedictionary.Count() <= 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 19
0
        public string UpdateTonKho(string ma, int sl)
        {
            string            temp;
            QLQuanAoDBContent db = new QLQuanAoDBContent();
            TONKHO            tk = db.TONKHOes.SingleOrDefault(x => x.maSanPham == ma);

            tk.soLuong = tk.soLuong + sl;

            db.SaveChanges();
            temp = "true";

            return(temp);
        }
Exemplo n.º 20
0
 public static int them(TONKHO tk)
 {
     try
     {
         DAO.QLTONK.them(tk);
         return(1);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(0);
     }
 }
Exemplo n.º 21
0
        public List <TONKHO> tonkho(DateTime?date)
        {
            List <TONKHO> all = db.TONKHOes.ToList();
            //List<int?> masach = db.Database.SqlQuery<int?>("splaymasachtrongtokho").ToList();
            List <int?> masach = (from a in all
                                  select a.MASACH).Distinct().OrderBy(a => a).ToList();
            List <TONKHO> thongke = new List <TONKHO>();

            foreach (var item in masach)
            {
                List <TONKHO> tonkhotheomasach   = all.Where(m => m.MASACH.Equals(item)).ToList();
                List <TONKHO> sachtonkhotheongay = tonkhotheomasach.Where(t => t.NGAYCAPNHAT.Equals(date)).ToList();
                int           rowcout            = sachtonkhotheongay.Count;
                if (rowcout > 1)
                {
                    thongke.Add(sachtonkhotheongay.ElementAt(sachtonkhotheongay.Count - 1));
                }
                else if (rowcout == 1)
                {
                    TONKHO tk = new TONKHO();
                    tk = sachtonkhotheongay.SingleOrDefault();
                    thongke.Add(tk);
                }
                else if (rowcout == 0)
                {
                    int count = tonkhotheomasach.Count;
                    if ((tonkhotheomasach.ElementAt(0).NGAYCAPNHAT) > date)
                    {
                        continue;
                    }
                    else if (date > tonkhotheomasach.ElementAt(count - 1).NGAYCAPNHAT)
                    {
                        thongke.Add(tonkhotheomasach.ElementAt(count - 1));
                    }

                    else
                    {
                        for (int i = count - 1; i >= 1; i--)
                        {
                            if (tonkhotheomasach.ElementAt(i).NGAYCAPNHAT > date && tonkhotheomasach.ElementAt(i - 1).NGAYCAPNHAT < date)
                            {
                                thongke.Add(tonkhotheomasach.ElementAt(i - 1));
                            }
                        }
                    }
                }
            }
            return(thongke);
        }
 public bool updateSL(int idkho, int idsl, int sl)
 {
     try
     {
         TONKHO tonkho = quanLyKho.TONKHOs.SingleOrDefault(n => n.ID_KHO == idkho && n.ID_SP == idsl);
         if (tonkho != null)
         {
             tonkho.SOLUONGTON = tonkho.SOLUONGTON + sl;
             quanLyKho.SubmitChanges();
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 23
0
        //xóa (sửa chi tiết phiếu)
        private void xoachitietphieu(object sender, EventArgs args)
        {
            TONKHO    entity = new TONKHO();
            tonkhobus bus    = new tonkhobus();

            entity.STT = Int32.Parse(thongtindonnhap1dgv.SelectedCells[0].Value.ToString());
            bool delete = bus.delete(entity);

            common.successorerror(delete);
            if (delete)
            {
                thongtindonnhap1dgv.DataSource = bus.list();
            }
            else
            {
            }
        }
Exemplo n.º 24
0
        public static void NhapKhoTong(KaraokeEntities kara, BOChiTietNhapKho chitiet, BONhapKho nhapkho)
        {
            int    soluongNhap = chitiet.ChiTietNhapKho.SoLuongNhap * chitiet.MenuKichThuocMon.KichThuocLoaiBan;
            TONKHO tonkho      = new TONKHO();

            tonkho.KhoID          = nhapkho.NhapKho.KhoID;
            tonkho.MonID          = chitiet.MenuKichThuocMon.MenuKichThuocMon.MonID;
            tonkho.SoLuongNhap    = soluongNhap;
            tonkho.SoLuongTon     = soluongNhap;
            tonkho.NgayNhap       = DateTime.Now;
            tonkho.NgaySanXuat    = chitiet.ChiTietNhapKho.NgaySanXuat;
            tonkho.NgayHetHan     = chitiet.ChiTietNhapKho.NgayHetHan;
            tonkho.GiaNhap        = chitiet.ChiTietNhapKho.GiaNhap;
            tonkho.GiaBan         = chitiet.ChiTietNhapKho.GiaBan;
            tonkho.LoaiPhatSinhID = 1;
            tonkho.Visual         = true;
            kara.TONKHOes.AddObject(tonkho);
        }
Exemplo n.º 25
0
 private void CopyTonKho(TONKHO a, TONKHO b)
 {
     a.MonID           = b.MonID;
     a.NgayHetHan      = b.NgayHetHan;
     a.NgaySanXuat     = b.NgaySanXuat;
     a.SoLuongNhap     = 0;
     a.SoLuongPhatSinh = 0;
     a.SoLuongTon      = 0;
     a.DonViID         = b.DonViID;
     a.DonViTinh       = b.DonViTinh;
     a.KhoID           = b.KhoID;
     a.GiaBan          = b.GiaBan;
     a.GiaNhap         = b.GiaNhap;
     a.LoaiBanID       = b.LoaiBanID;
     a.Visual          = true;
     a.Deleted         = false;
     a.Edit            = false;
 }
Exemplo n.º 26
0
 public bool update(XUATKHO entity, int soluongxuathientai)
 {
     if (validate(entity))
     {
         TONKHO tk1 = new TONKHO();
         tk1 = tonkhorepository.Find(c => c.STT == entity.MATONKHO).FirstOrDefault();
         int?slton = tk1.SOLUONGTON;
         slton          = slton - Convert.ToInt32(entity.SOLUONGXUAT);
         tk1.SOLUONGTON = slton;
         if (!tonkhorepository.Update(tk1))
         {
             return(false);
         }
         entity.SOLUONGXUAT += soluongxuathientai;
         return(xuatkhorepository.Attach(entity));
     }
     return(false);
 }
Exemplo n.º 27
0
        public string UpdateXuatTonKho(string ma, int sl)
        {
            string            temp;
            QuanLyDTDBContent db = new QuanLyDTDBContent();
            TONKHO            tk = db.TONKHOes.SingleOrDefault(x => x.maSanPham == ma);

            if (tk.soLuong >= sl)
            {
                tk.soLuong = tk.soLuong - sl;

                db.SaveChanges();
                temp = "true";

                return(temp);
            }
            else
            {
                return("false");
            }
        }
Exemplo n.º 28
0
 public bool delete(XUATKHO entity)
 {
     if (admin.phanquyen)
     {
         TONKHO tk1 = new TONKHO();
         tk1 = tonkhorepository.Find(c => c.STT == entity.MATONKHO).FirstOrDefault();
         int?slton = tk1.SOLUONGTON;
         slton          = slton + Convert.ToInt32(entity.SOLUONGXUAT);
         tk1.SOLUONGTON = slton;
         if (!tonkhorepository.Update(tk1))
         {
             return(false);
         }
         return(xuatkhorepository.Delete(entity));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 29
0
        //nút sửa (sửa chi tiết phiếu nhập)
        private void button29_Click(object sender, EventArgs e)
        {
            button29.Enabled = false;
            TONKHO    entity = new TONKHO();
            tonkhobus bus    = new tonkhobus();

            entity.STT        = Int32.Parse(lblmatonkho.Text);
            entity.MANHAPHANG = madonnhap;
            entity.MASP       = label53.Text;
            if (dateTimePicker3.Enabled == false)
            {
            }
            else
            {
                entity.NGAYHETHAN = dateTimePicker3.Value.Date;
            }
            entity.SOLUONGNHAP = (int)numericUpDown2.Value;
            entity.DONGIANHAP  = common.ktdecimal(textBox10.Text);
            entity.SOLUONGTON  = entity.SOLUONGNHAP - Int32.Parse(lblslxuat.Text);
            bool update = bus.update(entity);

            common.successorerror(update);
            if (update)
            {
                thongtindonnhap1dgv.DataSource = bus.findall(madonnhap);
                thongtindonnhap1dgv.Columns["PHIEUNHAPHANG"].Visible = false;
                thongtindonnhap1dgv.Columns["SANPHAM"].Visible       = false;
                thongtindonnhap1dgv.Columns["XUATKHOes"].Visible     = false;
                label53.Text         = "Mã sản phẩm";
                numericUpDown2.Value = 0;
                textBox10.Clear();
                dateTimePicker3.ResetText();
                lblmatonkho.Text = "0";
            }
            else
            {
            }
        }
Exemplo n.º 30
0
        public bool insert_CTPX(int idkho, int idpx, int idsp, int soluong, int gianhap, int thanhtien)
        {
            try
            {
                CHITIETPHIEUXUAT insert = new CHITIETPHIEUXUAT();
                TONKHO           tonkho = quanLyKho.TONKHOs.SingleOrDefault(n => n.ID_KHO == idkho && n.ID_SP == idsp);
                insert.ID_PX     = idpx;
                insert.ID_SP     = idsp;
                insert.SOLUONG   = soluong;
                insert.DONGIA    = (float)gianhap;
                insert.THANHTIEN = (float)thanhtien;
                quanLyKho.CHITIETPHIEUXUATs.InsertOnSubmit(insert);
                tonkho.SOLUONGTON = tonkho.SOLUONGTON - soluong;
                quanLyKho.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }