using System;
using System.Text;
using System.Xml;

namespace ChuPiao.Common.Models
{
    /// <summary>
    /// 彩票机玩法时段报表
    /// </summary>
    public class R_MachinePlayReportEntity : R_MachineReportEntity
    {
		#region Model
		private int _r_lotid;
		/// <summary>
		/// 彩种ID
		/// </summary>
		public int R_LotId
		{
            set { _r_lotid = value; }
            get { return _r_lotid; }
		}
		#endregion Model
        
        public R_MachinePlayReportEntity()
        {

        }
        public R_MachinePlayReportEntity(XmlNode xmlNode)
        {
            if(xmlNode==null)
            {
                return;
            }
            bool result;
            XmlNode node = xmlNode.SelectSingleNode("id");
            if(node!=null)
            {
                int id;
                result=int.TryParse(node.InnerText, out id);
                if(result)
                {
                    R_Id = id;
                }
            }
            node = xmlNode.SelectSingleNode("starttime");
            if (node != null)
            {
                DateTime starttime;
                result = DateTime.TryParse(node.InnerText, out starttime);
                if(result)
                {
                    R_StartTime = starttime;
                }
            }
            node = xmlNode.SelectSingleNode("endtime");
            if (node != null)
            {
                DateTime endtime;
                result=DateTime.TryParse(node.InnerText, out endtime);
                if(result)
                {
                    R_EndTime = endtime;
                }
            }
            node = xmlNode.SelectSingleNode("salemoney");
            if (node != null)
            {
                decimal salemoney;
                result=decimal.TryParse(node.InnerText, out salemoney);
                if(result)
                {
                    R_SaleMoney = salemoney;
                }
            }
            node = xmlNode.SelectSingleNode("saleticket");
            if (node != null)
            {
                int saleticket;
                result=int.TryParse(node.InnerText, out saleticket);
                if(result)
                {
                    R_SaleTicket = saleticket;
                }
            }
            node = xmlNode.SelectSingleNode("encashmoney");
            if (node != null)
            {
                decimal encashmoney;
                result=decimal.TryParse(node.InnerText, out encashmoney);
                if(result)
                {
                    R_EncashMoney = encashmoney;
                }
            }
            node = xmlNode.SelectSingleNode("encashticket");
            if (node != null)
            {
                int encashticket;
                result=int.TryParse(node.InnerText, out encashticket);
                if(result)
                {
                    R_EncashTicket = encashticket;
                }
            }
            node = xmlNode.SelectSingleNode("zxmacnumber");
            if (node != null)
            {
                R_ZxMacNumber = node.InnerText;
            }
            node = xmlNode.SelectSingleNode("querytime");
            if (node != null)
            {
                DateTime querytime;
                result=DateTime.TryParse(node.InnerText, out querytime);
                if(result)
                {
                    R_QueryTime = querytime;
                }
            }
            node = xmlNode.SelectSingleNode("lotid");
            if (node != null)
            {
                int lotid;
                result = int.TryParse(node.InnerText, out lotid);
                if (result)
                {
                    R_LotId = lotid;
                }
            }
            node = xmlNode.SelectSingleNode("prntext");
            if (node != null)
            {
                R_PrnText = node.InnerText;
            }
        }
        public new string Pack()
        {
            StringBuilder dataBuilder = new StringBuilder();
            dataBuilder.Append("<machineplayreport>");
            dataBuilder.AppendFormat("<id>{0}</id>",R_Id);
            dataBuilder.AppendFormat("<starttime>{0}</starttime>",R_StartTime);
            dataBuilder.AppendFormat("<endtime>{0}</endtime>",R_EndTime);
            dataBuilder.AppendFormat("<salemoney>{0}</salemoney>",R_SaleMoney);
            dataBuilder.AppendFormat("<saleticket>{0}</saleticket>",R_SaleTicket);
            dataBuilder.AppendFormat("<encashmoney>{0}</encashmoney>",R_EncashMoney);
            dataBuilder.AppendFormat("<encashticket>{0}</encashticket>",R_EncashTicket);
            dataBuilder.AppendFormat("<zxmacnumber>{0}</zxmacnumber>",R_ZxMacNumber);
            dataBuilder.AppendFormat("<querytime>{0}</querytime>", R_QueryTime);
            dataBuilder.AppendFormat("<lotid>{0}</lotid>", R_LotId);
            dataBuilder.AppendFormat("<prntext>{0}</prntext>",R_PrnText);
            dataBuilder.Append("</machineplayreport>");
            return dataBuilder.ToString();
        }
    }
}
