using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ZXDT.CallCenter.BLL
{
    //T_Fax_RecvFax
    public partial class T_Fax_RecvFax
    {

        private readonly DAL.T_Fax_RecvFax dal = new DAL.T_Fax_RecvFax();
        public T_Fax_RecvFax()
        { }

        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int FaxID)
        {
            return dal.Exists(FaxID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.T_Fax_RecvFax model)
        {
            return dal.Add(model);

        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.T_Fax_RecvFax model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 更新查看状态
        /// </summary>
        /// <param name="FaxID"></param>
        /// <param name="State"></param>
        /// <returns></returns>
        public int UpdateState(int FaxID, int State)
        {
            return dal.UpdateState(FaxID, State);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateWebFilePath(Model.T_Fax_RecvFax model)
        {
            return dal.UpdateWebFilePath(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int FaxID)
        {

            return dal.Delete(FaxID);
        }
        /// <summary>
        /// 批量删除一批数据
        /// </summary>
        public bool DeleteList(string FaxIDlist)
        {
            return dal.DeleteList(FaxIDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.T_Fax_RecvFax GetModel(int FaxID)
        {

            return dal.GetModel(FaxID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.T_Fax_RecvFax> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.T_Fax_RecvFax> DataTableToList(DataTable dt)
        {
            List<Model.T_Fax_RecvFax> modelList = new List<Model.T_Fax_RecvFax>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.T_Fax_RecvFax model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.T_Fax_RecvFax();
                    if (dt.Rows[n]["FaxID"].ToString() != "")
                    {
                        model.FaxID = int.Parse(dt.Rows[n]["FaxID"].ToString());
                    }
                    if (dt.Rows[n]["FileState"].ToString() != "")
                    {
                        model.FileState = int.Parse(dt.Rows[n]["FileState"].ToString());
                    }
                    if (dt.Rows[n]["State"].ToString() != "")
                    {
                        model.State = int.Parse(dt.Rows[n]["State"].ToString());
                    }
                    if (dt.Rows[n]["F_UserID"].ToString() != "")
                    {
                        model.F_UserID = int.Parse(dt.Rows[n]["F_UserID"].ToString());
                    }
                    if (dt.Rows[n]["F_CustomerID"].ToString() != "")
                    {
                        model.F_CustomerID = int.Parse(dt.Rows[n]["F_CustomerID"].ToString());
                    }
                    model.F_Name = dt.Rows[n]["F_Name"].ToString();
                    model.F_FaxCode = dt.Rows[n]["F_FaxCode"].ToString();
                    model.TelNum = dt.Rows[n]["TelNum"].ToString();
                    model.TifFilePath = dt.Rows[n]["TifFilePath"].ToString();
                    model.FilePath = dt.Rows[n]["FilePath"].ToString();
                    if (dt.Rows[n]["FileSize"].ToString() != "")
                    {
                        model.FileSize = int.Parse(dt.Rows[n]["FileSize"].ToString());
                    }
                    model.FileType = dt.Rows[n]["FileType"].ToString();
                    model.Remark = dt.Rows[n]["Remark"].ToString();
                    if (dt.Rows[n]["RecvTime"].ToString() != "")
                    {
                        model.RecvTime = DateTime.Parse(dt.Rows[n]["RecvTime"].ToString());
                    }
                    model.Info = dt.Rows[n]["Info"].ToString();


                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }
        #endregion

    }
}
