using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smobiler.Core;
using Smobiler.Core.Controls;
using System.Data;
using SmoONE.UI;

namespace SmoONE.UI.RB
{
    // ******************************************************************
    // ÎÄ¼þ°æ±¾£º SmoONE 2.0
    // Copyright  (c)  2017-2018 Smobiler 
    // ´´½¨Ê±¼ä£º 2017/07
    // Ö÷ÒªÄÚÈÝ£º  Ïû·ÑÀàÐÍÑ¡ÔñÁÐ±í
    // ******************************************************************
    partial class frmRTypeChoose : Smobiler.Core.Controls.MobileForm
    {
        #region "definition"
        internal string TYPEID;                //Ïû·ÑÀàÐÍ±àºÅ
        AutofacConfig AutofacConfig = new AutofacConfig();//µ÷ÓÃÅäÖÃÀà
        #endregion
        /// <summary>
        /// ÊÖ»ú×Ô´ø»ØÍË°´Å¥ÊÂ¼þ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmRTypeChoose_KeyDown(object sender, KeyDownEventArgs e)
        {
            if (e.KeyCode == KeyCode.Back)
            {
                this.Close();         //¹Ø±Õµ±Ç°Ò³Ãæ
            }
        }
        /// <summary>
        /// ³õÊ¼»¯ÊÂ¼þ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmRTypeChoose_Load(object sender, EventArgs e)
        {
            Bind();//°ó¶¨Êý¾Ý¿âÊý¾Ý²Ù×÷
        }
        /// <summary>
        /// ³õÊ¼»¯·½·¨
        /// </summary>
        /// <remarks></remarks>
        private void Bind()
        {
            try
            {
                //ÏÔÊ¾Êý¾Ý±¨ÏúÀàÐÍ
                List<SmoONE.Domain.RB_RType> Types = AutofacConfig.rBService.GetAllType();
                DataTable typetable = new DataTable();
                typetable.Columns.Add("TYPE", typeof(System.String));          //Ïû·ÑÀàÐÍ±àºÅ
                typetable.Columns.Add("TYPENAME", typeof(System.String));      //Ïû·ÑÀàÐÍÃû³Æ
                foreach (SmoONE.Domain.RB_RType row in Types)
                {
                    typetable.Rows.Add(row.RB_RT_ID, row.RB_RT_Name);
                }
                this.listRBRowTypeData.Rows.Clear();//Çå¿ÕÏû·ÑÀàÐÍÑ¡ÔñÁÐ±íÊý¾Ý
                if (typetable.Rows.Count > 0)
                {
                    this.listRBRowTypeData.DataSource = typetable;
                    this.listRBRowTypeData.DataBind();
                }

            }
            catch (Exception ex)
            {
                Toast(ex.Message);
            }
        }
    }
}