internal void AddProduct()
 {
     if (View.BanCurrent == null)
     {
         return;
     }
     if (View.HoaDonCurrent.BanId == null)
     {
         return;
     }
     if (View.BanCurrent.HoadonId == null)
     {
         var x = new HoadonModel {
             TenBan = View.BanCurrent.Ten, BanId = View.BanCurrent.BanId, Ngaygio = DateTime.Now, Step = 0, Tongtien = 0
         };
         View.HoaDonCurrent      = x;
         View.ChitietHoadonItems = new List <ChitietHoadonModel>();
     }
     View.ChitietHoadonItems.Add(new ChitietHoadonModel {
         HoadonId = View.HoaDonCurrent.HoadonId, HanghoaId = View.HanghoaCurrent.HanghoaId, Soluong = 1, Dongia = View.HanghoaCurrent.Giaban, Thanhtien = View.HanghoaCurrent.Giaban
     });
     View.BanCurrent.HoadonId = View.HoaDonCurrent.HoadonId;
     Model.Set(View.HoaDonCurrent);
     Model.Set(View.ChitietHoadonItems);
     View.RefreshData();
 }
        internal void LoadHoadonByBan()
        {
            if (View.ChitietHoadonItems != null && View.ChitietHoadonItems.Count != 0)
            {
                Model.Set(View.HoaDonCurrent);
                Model.Set(View.ChitietHoadonItems);
            }

            View.HoaDonCurrent = new HoadonModel();
            if (View.BanCurrent.HoadonId != null)
            {
                var item = new List <AutoItem>();
                item.Add(new AutoItem {
                    Name = "HoadonId", Value = View.BanCurrent.HoadonId, SqlType = System.Data.SqlDbType.UniqueIdentifier
                });
                var x = Model.Get <HoadonModel>(new AutoObject {
                    Items = item, SpName = "Pos_Danh_GetHoadonByHoadonId"
                }).FirstOrDefault();
                if (View.HoaDonCurrent != null)
                {
                    x.TenBan           = View.BanCurrent.Ten;
                    View.HoaDonCurrent = x;
                }
                View.ChitietHoadonItems = Model.Get <ChitietHoadonModel>(new AutoObject {
                    Items = item, SpName = "Pos_Danh_GetChitietHoadonByHoadonId"
                });
            }
            else
            {
                var x = new HoadonModel {
                    TenBan = View.BanCurrent.Ten, BanId = View.BanCurrent.BanId
                };
                View.HoaDonCurrent      = x;
                View.ChitietHoadonItems = new List <ChitietHoadonModel>();
            }
            View.RefreshData();
        }