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) != DialogResult.Yes) { this.Close(); } } else { MessageBox.Show("请选择要操作的数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 导入变更申请单模板 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem8_ItemClick(object sender, ItemClickEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.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"); dt.Columns.Add("FIELDOLD"); dt.Columns.Add("FIELDNEW"); ChangeAddXtraForm caxf = new ChangeAddXtraForm(); caxf.import = true; caxf.LoadDataByVin(dt.AsDataView()); caxf.Show(); } } catch (Exception ex) { MessageBox.Show("导入失败:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }