using MOKA_Factory_Tools.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MOKA_Factory_Tools.DAL
{
    public class DAL_AMYields : BaseDAL
    {
        public DAL_AMYields()
        {
            this.TableFieldNameString = "";
        }


        #region 属性和字段

        string _tableName = "AMYields";

        /// <summary>
        /// 获取数据表名
        /// </summary>
        public override string TableName
        {
            get { return _tableName; }
            set { this._tableName = value; }
        }

        /// <summary>
        /// 获取当前新的数据表模型对象
        /// </summary>
        public override object ObjModel
        {
            get
            {
                return this.CurrentModel;
            }
        }

        /// <summary>
        /// 获取当前新的MOdel
        /// </summary>
        public AMYields CurrentModel
        {
            get { return new AMYields(); }
        }


        string _tableFieldNameString = "";
        /// <summary>
        /// 数据表字段名数组
        /// </summary>
        public override string TableFieldNameString
        {
            get { return this._tableFieldNameString; }

            set { this._tableFieldNameString = value; }
        }

        #endregion

        #region 检查记录
        //基类已经实现
        #endregion

        #region 增加数据
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">Model对象</param>
        /// <returns></returns>
        public bool Add(AMYields model)
        {
            return base.Add(model);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">Model对象</param>
        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
        /// <returns></returns>
        public bool Add(AMYields model, string overlookFieldList = "ID")
        {
            return base.Add(model, overlookFieldList);
        }

        #endregion

        #region 删除数据
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Delete(AMYields model)
        {
            return base.Delete(model.ID);
        }
        #endregion

        #region 更新数据
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AMYields model)
        {
            return base.Update(model);
        }

        /// <summary>
        /// 根据筛选字段和SQL筛选运算符号更新数据
        /// </summary>
        /// <param name="model">Model对象</param>
        /// <param name="filterFieldName">筛选字段名称</param>
        /// <param name="operators">SQL筛选运算符号</param>
        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
        /// <returns></returns>
        public bool Update(AMYields model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID")
        {
            return base.Update(model, filterFieldName, operators, overlookFieldList);
        }
        #endregion

        #region 查询数据
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMYields GetModel(string strWhere)
        {
            return DataRowToModel(GetDataRow(strWhere));
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMYields GetModel(string strLine, string strStation, string ODF, DateTime TestDate, int TestHour)
        {
            return DataRowToModel(GetDataRow(string.Format("Line = '{0}' and Station = '{1}' and ODF='{2}' and TestDate='{3}' and TestHour='{4}'", strLine, strStation, ODF, TestDate, TestHour)));
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        public AMYields DataRowToModel(DataRow row)
        {
            return DataRowToModelObject(row) as AMYields;
        }

        /// <summary>
        /// 获得数据Model列表
        /// </summary>
        /// <param name="strWhere">条件 不包含 where 关键字</param>
        public List<AMYields> GetModelList(string strWhere)
        {
            DataSet ds = base.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="dt">DataTable</param>
        public List<AMYields> DataTableToList(DataTable dt)
        {
            List<AMYields> modelList = new List<AMYields>();
            List<object> ObjList = base.GetDataTableToOblList(dt);
            foreach (object obj in ObjList)
            {
                modelList.Add((AMYields)obj);
            }
            return modelList;
        }
        #endregion
    }

    public class DAL_AMYields_TR : BaseDAL
    {
        public DAL_AMYields_TR()
        {
            this.TableFieldNameString = "";
        }


        #region 属性和字段

        string _tableName = "AMYields_TR";

        /// <summary>
        /// 获取数据表名
        /// </summary>
        public override string TableName
        {
            get { return _tableName; }
            set { this._tableName = value; }
        }

        /// <summary>
        /// 获取当前新的数据表模型对象
        /// </summary>
        public override object ObjModel
        {
            get
            {
                return this.CurrentModel;
            }
        }

        /// <summary>
        /// 获取当前新的MOdel
        /// </summary>
        public AMYields_TR CurrentModel
        {
            get { return new AMYields_TR(); }
        }


        string _tableFieldNameString = "";
        /// <summary>
        /// 数据表字段名数组
        /// </summary>
        public override string TableFieldNameString
        {
            get { return this._tableFieldNameString; }

            set { this._tableFieldNameString = value; }
        }

        #endregion

        #region 检查记录
        //基类已经实现
        #endregion

        #region 增加数据
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">Model对象</param>
        /// <returns></returns>
        public bool Add(AMYields_TR model)
        {
            return base.Add(model);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">Model对象</param>
        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
        /// <returns></returns>
        public bool Add(AMYields_TR model, string overlookFieldList = "ID")
        {
            return base.Add(model, overlookFieldList);
        }

        #endregion

        #region 删除数据
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Delete(AMYields_TR model)
        {
            return base.Delete(model.ID);
        }
        #endregion

        #region 更新数据
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AMYields_TR model)
        {
            return base.Update(model);
        }

        /// <summary>
        /// 根据筛选字段和SQL筛选运算符号更新数据
        /// </summary>
        /// <param name="model">Model对象</param>
        /// <param name="filterFieldName">筛选字段名称</param>
        /// <param name="operators">SQL筛选运算符号</param>
        /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
        /// <returns></returns>
        public bool Update(AMYields_TR model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID")
        {
            return base.Update(model, filterFieldName, operators, overlookFieldList);
        }
        #endregion

        #region 查询数据
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMYields_TR GetModel(string strWhere)
        {
            return DataRowToModel(GetDataRow(strWhere));
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMYields_TR GetModel(string strLine, string strStation, string ODF, DateTime TestDate, int TestHour)
        {
            return DataRowToModel(GetDataRow(string.Format("Line = '{0}' and Station = '{1}' and ODF='{2}' and TestDate='{3}' and TestHour='{4}'", strLine, strStation, ODF, TestDate, TestHour)));
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        public AMYields_TR DataRowToModel(DataRow row)
        {
            return DataRowToModelObject(row) as AMYields_TR;
        }

        /// <summary>
        /// 获得数据Model列表
        /// </summary>
        /// <param name="strWhere">条件 不包含 where 关键字</param>
        public List<AMYields_TR> GetModelList(string strWhere)
        {
            DataSet ds = base.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="dt">DataTable</param>
        public List<AMYields_TR> DataTableToList(DataTable dt)
        {
            List<AMYields_TR> modelList = new List<AMYields_TR>();
            List<object> ObjList = base.GetDataTableToOblList(dt);
            foreach (object obj in ObjList)
            {
                modelList.Add((AMYields_TR)obj);
            }
            return modelList;
        }
        #endregion
    }
}
