xxe 2 yıl önce
ebeveyn
işleme
7ef83dafe2
3 değiştirilmiş dosya ile 108 ekleme ve 86 silme
  1. +6
    -0
      HKCardManager/Form1.cs
  2. +8
    -0
      HKCardManager/UserPages/CancellationPage.cs
  3. +94
    -86
      HKCardManager/UserPages/ReportFormPage.cs

+ 6
- 0
HKCardManager/Form1.cs Dosyayı Görüntüle

@@ -313,6 +313,12 @@ namespace HKCardManager
return;
}

if (res.Equals("666") || res.Equals("888") || res.Equals("999"))
{
MessageBox.Show("超级卡不能被注销");
return;
}

var result = await HKLibHelper.GetUserList("");
UserListDto users = null;
result.ForEach(item =>


+ 8
- 0
HKCardManager/UserPages/CancellationPage.cs Dosyayı Görüntüle

@@ -76,12 +76,20 @@ namespace HKCardManager.UserPages
var temp = Global.UserListDtos.FirstOrDefault(p => p.UserName == name);
if (temp != null)
{
if (temp.State == "作废")
{
MessageBox.Show($"用户【{temp.UserName}】卡片已作废,不允许进行解卦和挂失操作");
return;
}


if (status == 3 && temp.State == "挂失")
{
MessageBox.Show($"用户【{temp.UserName}】挂失状态不能销户");
return;
}


if (!string.IsNullOrEmpty(temp.CardNum))
{
if (MessageBox.Show($"确认是否[{TagName}]用户[{temp.UserName}]!", "操作", MessageBoxButtons.YesNo) == DialogResult.Yes)


+ 94
- 86
HKCardManager/UserPages/ReportFormPage.cs Dosyayı Görüntüle

@@ -43,110 +43,118 @@ namespace HKCardManager.UserPages

private void ExportDataToExcel(DataGridView TableName, string FileName)
{
var d = TableName.DataSource as List<ReportCountDto>;
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "导出Excel文件"; //设置文件标题
saveFileDialog.Filter = "Microsoft Office Excel 工作簿(*.xls)|*.xls"; //设置文件类型
saveFileDialog.FilterIndex = 1; //设置默认文件类型显示顺序
saveFileDialog.AddExtension = true; //是否自动在文件名中添加扩展名
saveFileDialog.RestoreDirectory = true; //是否记忆上次打开的目录
saveFileDialog.FileName = FileName; //设置默认文件名
if (saveFileDialog.ShowDialog() == DialogResult.OK)
try
{
string localFilePath = saveFileDialog.FileName.ToString();
//数据初始化
int TotalCount; //总行数
int RowRead = 0; //已读行数
int Percent = 0; //百分比
TotalCount = TableName.Rows.Count;
Stream myStream = saveFileDialog.OpenFile();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
StreamWriter sw = new StreamWriter(myStream, Encoding.GetEncoding("gb2312"));
string strHeader = string.Empty;
var d = TableName.DataSource as List<ReportCountDto>;
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "导出Excel文件"; //设置文件标题
saveFileDialog.Filter = "Microsoft Office Excel 工作簿(*.xls)|*.xls"; //设置文件类型
saveFileDialog.FilterIndex = 1; //设置默认文件类型显示顺序
saveFileDialog.AddExtension = true; //是否自动在文件名中添加扩展名
saveFileDialog.RestoreDirectory = true; //是否记忆上次打开的目录
saveFileDialog.FileName = FileName; //设置默认文件名
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
string localFilePath = saveFileDialog.FileName.ToString();
//数据初始化
int TotalCount; //总行数
int RowRead = 0; //已读行数
int Percent = 0; //百分比
TotalCount = TableName.Rows.Count;
Stream myStream = saveFileDialog.OpenFile();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
StreamWriter sw = new StreamWriter(myStream, Encoding.GetEncoding("gb2312"));
string strHeader = string.Empty;

Stopwatch timer = new Stopwatch();
timer.Start();
Stopwatch timer = new Stopwatch();
timer.Start();

try
{
//写入标题
for (int i = 0; i < TableName.Columns.Count; i++)
try
{
if (TableName.Columns[i].Visible)
//写入标题
for (int i = 0; i < TableName.Columns.Count; i++)
{
if (i > 0 && !string.IsNullOrEmpty(strHeader)) strHeader += "\t";
strHeader += TableName.Columns[i].HeaderText.ToString();
if (TableName.Columns[i].Visible)
{
if (i > 0 && !string.IsNullOrEmpty(strHeader)) strHeader += "\t";
strHeader += TableName.Columns[i].HeaderText.ToString();
}
}
}
sw.WriteLine(strHeader);
for (int i = 0; i < TableName.Rows.Count+1; i++)
{
RowRead++;
Percent = (int)(100 * RowRead / (TotalCount+1));
Application.DoEvents();
string strData = string.Empty;
for (int j = 0; j < TableName.Columns.Count; j++)
sw.WriteLine(strHeader);
for (int i = 0; i < TableName.Rows.Count + 1; i++)
{
if (i == TableName.Rows.Count)
RowRead++;
Percent = (int)(100 * RowRead / (TotalCount + 1));
Application.DoEvents();
string strData = string.Empty;
for (int j = 0; j < TableName.Columns.Count; j++)
{
if (TableName.Columns[j].Visible && TableName.Columns[j].Name == "早上消费金额")
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += d.Sum(t => t.AM);
}
else if (TableName.Columns[j].Visible && TableName.Columns[j].Name == "中午消费金额")
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += d.Sum(t => t.PM);
}
else if (TableName.Columns[j].Visible && TableName.Columns[j].Name == "晚上消费金额")
if (i == TableName.Rows.Count)
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += d.Sum(t => t.AT);
}
else if (TableName.Columns[j].Visible && TableName.Columns[j].Name == "金额总计")
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += d.Sum(t => t.Total);
}
else if(TableName.Columns[j].Visible)
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += "-";
if (TableName.Columns[j].Visible && TableName.Columns[j].Name == "早上消费金额")
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += d.Sum(t => t.AM);
}
else if (TableName.Columns[j].Visible && TableName.Columns[j].Name == "中午消费金额")
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += d.Sum(t => t.PM);
}
else if (TableName.Columns[j].Visible && TableName.Columns[j].Name == "晚上消费金额")
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += d.Sum(t => t.AT);
}
else if (TableName.Columns[j].Visible && TableName.Columns[j].Name == "金额总计")
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += d.Sum(t => t.Total);
}
else if (TableName.Columns[j].Visible)
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += "-";
}
}
}
else
{
if (i <= TableName.Rows.Count-1)
else
{
string? res = TableName.Rows[i].Cells[j].Value?.ToString();
if (TableName.Columns[j].Visible)
if (i <= TableName.Rows.Count - 1)
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += string.IsNullOrEmpty(res) ? "" : res;
string? res = TableName.Rows[i].Cells[j].Value?.ToString();
if (TableName.Columns[j].Visible)
{
if (j > 0 && !string.IsNullOrEmpty(strData)) strData += "\t";
strData += string.IsNullOrEmpty(res) ? "" : res;
}
}
}
}
sw.WriteLine(strData);
}
sw.WriteLine(strData);
sw.Close();
myStream.Close();
timer.Reset();
timer.Stop();
}
sw.Close();
myStream.Close();
timer.Reset();
timer.Stop();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
sw.Close();
myStream.Close();
timer.Stop();
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
sw.Close();
myStream.Close();
timer.Stop();
}
MessageLogNotify.GetInstance.Show("数据导出成功");
}
MessageLogNotify.GetInstance.Show("数据导出成功");
}
catch (Exception)
{
MessageBox.Show("文件已被打开,请先关闭后在导出", "提示");
}

}
List<ReportCountDto> reportCountDtos = new List<ReportCountDto>();
//查询
@@ -182,7 +190,7 @@ namespace HKCardManager.UserPages
{
this.Invoke(() =>
{
this.button3.Enabled = true;
this.button4.Enabled = true;
if (type == 1)
{
dataGridView1.Columns[0].Visible = true;


Yükleniyor…
İptal
Kaydet