using Forks.EnterpriseServices.DataDictionary;
using Forks.EnterpriseServices.DomainObjects2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ButcherFactory.BO
{
  [MapToTable("Butcher_CarcassSaleOut_Detail")]
  [KeyField("ID", KeyGenType.identity)]
  [DBIndex("IDX_Butcher_CarcassSaleOut_Detail_Clustered", "BarCode", false, 0)]
  [DBIndexType("IDX_Butcher_CarcassSaleOut_Detail_Clustered", IndexType.Clustered)]
  public class CarcassSaleOut_Detail
  {
    public CarcassSaleOut_Detail()
    {
      Time = DateTime.Now;
    }

    public long ID { get; set; }

    public long? BillID { get; set; }

    public long? DetailID { get; set; }

    public string BarCode { get; set; }

    [NonDmoProperty]
    public string ShortCode
    {
      get
      {
        if (string.IsNullOrEmpty(BarCode))
          return null;
        if (BarCode.Contains("260912011"))
          return BarCode.Replace("260912011", "");
        return BarCode;
      }
    }

    public long? Goods_ID { get; set; }

    public string Goods_Name { get; set; }

    public string Goods_Code { get; set; }

    public long? ProductBatch_ID { get; set; }

    public decimal Number { get; set; }

    public decimal? InStoreWeight { get; set; }

    public decimal Weight { get; set; }

    [NonDmoProperty]
    public int Idx { get; set; }

    [NonDmoProperty]
    public decimal? DiffWeight
    {
      get
      {
        if (InStoreWeight.HasValue)
          return InStoreWeight.Value - Weight;
        return null;
      }
    }

    public DateTime Time { get; set; }

    public bool Filled { get; set; }

    private bool mSelected = true;
    [NonDmoProperty]
    public bool Selected
    {
      get { return mSelected; }
      set { mSelected = value; }
    }

    public long? WeightRecord_ID { get; set; }

    public long? ScanRecord_ID { get; set; }

    public string Operator { get; set; }

    [DbColumn(DefaultValue = false)]
    public bool IsBack { get; set; }
  }

  public class SaleOutStore
  {
    public long ID { get; set; }

    public string Customer_Name { get; set; }

    public DateTime? SendTime { get; set; }

    public string DeliverGoodsLine_Name { get; set; }

    public string Address { get; set; }

    public string CarNumber { get; set; }
  }

  public class SaleOutStore_Detail
  {
    public long SaleOutStore_ID { get; set; }

    public long ID { get; set; }

    public string Customer_Name { get; set; }

    public long? Goods_ID { get; set; }

    public string Goods_Code { get; set; }

    public string Goods_Name { get; set; }

    public decimal? SecondNumber { get; set; }

    public decimal? Number { get; set; }

    public decimal? SSecondNumber { get; set; }

    public decimal? SNumber { get; set; }

    public decimal? DiffNumber
    {
      get
      {
        if (Number.HasValue && SNumber.HasValue)
          return Number.Value - SNumber.Value;
        return null;
      }
    }
  }
}
