//添加 private void simpleButton4_Click(object sender, EventArgs e) { DataView dv = GetCheckData(); if (dv != null && dv.Table.Rows.Count > 0) { ChangeAddXtraForm caxf = (ChangeAddXtraForm)this.Owner; caxf.LoadDataByVin(dv); if (MessageBox.Show("添加成功,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { this.Close(); } } else { MessageBox.Show("请选择要操作的数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void barButtonItem8_ItemClick(object sender, ItemClickEventArgs e) { OpenFileDialog ofd = new OpenFileDialog() { Filter = "Excel|*.xls;*.xlsx|All Files|*.*" }; if (ofd.ShowDialog() == DialogResult.OK) { try { MitsUtils miutils = new MitsUtils(); DataSet ds = miutils.ReadExcel(ofd.FileName, "Sheet1"); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { var dt = ds.Tables[0]; dt.Columns["备案号(VIN)"].ColumnName = "VIN"; dt.Columns["车辆型号"].ColumnName = "CLXH"; dt.Columns["通用名称"].ColumnName = "TYMC"; dt.Columns["燃料种类"].ColumnName = "RLLX"; dt.Columns["综合工况燃料消耗量"].ColumnName = "CT_ZHGKRLXHL"; dt.Columns["整车整备质量"].ColumnName = "ZCZBZL"; dt.Columns["变速器型式"].ColumnName = "CT_BSQXS"; dt.Columns["座位排数"].ColumnName = "ZWPS"; dt.Columns["操作类型"].ColumnName = "APPLYTYPE"; dt.Columns.Add("UPDATEFIELD", System.Type.GetType("System.String")); dt.Columns.Add("FIELDOLD", System.Type.GetType("System.String")); dt.Columns.Add("FIELDNEW", System.Type.GetType("System.String")); dt.Columns.Add("DID", System.Type.GetType("System.String")); dt.Columns["DID"].SetOrdinal(0); dt.Columns["APPLYTYPE"].SetOrdinal(12); ChangeAddXtraForm caxf = new ChangeAddXtraForm(); caxf.import = true; caxf.LoadDataByVin(dt.AsDataView()); caxf.Show(); } } catch (Exception ex) { MessageBox.Show("导入失败:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }