Files
Desktop_PMSTools/frmMain.cs
2025-11-26 11:50:21 +08:00

227 lines
8.3 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 frmMain : Form
{
syncstatus.syncstatusSoapClient client = new syncstatus.syncstatusSoapClient();
public frmMain()
{
InitializeComponent();
grdData.RowPostPaint += new DataGridViewRowPostPaintEventHandler(grdData_RowPostPaint);
btnQuery.Click += new EventHandler(btnQuery_Click);
btnClose.Click += new EventHandler(btnClose_Click);
btnFace.Click += new EventHandler(btnFace_Click);
btnTongBu.Click += new EventHandler(btnTongBu_Click);
}
void btnTongBu_Click(object sender, EventArgs e)
{
if (grdData.SelectedRows.Count == 0)
{
MessageBox.Show("请选择开房记录");
return;
}
DataGridViewRow row = grdData.SelectedRows[0];
frmCustomerList frm = new frmCustomerList((long)row.Cells["ID"].Value);
frm.ShowDialog();
}
void btnFace_Click(object sender, EventArgs e)
{
frmFace frm = new frmFace(cmbHotelCode.SelectedValue.ToString(), cmbHotelCode.Enabled);
frm.ShowDialog();
}
private void Form2_Load(object sender, EventArgs e)
{
BindGridStyle();
try
{
DataSet ds = client.GetHotelCode();
cmbHotelCode.ValueMember = "Code";
cmbHotelCode.DisplayMember = "Remark";
cmbHotelCode.DataSource = ds.Tables[0].DefaultView;
//cmbHotelCode.SelectedValue = "1486";//只用改这里就可以了 Code
cmbHotelCode.SelectedValue = "1919";//只用改这里就可以了 Code
cmbHotelCode.Enabled = false;
//btnFace.Visible = btnTongBu.Visible = cmbHotelCode.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show("获取酒店数据有误。原因:" + ex.Message);
}
}
void btnQuery_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(cmbHotelCode.SelectedValue.ToString()))
{
MessageBox.Show("请选择酒店编码!");
return;
}
try
{
Cursor.Current = Cursors.WaitCursor;
DataSet ds = client.GetRoomRecord(cmbHotelCode.SelectedValue.ToString(), txtRoomNumber.Text.Trim(), "");
grdData.DataSource = ds.Tables[0].DefaultView;
}
catch (Exception ex)
{
MessageBox.Show("查询数据有误。原因:" + ex.ToString());
}
Cursor.Current = Cursors.Default;
}
private void button2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(cmbHotelCode.SelectedValue.ToString()))
{
MessageBox.Show("请选择酒店编码!");
return;
}
try
{
Cursor.Current = Cursors.WaitCursor;
DataSet ds = client.GetRoomRecord(cmbHotelCode.SelectedValue.ToString(), txtRoomNumber.Text.Trim(), "tb_RoomCheck20180908");
grdData.DataSource = ds.Tables[0].DefaultView;
}
catch (Exception ex)
{
MessageBox.Show("查询数据有误。原因:" + ex.ToString());
}
Cursor.Current = Cursors.Default;
}
void grdData_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
DataGridView grd = (DataGridView)sender;
using (SolidBrush b = new SolidBrush(grd.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 10, e.RowBounds.Location.Y + 2);
}
}
/// <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 = true;
grdData.Columns.Add(col1);
DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();
col2.Name = "RoomNumber";
col2.DataPropertyName = col2.Name;
col2.HeaderText = "房号";
col2.Width = 70;
grdData.Columns.Add(col2);
DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn();
col3.Name = "CheckInDate";
col3.DataPropertyName = col3.Name;
col3.HeaderText = "PMS开房时间";
col3.Width = 120;
grdData.Columns.Add(col3);
DataGridViewCheckBoxColumn col4 = new DataGridViewCheckBoxColumn();
col4.Name = "SyncCheckIn";
col4.DataPropertyName = col4.Name;
col4.HeaderText = "客控同步";
col4.Width = 60;
//col4.SortMode = DataGridViewColumnSortMode.NotSortable;
grdData.Columns.Add(col4);
DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn();
col5.Name = "CheckOutDate";
col5.DataPropertyName = col5.Name;
col5.HeaderText = "PMS退房时间";
col5.Width = 120;
grdData.Columns.Add(col5);
DataGridViewCheckBoxColumn col6 = new DataGridViewCheckBoxColumn();
col6.Name = "SyncCheckOut";
col6.DataPropertyName = col6.Name;
col6.HeaderText = "客控同步";
col6.Width = 60;
//col6.SortMode = DataGridViewColumnSortMode.NotSortable;
grdData.Columns.Add(col6);
DataGridViewTextBoxColumn col7 = new DataGridViewTextBoxColumn();
col7.Name = "RentDate";
col7.DataPropertyName = col7.Name;
col7.HeaderText = "PMS待租时间";
col7.Width = 120;
grdData.Columns.Add(col7);
DataGridViewCheckBoxColumn col8 = new DataGridViewCheckBoxColumn();
col8.Name = "SyncRent";
col8.DataPropertyName = col8.Name;
col8.HeaderText = "客控同步";
col8.Width = 60;
//col8.SortMode = DataGridViewColumnSortMode.NotSortable;
grdData.Columns.Add(col8);
DataGridViewTextBoxColumn col9 = new DataGridViewTextBoxColumn();
col9.Name = "PhoneNumber";
col9.DataPropertyName = col9.Name;
col9.HeaderText = "手机号";
col9.Width = 90;
grdData.Columns.Add(col9);
DataGridViewTextBoxColumn col11 = new DataGridViewTextBoxColumn();
col11.Name = "IDNumber";
col11.DataPropertyName = col11.Name;
col11.HeaderText = "身份证号";
col11.Width = 130;
grdData.Columns.Add(col11);
DataGridViewTextBoxColumn col10 = new DataGridViewTextBoxColumn();
col10.Name = "ValidateCode";
col10.DataPropertyName = col10.Name;
col10.HeaderText = "验证码";
col10.Width = 70;
col10.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
grdData.Columns.Add(col10);
}
void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
frmCheckIn frm = new frmCheckIn(cmbHotelCode.SelectedValue.ToString(), txtRoomNumber.Text.Trim());
frm.ShowDialog();
}
private void btnQuery_Click_1(object sender, EventArgs e)
{
}
}
}