200 lines
7.2 KiB
C#
200 lines
7.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
|
|||
|
|
namespace WinFormTest
|
|||
|
|
{
|
|||
|
|
public partial class frmFace : Form
|
|||
|
|
{
|
|||
|
|
syncstatus.syncstatusSoapClient client = new syncstatus.syncstatusSoapClient();
|
|||
|
|
private string _hotelCode;
|
|||
|
|
private int _selectedIndex = 0;
|
|||
|
|
private bool _multipleHotel;
|
|||
|
|
|
|||
|
|
public frmFace(string hotelCode, bool multipleHotel)
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
_hotelCode = hotelCode;
|
|||
|
|
_multipleHotel = multipleHotel;
|
|||
|
|
|
|||
|
|
btnRefresh.Click += new EventHandler(btnRefresh_Click);
|
|||
|
|
btnBing.Click += new EventHandler(btnBing_Click);
|
|||
|
|
btnCleanBing.Click += new EventHandler(btnCleanBing_Click);
|
|||
|
|
btnClose.Click += new EventHandler(btnClose_Click);
|
|||
|
|
grdData.CellDoubleClick += new DataGridViewCellEventHandler(grdData_CellDoubleClick);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void grdData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
|||
|
|
{
|
|||
|
|
btnBing_Click(null, null);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void btnRefresh_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
LoadData(cmbHotelCode.SelectedValue.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void frmFace_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BindGridStyle();
|
|||
|
|
//LoadData(_hotelCode);
|
|||
|
|
|
|||
|
|
DataSet ds = client.GetHotelCode();
|
|||
|
|
DataRow dr = ds.Tables[0].NewRow();
|
|||
|
|
dr["Code"] = "";
|
|||
|
|
dr["Remark"] = "全部酒店";
|
|||
|
|
ds.Tables[0].Rows.InsertAt(dr, 0);
|
|||
|
|
cmbHotelCode.ValueMember = "Code";
|
|||
|
|
cmbHotelCode.DisplayMember = "Remark";
|
|||
|
|
cmbHotelCode.DataSource = ds.Tables[0].DefaultView;
|
|||
|
|
cmbHotelCode.SelectedIndexChanged += new EventHandler(cmbHotelCode_SelectedIndexChanged);
|
|||
|
|
cmbHotelCode.SelectedValue = _hotelCode;
|
|||
|
|
cmbHotelCode.Enabled = _multipleHotel;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LoadData(string code)
|
|||
|
|
{
|
|||
|
|
DataSet dsDevices = client.GetDevices(code);
|
|||
|
|
grdData.DataSource = dsDevices.Tables[0].DefaultView;
|
|||
|
|
if (dsDevices.Tables[0].Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
grdData.Rows[_selectedIndex].Selected = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void cmbHotelCode_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
_selectedIndex = 0;
|
|||
|
|
LoadData(cmbHotelCode.SelectedValue.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void btnBing_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (grdData.SelectedRows.Count == 0)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("请选择设备记录");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
DataGridViewRow row = grdData.SelectedRows[0];
|
|||
|
|
_selectedIndex = row.Index;
|
|||
|
|
frmFaceDevice frm = new frmFaceDevice((long)row.Cells["ID"].Value, row.Cells["SerialNo"].Value.ToString(),
|
|||
|
|
row.Cells["DevName"].Value.ToString(), row.Cells["HotelCode"].Value.ToString(), row.Cells["RoomNumber"].Value.ToString(),
|
|||
|
|
cmbHotelCode.SelectedValue.ToString(), _multipleHotel);
|
|||
|
|
frm.SaveEvent += new EventHandler(frm_SaveEvent);
|
|||
|
|
frm.ShowDialog();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void frm_SaveEvent(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
btnRefresh_Click(null, null);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void btnCleanBing_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (grdData.SelectedRows.Count == 0)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("请选择设备记录");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
DataGridViewRow row = grdData.SelectedRows[0];
|
|||
|
|
if (string.IsNullOrEmpty(row.Cells["HotelCode"].Value.ToString()))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("该设备尚未绑定,无需解绑");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (MessageBox.Show("确定解除绑定吗?", "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
_selectedIndex = row.Index;
|
|||
|
|
if (client.SaveDevice((long)row.Cells["ID"].Value, "", "") > 0)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("解除绑定成功");
|
|||
|
|
btnRefresh_Click(null, null);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("解除绑定失败");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void btnClose_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定Grid样式
|
|||
|
|
/// </summary>
|
|||
|
|
private void BindGridStyle()
|
|||
|
|
{
|
|||
|
|
grdData.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.WhiteSmoke;//FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
|
|||
|
|
grdData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|||
|
|
grdData.MultiSelect = false;
|
|||
|
|
grdData.AllowUserToAddRows = false;
|
|||
|
|
grdData.AutoGenerateColumns = false;
|
|||
|
|
|
|||
|
|
DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();
|
|||
|
|
col1.Name = "ID";
|
|||
|
|
col1.DataPropertyName = col1.Name;
|
|||
|
|
col1.HeaderText = "ID";
|
|||
|
|
col1.Width = 60;
|
|||
|
|
//col1.Visible = false;
|
|||
|
|
grdData.Columns.Add(col1);
|
|||
|
|
|
|||
|
|
DataGridViewTextBoxColumn col11 = new DataGridViewTextBoxColumn();
|
|||
|
|
col11.Name = "SerialNo";
|
|||
|
|
col11.DataPropertyName = col11.Name;
|
|||
|
|
col11.HeaderText = "设备序列号";
|
|||
|
|
col11.Width = 130;
|
|||
|
|
grdData.Columns.Add(col11);
|
|||
|
|
|
|||
|
|
DataGridViewTextBoxColumn col10 = new DataGridViewTextBoxColumn();
|
|||
|
|
col10.Name = "DevName";
|
|||
|
|
col10.DataPropertyName = col10.Name;
|
|||
|
|
col10.HeaderText = "设备名称";
|
|||
|
|
col10.Width = 80;
|
|||
|
|
grdData.Columns.Add(col10);
|
|||
|
|
|
|||
|
|
DataGridViewTextBoxColumn col19 = new DataGridViewTextBoxColumn();
|
|||
|
|
col19.Name = "HotelCode";
|
|||
|
|
col19.DataPropertyName = col19.Name;
|
|||
|
|
col19.HeaderText = "所属酒店";
|
|||
|
|
col19.Width = 180;
|
|||
|
|
col19.Visible = false;
|
|||
|
|
grdData.Columns.Add(col19);
|
|||
|
|
|
|||
|
|
DataGridViewTextBoxColumn col9 = new DataGridViewTextBoxColumn();
|
|||
|
|
col9.Name = "Remark";
|
|||
|
|
col9.DataPropertyName = col9.Name;
|
|||
|
|
col9.HeaderText = "所属酒店";
|
|||
|
|
col9.Width = 180;
|
|||
|
|
grdData.Columns.Add(col9);
|
|||
|
|
|
|||
|
|
DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();
|
|||
|
|
col2.Name = "RoomNumber";
|
|||
|
|
col2.DataPropertyName = col2.Name;
|
|||
|
|
col2.HeaderText = "绑定房号";
|
|||
|
|
col2.Width = 80;
|
|||
|
|
grdData.Columns.Add(col2);
|
|||
|
|
|
|||
|
|
DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn();
|
|||
|
|
col3.Name = "CreatedDate";
|
|||
|
|
col3.DataPropertyName = col3.Name;
|
|||
|
|
col3.HeaderText = "创建日期";
|
|||
|
|
col3.Width = 120;
|
|||
|
|
grdData.Columns.Add(col3);
|
|||
|
|
|
|||
|
|
DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn();
|
|||
|
|
col5.Name = "ModifiedDate";
|
|||
|
|
col5.DataPropertyName = col5.Name;
|
|||
|
|
col5.HeaderText = "修改日期";
|
|||
|
|
col5.Width = 120;
|
|||
|
|
grdData.Columns.Add(col5);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|