Beispiel #1
0
        protected void Select_Change(Object sender, EventArgs e)
        {
            string str_ID = "";

            if (TreeView1.SelectedNode.ChildNodes.Count == 0)
            {
                str_ID = TreeView1.SelectedValue;
            }
            else
            {
                for (int i = 0; i < TreeView1.SelectedNode.ChildNodes.Count; i++)
                {
                    if (i == 0)
                    {
                        str_ID += TreeView1.SelectedNode.ChildNodes[i].Value;
                    }
                    else if (i > 0)
                    {
                        str_ID += ", " + TreeView1.SelectedNode.ChildNodes[i].Value;
                    }
                }
            }
            str_ID += ", " + TreeView1.SelectedValue.ToString();
            DeviceObjectDataSource.SelectParameters["str_ID"].DefaultValue = str_ID;
            GridDevice.DataBind();
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        private void DataBind()
        {
            List <SeatManage.ClassModel.TerminalInfoV2> clientlist = SeatManage.Bll.TerminalOperatorService.GetAllTeminalInfo();
            DataTable dt = new DataTable();

            dt.Columns.Add("DeviceNum", typeof(string));
            dt.Columns.Add("Describe", typeof(string));
            dt.Columns.Add("LastPrintTimes", typeof(string));
            dt.Columns.Add("PrintedTimes", typeof(string));
            dt.Columns.Add("PrinterStatus", typeof(string));
            dt.Columns.Add("Date", typeof(string));
            foreach (SeatManage.ClassModel.TerminalInfoV2 client in clientlist)
            {
                DataRow dr = dt.NewRow();
                dr["DeviceNum"] = client.ClientNo;
                dr["Describe"]  = client.Describe;
                if (client.LastPrintTimes == 0)
                {
                    dr["LastPrintTimes"] = "暂无打印数据";
                }
                else
                {
                    dr["LastPrintTimes"] = client.LastPrintTimes.ToString();
                }
                dr["PrintedTimes"] = client.PrintedTimes.ToString();
                if (client.PrinterStatus)
                {
                    dr["PrinterStatus"] = "打印机有纸";
                }
                else
                {
                    dr["PrinterStatus"] = "打印机缺纸";
                }
                if (client.StatusUpdateTime == null)
                {
                    dr["Date"] = "暂无记录";
                }
                else
                {
                    dr["Date"] = client.StatusUpdateTime.ToString();
                }

                dt.Rows.Add(dr);
            }
            DataView TableView = dt.DefaultView;

            GridDevice.DataSource = TableView;
            GridDevice.DataBind();
        }