Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

有很多空行

  • Loading branch information...
commit 821141c7be3bca51d0f090a66f09e0a7cd8b8a4b 1 parent aba302f
Advansil authored
View
4 ExcelApplication/ExcelApplication/ExcelApplication.csproj
@@ -98,7 +98,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
- <None Include="app.config" />
+ <None Include="app.config">
+ <SubType>Designer</SubType>
+ </None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
View
13 ExcelApplication/ExcelApplication/Form1.Designer.cs
@@ -120,7 +120,7 @@ private void InitializeComponent()
// removeColumnToolStripMenuItem
//
this.removeColumnToolStripMenuItem.Name = "removeColumnToolStripMenuItem";
- this.removeColumnToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.removeColumnToolStripMenuItem.Size = new System.Drawing.Size(106, 22);
this.removeColumnToolStripMenuItem.Text = "整理列";
this.removeColumnToolStripMenuItem.Click += new System.EventHandler(this.removeColumnToolStripMenuItem_Click);
//
@@ -132,34 +132,34 @@ private void InitializeComponent()
this.cuttingToolStripMenuItem,
this.cutNOToolStripMenuItem});
this.statisticsToolStripMenuItem.Name = "statisticsToolStripMenuItem";
- this.statisticsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.statisticsToolStripMenuItem.Size = new System.Drawing.Size(106, 22);
this.statisticsToolStripMenuItem.Text = "统计";
//
// dateToolStripMenuItem
//
this.dateToolStripMenuItem.Name = "dateToolStripMenuItem";
- this.dateToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.dateToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
this.dateToolStripMenuItem.Text = "按日期";
this.dateToolStripMenuItem.Click += new System.EventHandler(this.dateToolStripMenuItem_Click);
//
// ingotToolStripMenuItem
//
this.ingotToolStripMenuItem.Name = "ingotToolStripMenuItem";
- this.ingotToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.ingotToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
this.ingotToolStripMenuItem.Text = "按铸锭编号";
this.ingotToolStripMenuItem.Click += new System.EventHandler(this.ingotToolStripMenuItem_Click);
//
// cuttingToolStripMenuItem
//
this.cuttingToolStripMenuItem.Name = "cuttingToolStripMenuItem";
- this.cuttingToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.cuttingToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
this.cuttingToolStripMenuItem.Text = "按切割号";
this.cuttingToolStripMenuItem.Click += new System.EventHandler(this.cuttingToolStripMenuItem_Click);
//
// cutNOToolStripMenuItem
//
this.cutNOToolStripMenuItem.Name = "cutNOToolStripMenuItem";
- this.cutNOToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.cutNOToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
this.cutNOToolStripMenuItem.Text = "按机器号";
this.cutNOToolStripMenuItem.Click += new System.EventHandler(this.cutNOToolStripMenuItem_Click);
//
@@ -254,7 +254,6 @@ private void InitializeComponent()
// btnLoadData
//
this.btnLoadData.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.btnLoadData.Enabled = false;
this.btnLoadData.Location = new System.Drawing.Point(722, 441);
this.btnLoadData.Name = "btnLoadData";
this.btnLoadData.Size = new System.Drawing.Size(75, 23);
View
126 ExcelApplication/ExcelApplication/Form1.cs
@@ -18,70 +18,77 @@ public bool dataTotal(int col)
{
try
{
- dataGridView1.Sort(dataGridView1.Columns[col], ListSortDirection.Ascending);
+ #region ingotTool
+ if (col == 2)
+ {
+ dataGridView1.Sort(dataGridView1.Columns[col], ListSortDirection.Ascending);
- int columnCount = dataGridView1.ColumnCount;
- int rowCount = dataGridView1.RowCount;
+ int columnCount = dataGridView1.ColumnCount;
+ int rowCount = dataGridView1.RowCount;
- string tempA = (string)dataGridView1.Rows[rowCount - 2].Cells[col].Value;
- string tempB;
- int total = 0;
- for (int i = rowCount - 3; i >= 0; i--)
- {
- tempB = (string)dataGridView1.Rows[i].Cells[col].Value;
- if (tempA.GetHashCode() == tempB.GetHashCode())
+ string tempA = (string)dataGridView1.Rows[rowCount - 2].Cells[col].Value;
+ string tempB;
+ int total = 0;
+ for (int i = rowCount - 3; i >= 0; i--)
{
- for (int j = 6; j < 12; j ++)
+ tempB = (string)dataGridView1.Rows[i].Cells[col].Value;
+ if (tempA.GetHashCode() == tempB.GetHashCode())
{
- if (j == 7) continue;
- total = int.Parse(dataGridView1.Rows[i].Cells[j].Value.ToString()) + int.Parse(dataGridView1.Rows[i + 1].Cells[j].Value.ToString());
- dataGridView1.Rows[i].Cells[j].Value = total.ToString();
+ for (int j = 6; j < 12; j++)
+ {
+ if (j == 7) continue;
+ total = int.Parse(dataGridView1.Rows[i].Cells[j].Value.ToString()) + int.Parse(dataGridView1.Rows[i + 1].Cells[j].Value.ToString());
+ dataGridView1.Rows[i].Cells[j].Value = total.ToString();
+ }
+ for (int j = 12; j < columnCount; j += 2)
+ {
+ total = int.Parse(dataGridView1.Rows[i].Cells[j].Value.ToString()) + int.Parse(dataGridView1.Rows[i + 1].Cells[j].Value.ToString());
+ dataGridView1.Rows[i].Cells[j].Value = total.ToString();
+ }
+ dataGridView1.Rows.RemoveAt(i + 1);
}
- for (int j = 12; j < columnCount; j += 2)
+ else
{
- total = int.Parse(dataGridView1.Rows[i].Cells[j].Value.ToString()) + int.Parse(dataGridView1.Rows[i + 1].Cells[j].Value.ToString());
- dataGridView1.Rows[i].Cells[j].Value = total.ToString();
+ tempA = tempB;
}
- dataGridView1.Rows.RemoveAt(i + 1);
}
- else
- {
- tempA = tempB;
- }
- }
-
- columnCount = dataGridView1.ColumnCount;
- rowCount = dataGridView1.RowCount;
- for (int j = 0; j < rowCount - 1; j++)
- {
- int tempD = int.Parse(dataGridView1.Rows[j].Cells[6].Value.ToString());
- int tempC = int.Parse(dataGridView1.Rows[j].Cells[12].Value.ToString());
- if (tempD == 0)
- dataGridView1.Rows[j].Cells[13].Value = "0";
- else
- dataGridView1.Rows[j].Cells[13].Value = (tempC * 10000 / tempD / 100.0).ToString();
- }
+ columnCount = dataGridView1.ColumnCount;
+ rowCount = dataGridView1.RowCount;
- for (int i = 15; i < 50; i += 2)
- {
for (int j = 0; j < rowCount - 1; j++)
{
- int tempD = int.Parse(dataGridView1.Rows[j].Cells[9].Value.ToString());
- int tempC = int.Parse(dataGridView1.Rows[j].Cells[i - 1].Value.ToString());
+ int tempD = int.Parse(dataGridView1.Rows[j].Cells[6].Value.ToString());
+ int tempC = int.Parse(dataGridView1.Rows[j].Cells[12].Value.ToString());
if (tempD == 0)
- dataGridView1.Rows[j].Cells[i].Value = "0";
+ dataGridView1.Rows[j].Cells[13].Value = "0";
else
- dataGridView1.Rows[j].Cells[i].Value = (tempC * 10000 / tempD / 100.0).ToString();
+ dataGridView1.Rows[j].Cells[13].Value = (tempC * 10000 / tempD / 100.0).ToString();
+ }
+
+ for (int i = 15; i < 50; i += 2)
+ {
+ for (int j = 0; j < rowCount - 1; j++)
+ {
+ int tempD = int.Parse(dataGridView1.Rows[j].Cells[9].Value.ToString());
+ int tempC = int.Parse(dataGridView1.Rows[j].Cells[i - 1].Value.ToString());
+ if (tempD == 0)
+ dataGridView1.Rows[j].Cells[i].Value = "0";
+ else
+ dataGridView1.Rows[j].Cells[i].Value = (tempC * 10000 / tempD / 100.0).ToString();
+ }
}
+ return true;
}
+ #endregion
+
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
- return true;
+ return false;
}
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
@@ -108,7 +115,6 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
if (!tmp.Open())
MessageBox.Show("File Not Found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
comboBox1.DataSource = tmp.GetWorkSheets();
- btnLoadData.Enabled = true;
}
private void calculatorToolStripMenuItem_Click(object sender, EventArgs e)
@@ -163,13 +169,20 @@ private void btnLoadData_Click(object sender, EventArgs e)
}
tmp.Close();
+
+ string[] rowValue = new string[rowCount];
+ for (int i = 0; i < rowCount - 1; i++)
+ {
+ rowValue[i] = (string)dataGridView1.Rows[i].Cells[1].Value;
+ rowValue[i] = rowValue[i].TrimStart('M');
+ dataGridView1.Rows[i].Cells[2].Value = (rowValue[i].Length > 6) ? rowValue[i].Substring(0, 6) : rowValue[i];
+ }
+ dataGridView1.Columns[2].HeaderCell.Value = "铸锭编号";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
- txtPath.Text = "";
- comboBox1.DataSource = null;
btnLoadData.Enabled = false;
}
@@ -180,7 +193,6 @@ private void codeToolStripMenuItem_Click(object sender, EventArgs e)
private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
{
- btnLoadData.Enabled = false;
try
{
ExcelLib.IExcel tmp = ExcelLib.PreExcel.GetExcel(txtPath.Text);
@@ -217,8 +229,6 @@ private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
if (tmp.Save(sheetName, array))
MessageBox.Show("File Save Success!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
tmp.Close();
- txtPath.Text = "";
- comboBox1.DataSource = null;
}
catch (Exception ex)
{
@@ -241,8 +251,7 @@ private void removeColumnToolStripMenuItem_Click(object sender, EventArgs e)
{
int columnCount = dataGridView1.ColumnCount;
int rowCount = dataGridView1.RowCount;
- string[] rowValue = new string[rowCount];
-
+
if (columnCount > 50)
{
for (int i = columnCount - 1; i > 49; i--)
@@ -250,13 +259,15 @@ private void removeColumnToolStripMenuItem_Click(object sender, EventArgs e)
dataGridView1.Columns.RemoveAt(i);
}
- for (int i = 0; i < rowCount - 1; i++)
- {
- rowValue[i] = (string)dataGridView1.Rows[i].Cells[1].Value;
- rowValue[i] = rowValue[i].TrimStart('M');
- dataGridView1.Rows[i].Cells[2].Value = (rowValue[i].Length > 6) ? rowValue[i].Substring(0, 6) : rowValue[i];
- }
- dataGridView1.Columns[2].HeaderCell.Value = "铸锭编号";
+ //for (int j = rowCount - 1; j >0; j--)
+ //{
+ //if (string.IsNullOrEmpty(dataGridView1.Rows[rowCount - 1].Cells[1].Value.ToString()))
+ // dataGridView1.Rows.RemoveAt(rowCount - 1);
+ //}
+
+ columnCount = dataGridView1.ColumnCount;
+ rowCount = dataGridView1.RowCount;
+ string[] rowValue = new string[rowCount];
for (int j = 0; j < rowCount-1; j++)
{
@@ -281,7 +292,6 @@ private void removeColumnToolStripMenuItem_Click(object sender, EventArgs e)
}
}
}
-
MessageBox.Show("Records Delete And Sort Success!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Please sign in to comment.
Something went wrong with that request. Please try again.