Exemplo n.º 1
0
        public void xoa()
        {
            Console.Clear();
            Console.WriteLine("XOA THONG TIN HOA DON BAN ");
            List <hoadonban> list = spDLL.GetAllhoadonban();
            string           ma;

            Console.Write("Nhap ma hoa don ban can xoa:");
            ma = Console.ReadLine();
            int i = 0;

            for (i = 0; i < list.Count; ++i)
            {
                if (list[i].Mahdb == ma)
                {
                    break;
                }
            }

            if (i < list.Count)
            {
                hoadonban b = new hoadonban(list[i]);
                spDLL.xoahoadonban(b);
            }
            else
            {
                Console.WriteLine("Khong ton tai ma san pham nay");
            }
        }
Exemplo n.º 2
0
        public List <hoadonban> timhoadonban(hoadonban hdb)
        {
            List <hoadonban> list = lhhdb.GetAllhoadonban();
            List <hoadonban> kq   = new List <hoadonban>();

            //Voi gai tri ngam dinh ban dau
            if (hdb.Mahdb == null && hdb.Giaban == 0 && hdb.Ngayban == null)
            {
                kq = list;
            }
            //Tim theo
            else if (hdb.Mahdb != "")
            {
                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i].Mahdb.IndexOf(hdb.Mahdb) >= 0)
                    {
                        kq.Add(new hoadonban(list[i]));
                    }
                }
            }


            else
            {
                kq = null;
            }
            return(kq);
        }
Exemplo n.º 3
0
        public ActionResult DeleteConfirmed(long id)
        {
            hoadonban hoadonban = db.hoadonbans.Find(id);

            db.hoadonbans.Remove(hoadonban);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        //Chèn một bản ghi hóa đơn bán vào tệp
        public void themhoadonban(hoadonban hd)
        {
            string       mahdb  = DateTime.Now.ToString("tt");
            StreamWriter fwrite = File.AppendText(txtfile);

            fwrite.WriteLine();
            fwrite.Write(mahdb + "#" + hd.Giaban + "#" + hd.Ngayban);
            fwrite.Close();
        }
Exemplo n.º 5
0
        public void Nhap()
        {
            Console.Clear();
            Console.WriteLine("           NHAP THONG TIN HOA DON BAN   ");
            hoadonban sp = new hoadonban();

            Console.Write("Nhap gia ban :"); sp.Giaban   = double.Parse(Console.ReadLine());
            Console.Write(" Nhap ngay ban:"); sp.Ngayban = DateTime.Parse(Console.ReadLine());

            spDLL.themhoadonban(sp);
        }
Exemplo n.º 6
0
 public void themhoadonban(hoadonban hdb)
 {
     if (hdb.Giaban > 0)
     {
         lhhdb.themhoadonban(hdb);
     }
     else
     {
         throw new Exception("Du lieu sai");
     }
 }
Exemplo n.º 7
0
        // GET: hoadonbans/Delete/5
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            hoadonban hoadonban = db.hoadonbans.Find(id);

            if (hoadonban == null)
            {
                return(HttpNotFound());
            }
            return(View(hoadonban));
        }
Exemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "hoadonban_id,ngaytao,ngayhoanthanh,noigui,soluong,hoadonban_id,merchant_id,hinhthucthanhtoan_id,tinhtranggiaohang_id,hoadonmua_id")] hoadonban hoadonban)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hoadonban).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.hinhthucthanhtoan_id = new SelectList(db.hinhthucthanhtoans, "hinhthucthanhtoan_id", "tenhinhthucthanhtoan", hoadonban.hinhthucthanhtoan_id);
     ViewBag.hoadonban_id         = new SelectList(db.hoadonbans, "hoadonban_id", "tenhoadonban", hoadonban.hoadonban_id);
     ViewBag.merchant_id          = new SelectList(db.merchants, "merchant_id", "cmnd", hoadonban.merchant_id);
     ViewBag.tinhtranggiaohang_id = new SelectList(db.tinhtranggiaohangs, "tinhtranggiaohang_id", "tentinhtranggiaohang", hoadonban.tinhtranggiaohang_id);
     ViewBag.hoadonmua_id         = new SelectList(db.hoadonmuas, "hoadonmua_id", "noinhan", hoadonban.hoadonmua_id);
     return(View(hoadonban));
 }
Exemplo n.º 9
0
        // GET: hoadonbans/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            hoadonban hoadonban = db.hoadonbans.Find(id);

            if (hoadonban == null)
            {
                return(HttpNotFound());
            }
            ViewBag.hinhthucthanhtoan_id = new SelectList(db.hinhthucthanhtoans, "hinhthucthanhtoan_id", "tenhinhthucthanhtoan", hoadonban.hinhthucthanhtoan_id);
            ViewBag.hoadonban_id         = new SelectList(db.hoadonbans, "hoadonban_id", "tenhoadonban", hoadonban.hoadonban_id);
            ViewBag.merchant_id          = new SelectList(db.merchants, "merchant_id", "cmnd", hoadonban.merchant_id);
            ViewBag.tinhtranggiaohang_id = new SelectList(db.tinhtranggiaohangs, "tinhtranggiaohang_id", "tentinhtranggiaohang", hoadonban.tinhtranggiaohang_id);
            ViewBag.hoadonmua_id         = new SelectList(db.hoadonmuas, "hoadonmua_id", "noinhan", hoadonban.hoadonmua_id);
            return(View(hoadonban));
        }
Exemplo n.º 10
0
        public void Hientimkiem(hoadonban hdb)
        {
            int i;
            List <hoadonban> list = lhhdb.GetAllhoadonban();

            Console.WriteLine("mahoadonban" + "\t" + "giaban" + "\t" + "ngay");
            for (i = 0; i < list.Count; ++i)
            {
                if (list[i].Mahdb == hdb.Mahdb)
                {
                    Console.WriteLine(hdb.Mahdb + "\t" + hdb.Giaban + "\t\t" + hdb.Ngayban);
                }

                else
                {
                    throw new Exception("Khong ton tai hs nay");
                }
            }
        }
Exemplo n.º 11
0
        public void Sua()
        {
            Console.Clear();
            Console.WriteLine("SUA THONG TIN HOA DON BAN");
            List <hoadonban> list = spDLL.GetAllhoadonban();
            string           ma;

            Console.Write("Nhap ma hoa don ban can sua:");
            ma = Console.ReadLine();
            int i = 0;

            for (i = 0; i < list.Count; ++i)
            {
                if (list[i].Mahdb == ma)
                {
                    break;
                }
            }

            if (i < list.Count)
            {
                hoadonban sp = new hoadonban(list[i]);
                //Console.Write("Nhap ma hoa don ban:");
                //string mahdb = Console.ReadLine();
                //if (mahdb != "") sp.Mahdb = mahdb;
                Console.Write("gia ban:");
                double gb = double.Parse(Console.ReadLine());
                sp.Giaban = gb;
                Console.Write("Nhap ngay ban:");
                DateTime nb = DateTime.Parse(Console.ReadLine());
                sp.Ngayban = nb;


                spDLL.suahoadonban(sp);
            }
            else
            {
                Console.WriteLine("Khong ton tai ma hóa đơn này nay");
            }
        }
Exemplo n.º 12
0
        public void xoahoadonban(hoadonban mahdb)
        {
            int i;
            List <hoadonban> list = lhhdb.GetAllhoadonban();

            for (i = 0; i < list.Count; ++i)
            {
                if (list[i].Mahdb == mahdb.Mahdb)
                {
                    break;
                }
            }
            if (i < list.Count)
            {
                list.RemoveAt(i);
                lhhdb.update(list);
            }
            else
            {
                throw new Exception("Khong ton tai ma nay");
            }
        }
Exemplo n.º 13
0
        public void Hientimkiem()
        {
            Console.Clear();
            Console.WriteLine("HIEN THONG TIN TIM KIEM");
            List <hoadonban> list = spDLL.GetAllhoadonban();
            string           ma;

            Console.Write("Nhap ma hoa don ban can hien thi:");
            ma = Console.ReadLine();
            int i;

            for (i = 0; i < list.Count; ++i)
            {
                if (list[i].Mahdb == ma)
                {
                    break;
                }
            }
            if (i < list.Count)
            {
                hoadonban b = new hoadonban(list[i]);
                spDLL.Hientimkiem(b);
            }
        }