Files
Desktop_PMSTools/frmCustomerList.cs

186 lines
6.5 KiB
C#
Raw Normal View History

2025-11-26 11:50:15 +08:00
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;
using System.Net;
using System.IO;
namespace WinFormTest
{
public partial class frmCustomerList : Form
{
syncstatus.syncstatusSoapClient client = new syncstatus.syncstatusSoapClient();
long _checkInID;
public frmCustomerList(long checkInID)
{
InitializeComponent();
_checkInID = checkInID;
btnRefresh.Click += new EventHandler(btnRefresh_Click);
btnClose.Click += new EventHandler(btnClose_Click);
//grdData.CellContentClick += new DataGridViewCellEventHandler(grdData_CellContentClick);
grdData.CellFormatting += new DataGridViewCellFormattingEventHandler(grdData_CellFormatting);
grdData.CellDoubleClick += new DataGridViewCellEventHandler(grdData_CellDoubleClick);
}
void grdData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 6)
{
System.Diagnostics.Process.Start("iexplore.exe", grdData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
}
}
void grdData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (grdData.Columns[e.ColumnIndex].Name.Equals("PhotoUrl"))
{
e.Value = new Bitmap(GetImage(e.Value.ToString()));
}
}
private Stream GetImage(string path)
{
try
{
WebRequest request = WebRequest.Create(path);
WebResponse response = request.GetResponse();
Stream str = response.GetResponseStream();
return str;
}
catch (Exception err)
{
throw new Exception(err.Message);
}
}
void btnRefresh_Click(object sender, EventArgs e)
{
LoadData();
}
private void frmFace_Load(object sender, EventArgs e)
{
BindGridStyle();
LoadData();
}
void LoadData()
{
DataSet ds = client.GetRoomCustomer(_checkInID);
foreach (DataRow row in ds.Tables[0].Rows)
{
switch (Convert.ToInt16(row["Status"]))
{
case 0:
row["StatusName"] = "未同步";
break;
case 1:
row["StatusName"] = "推送下发成功";
break;
case 2:
row["StatusName"] = "推送删除成功";
break;
}
row["SexName"] = Convert.ToInt16(row["Sex"]) == 0 ? "女" : "男";
}
grdData.DataSource = ds.Tables[0].DefaultView;
for (int i = 0; i < grdData.Rows.Count; i++)
{
grdData.Rows[i].Height = 75;
}
}
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 col100 = new DataGridViewTextBoxColumn();
col100.Name = "StatusName";
col100.DataPropertyName = col100.Name;
col100.HeaderText = "状态";
col100.Width = 80;
grdData.Columns.Add(col100);
DataGridViewTextBoxColumn col11 = new DataGridViewTextBoxColumn();
col11.Name = "IDCard";
col11.DataPropertyName = col11.Name;
col11.HeaderText = "身份证号";
col11.Width = 130;
grdData.Columns.Add(col11);
DataGridViewTextBoxColumn col10 = new DataGridViewTextBoxColumn();
col10.Name = "Name";
col10.DataPropertyName = col10.Name;
col10.HeaderText = "姓名";
col10.Width = 80;
grdData.Columns.Add(col10);
DataGridViewTextBoxColumn col19 = new DataGridViewTextBoxColumn();
col19.Name = "SexName";
col19.DataPropertyName = col19.Name;
col19.HeaderText = "性别";
col19.Width = 40;
grdData.Columns.Add(col19);
DataGridViewTextBoxColumn col9 = new DataGridViewTextBoxColumn();
col9.Name = "Birthday";
col9.DataPropertyName = col9.Name;
col9.HeaderText = "出生日期";
col9.Width = 80;
grdData.Columns.Add(col9);
//DataGridViewLinkColumn col2 = new DataGridViewLinkColumn();
//col2.Name = "PhotoUrl";
//col2.DataPropertyName = col2.Name;
//col2.HeaderText = "图片路径";
//col2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
//grdData.Columns.Add(col2);
DataGridViewImageColumn col22 = new DataGridViewImageColumn();
col22.Name = "PhotoUrl";
col22.DataPropertyName = col22.Name;
col22.HeaderText = "图片";
col22.ImageLayout = DataGridViewImageCellLayout.Zoom;
grdData.Columns.Add(col22);
DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn();
col3.Name = "CreatedDate";
col3.DataPropertyName = col3.Name;
col3.HeaderText = "创建日期";
col3.Width = 100;
grdData.Columns.Add(col3);
DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn();
col5.Name = "ModifiedDate";
col5.DataPropertyName = col5.Name;
col5.HeaderText = "修改日期";
col5.Width = 100;
grdData.Columns.Add(col5);
}
}
}