- 客户/产品销售明细写入逻辑优化,支持动态插入产品行,合并单元格处理更严谨 - 销售明细导入支持“英文品名”列动态索引,兼容多种表格格式 - 启用产品年度预估表自动生成,支持“產品資料”批量导入 - 客户/产品查找新增特殊字符转义,查找更稳定 - “成長率”列标题改为“達成率” - 项目及程序集版本号提升
96 lines
3.3 KiB
C#
96 lines
3.3 KiB
C#
using KellyReport_D.Properties;
|
|
using KellyReport_D.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Office.Interop.Excel;
|
|
using System.Windows.Forms;
|
|
|
|
namespace KellyReport_D
|
|
{
|
|
public partial class JQSalesSummaryPanel : UserControl
|
|
{
|
|
public JQSalesSummaryPanel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
override
|
|
protected void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
this.step1Lab.Text = Resources.Step1;
|
|
this.step1DescLab.Text = Resources.STEP1_DESC;
|
|
this.step1NoteLab.Text = Resources.STEP1_NOTE;
|
|
this.initForecastBtn.Text = Resources.INIT_FORECAST;
|
|
|
|
this.step2Lab.Text = Resources.Step2;
|
|
this.step2DescLab.Text = Resources.STEP2_DESC;
|
|
this.importSalesBtn.Text = Resources.IMPORT_SALES;
|
|
}
|
|
|
|
private void panel1_Resize(object sender, EventArgs e)
|
|
{
|
|
initForecastBtn.Left = (buttonWrapper1.ClientSize.Width - initForecastBtn.Width) / 2;
|
|
initForecastBtn.Top = (buttonWrapper1.ClientSize.Height - initForecastBtn.Height) / 2; // 可选:垂直居中
|
|
}
|
|
|
|
private void JQSalesSummaryPanel_Resize(object sender, EventArgs e)
|
|
{
|
|
//this.step2DescLab.Size = new Size(this.Width, 65);
|
|
int width = this.Width;
|
|
// 预留内边距
|
|
int padding = this.step2DescLab.Padding.Vertical + 4;
|
|
// 计算文本所需高度
|
|
Size textSize = TextRenderer.MeasureText(
|
|
this.step2DescLab.Text,
|
|
this.step2DescLab.Font,
|
|
new Size(width, int.MaxValue),
|
|
TextFormatFlags.WordBreak
|
|
);
|
|
step2DescLab.Size = new Size(width, textSize.Height + padding);
|
|
}
|
|
|
|
private void initForecastBtn_Click(object sender, EventArgs e)
|
|
{
|
|
WorkBookUtils.GenForecast(this.initForecastBtn);
|
|
MessageBox.Show("生成年度預估表完成", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
private void importSalesBtn_Click(object sender, EventArgs e)
|
|
{
|
|
var workBook = WorkBookUtils.SelectAndOpenExcelFile();
|
|
|
|
if (workBook == null)
|
|
{
|
|
MessageBox.Show("未選擇文件或者文件無法打開,請重試。", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
|
|
String originLabel = this.importSalesBtn.Text;
|
|
this.importSalesBtn.Text = Resources.GENERATING;
|
|
|
|
try
|
|
{
|
|
WorkBookUtils.ImportSalesDetailFromWorkBook(workBook);
|
|
MessageBox.Show("導入銷售表完成", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
FileLogger.Error($"導入銷售表错误!", ex);
|
|
MessageBox.Show($"導入銷售表過程中發生錯誤:{ex.Message}", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
finally
|
|
{
|
|
workBook.Close(false); // 关闭工作簿
|
|
this.importSalesBtn.Text = originLabel;
|
|
}
|
|
}
|
|
}
|
|
}
|