private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { try { List <int> idtrr = new List <int>(); for (int i = this.dataGridView1.SelectedRows.Count; i > 0; i--) { if (dataGridView1.SelectedRows[i - 1].Cells[0].Value == null || dataGridView1.SelectedRows[i - 1].Cells[0].Value is DBNull) { DataRowView drv = dataGridView1.SelectedRows[i - 1].DataBoundItem as DataRowView; if (drv != null) { drv.Delete(); i = i - 1; } } else { idtrr.Add(Convert.ToInt32(dataGridView1.SelectedRows[i - 1].Cells[0].Value)); } } cal.deleteKucun(idtrr); this.backgroundWorker1.RunWorkerAsync(); JingDu form = new JingDu(this.backgroundWorker1, "删除中");// 显示进度条窗体 form.ShowDialog(this); form.Close(); MessageBox.Show("删除成功!"); bindDatagridview(); //comboBox1_SelectedIndexChanged(sender, e); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btn_Login_Click(object sender, EventArgs e) { try { this.backgroundWorker1.RunWorkerAsync(); // 运行 backgroundWorker 组件 JingDu form = new JingDu(this.backgroundWorker1, "后台验证中"); // 显示进度条窗体 form.ShowDialog(this); form.Close(); bool Loginpd = cals.Login(txt_User.Text.Trim(), txt_pwd.Text.Trim()); if (Loginpd) { MessageBox.Show("登陆成功!"); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show("登录失败!原因:账号或密码错误"); } } catch (Exception ex) { MessageBox.Show("登录失败!原因:找不到账号或密码!"); } }
private void toolStripLabel3_Click(object sender, EventArgs e) { try { DialogResult queren = MessageBox.Show("读取的'EXCEL文件'后缀必须为.Xlsx,否则读取失败!", "系统提示!", MessageBoxButtons.YesNo); if (queren == DialogResult.Yes) { this.backgroundWorker1.RunWorkerAsync(); JingDu form = new JingDu(this.backgroundWorker1, "读取中");// 显示进度条窗体 form.ShowDialog(this); form.Close(); if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { string path = openFileDialog1.FileName; if (!path.Equals(string.Empty)) { if (!File.Exists(path)) { MessageBox.Show("文件不存在!"); return; } IntPtr vHandle = _lopen(path, OF_READWRITE | OF_SHARE_DENY_NONE); if (vHandle == HFILE_ERROR) { MessageBox.Show("文件被占用!"); return; } CloseHandle(vHandle); if (path.Trim().Contains("xlsx")) { List <KuCun> list = cal.readerKucunExcel(path); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (!dataGridView1.Columns[i].HeaderCell.Value.ToString().Equals("Id")) { dt.Columns.Add(dataGridView1.Columns[i].HeaderCell.Value.ToString(), typeof(String)); } } foreach (KuCun s in list) { dt.Rows.Add(s.Id, s.PingMing, s.HuoHao, s.SeHao, s.ShuLiang, s.GongHuoFang, s.CunFangDI); } dataGridView1.DataSource = dt; MessageBox.Show("读取完成!"); } else { MessageBox.Show("读取失败!原因:读取文件后缀非'xlsx'"); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void toolStripLabel4_Click(object sender, EventArgs e) { try { DialogResult queren = MessageBox.Show("读取的'EXCEL文件'后缀必须为.Xlsx,否则读取失败!", "系统提示!", MessageBoxButtons.YesNo); if (queren == DialogResult.Yes) { if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { string path = openFileDialog1.FileName; if (!path.Equals(string.Empty)) { if (!File.Exists(path)) { MessageBox.Show("文件不存在!"); return; } IntPtr vHandle = _lopen(path, OF_READWRITE | OF_SHARE_DENY_NONE); if (vHandle == HFILE_ERROR) { MessageBox.Show("文件被占用!"); return; } CloseHandle(vHandle); if (path.Trim().Contains("xlsx")) { list = cal.readerSehaoExcel(path); this.backgroundWorker1.RunWorkerAsync(); // 运行 backgroundWorker 组件 JingDu form = new JingDu(this.backgroundWorker1, "读取中"); // 显示进度条窗体 form.ShowDialog(this); form.Close(); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(String)); dt.Columns.Add("SeHao1", typeof(String)); foreach (Sehao s in list) { dt.Rows.Add(s.Id, s.Name, s.SeHao1); } dataGridView1.DataSource = dt; MessageBox.Show("读取成功!"); } else { MessageBox.Show("读取失败!原因:读取文件后缀非'xlsx"); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { try { DialogResult dr = MessageBox.Show("确认要删除选中信息吗?", "提示", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { List <int> idtrr = new List <int>(); for (int i = this.dataGridView1.SelectedRows.Count; i > 0; i--) { if (dataGridView1.SelectedRows[i - 1].Cells[0].Value == null || dataGridView1.SelectedRows[i - 1].Cells[0].Value is DBNull) { DataRowView drv = dataGridView1.SelectedRows[i - 1].DataBoundItem as DataRowView; if (drv != null) { drv.Delete(); i = i - 1; } } else { idtrr.Add(Convert.ToInt32(dataGridView1.SelectedRows[i - 1].Cells[0].Value)); } } for (int i = this.dataGridView2.SelectedRows.Count; i > 0; i--) { if (dataGridView2.SelectedRows[i - 1].Cells[0].Value == null || dataGridView2.SelectedRows[i - 1].Cells[0].Value is DBNull) { DataRowView drv = dataGridView2.SelectedRows[i - 1].DataBoundItem as DataRowView; drv.Delete(); i = i - 1; } else { idtrr.Add(Convert.ToInt32(dataGridView2.SelectedRows[i - 1].Cells[0].Value)); } } cal.deleteDanHao(idtrr); this.backgroundWorker1.RunWorkerAsync(); JingDu form = new JingDu(this.backgroundWorker1, "删除中");// 显示进度条窗体 form.ShowDialog(this); form.Close(); MessageBox.Show("删除成功!"); comboBox1_SelectedIndexChanged(sender, e); } } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } }
private void toolStripLabel1_Click(object sender, EventArgs e) { try { this.backgroundWorker1.RunWorkerAsync(); JingDu form = new JingDu(this.backgroundWorker1, "刷新中");// 显示进度条窗体 form.ShowDialog(this); form.Close(); bindDatagridview(); MessageBox.Show("刷新成功!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { if (!txt_ml.Text.Equals(string.Empty) && !txt_ks.Text.Equals(string.Empty) && !cb_jgc.Text.Equals(string.Empty)) { this.backgroundWorker1.RunWorkerAsync(); JingDu form = new JingDu(this.backgroundWorker1, "生成核算表中");// 显示进度条窗体 form.ShowDialog(this); form.Close(); //MianFuLiaoDingGou mfdg = new MianFuLiaoDingGou(txt_ml.Text, txt_ks.Text, cb_jgc.Text, cb_cd.Text); //mfdg.ShowDialog(); this.Close(); } else { MessageBox.Show("生成失败!原因:数据不能为空"); } }
private void toolStripLabel5_Click(object sender, EventArgs e) { try { this.backgroundWorker11.RunWorkerAsync(); // 运行 backgroundWorker 组件 JingDu form = new JingDu(this.backgroundWorker11, "刷新中"); // 显示进度条窗体 form.ShowDialog(this); form.Close(); bindGirdview(); MessageBox.Show("刷新成功"); } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } }
private void toolStripLabel1_Click_1(object sender, EventArgs e) { try { this.backgroundWorker11.RunWorkerAsync(); // 运行 backgroundWorker 组件 JingDu form = new JingDu(this.backgroundWorker11, "提交中"); // 显示进度条窗体 form.ShowDialog(this); form.Close(); DataTable dt = dataGridView2.DataSource as DataTable; if (dt == null) { dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); for (int i = 0; i < dataGridView2.Columns.Count; i++) { if (!dataGridView2.Columns[i].HeaderCell.Value.ToString().Equals("Id")) { dt.Columns.Add(dataGridView2.Columns[i].HeaderCell.Value.ToString(), typeof(String)); } } for (int i = 0; i < dataGridView2.Rows.Count; i++) { if (dataGridView2.Rows[i].Cells[1].Value != null) { dt.Rows.Add(dataGridView2.Rows[i].Cells[0].Value, dataGridView2.Rows[i].Cells[1].Value, dataGridView2.Rows[i].Cells[2].Value, dataGridView2.Rows[i].Cells[3].Value, dataGridView2.Rows[i].Cells[4].Value, dataGridView2.Rows[i].Cells[5].Value, dataGridView2.Rows[i].Cells[6].Value, dataGridView2.Rows[i].Cells[7].Value, dataGridView2.Rows[i].Cells[8].Value, dataGridView2.Rows[i].Cells[9].Value); } } } cal1.insertGongHuoFang(dt); MessageBox.Show("提交成功!"); bindGirdview(); } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } #endregion }
private void toolStripLabel2_Click(object sender, EventArgs e) { try { DataTable dt = dataGridView1.DataSource as DataTable; if (dt == null) { dt = new DataTable(); //dt.Columns.Add("Id", typeof(int)); for (int i = 0; i < dataGridView1.Columns.Count; i++) { //if (!dataGridView1.Columns[i].HeaderCell.Value.ToString().Equals("Id")) //{ dt.Columns.Add(dataGridView1.Columns[i].HeaderCell.Value.ToString(), typeof(String)); //} } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[6].Value != null) { dt.Rows.Add(dataGridView1.Rows[i].Cells[0].Value, dataGridView1.Rows[i].Cells[1].Value, dataGridView1.Rows[i].Cells[2].Value, dataGridView1.Rows[i].Cells[3].Value, dataGridView1.Rows[i].Cells[4].Value, dataGridView1.Rows[i].Cells[5].Value, dataGridView1.Rows[i].Cells[6].Value, dataGridView1.Rows[i].Cells[7].Value, dataGridView1.Rows[i].Cells[8].Value, dataGridView1.Rows[i].Cells[9].Value, dataGridView1.Rows[i].Cells[10].Value, dataGridView1.Rows[i].Cells[11].Value, dataGridView1.Rows[i].Cells[12].Value, dataGridView1.Rows[i].Cells[13].Value, dataGridView1.Rows[i].Cells[14].Value, dataGridView1.Rows[i].Cells[15].Value, dataGridView1.Rows[i].Cells[16].Value, dataGridView1.Rows[i].Cells[17].Value, dataGridView1.Rows[i].Cells[18].Value, dataGridView1.Rows[i].Cells[19].Value, dataGridView1.Rows[i].Cells[20].Value, dataGridView1.Rows[i].Cells[21].Value); } } } this.backgroundWorker1.RunWorkerAsync(); // 运行 backgroundWorker 组件 JingDu form = new JingDu(this.backgroundWorker1, "提交中"); // 显示进度条窗体 form.ShowDialog(this); form.Close(); cal.insertPeise(dt, cb_MianLiao.Text, dateTimePicker1.Text); MessageBox.Show("提交成功!"); string cbtext = cb_MianLiao.Text; PeiSeBiaoLuru_Load(sender, e); cb_MianLiao.Text = cbtext; } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } }
private void toolStripLabel2_Click(object sender, EventArgs e) { try { this.backgroundWorker1.RunWorkerAsync(); JingDu form = new JingDu(this.backgroundWorker1, "提交中");// 显示进度条窗体 form.ShowDialog(this); form.Close(); DataTable dt = dataGridView1.DataSource as DataTable; if (dt == null) { dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (!dataGridView1.Columns[i].HeaderCell.Value.ToString().Equals("Id")) { dt.Columns.Add(dataGridView1.Columns[i].HeaderCell.Value.ToString(), typeof(String)); } } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[1].Value != null) { dt.Rows.Add(dataGridView1.Rows[i].Cells[0].Value, dataGridView1.Rows[i].Cells[1].Value, dataGridView1.Rows[i].Cells[2].Value, dataGridView1.Rows[i].Cells[3].Value, dataGridView1.Rows[i].Cells[4].Value, dataGridView1.Rows[i].Cells[5].Value, dataGridView1.Rows[i].Cells[6].Value); } } } cal.insertKucun(dt); MessageBox.Show("提交成功"); bindDatagridview(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void toolStripLabel2_Click_1(object sender, EventArgs e) { try { this.backgroundWorker1.RunWorkerAsync(); // 运行 backgroundWorker 组件 DataTable dt = dataGridView1.DataSource as DataTable; if (dt == null) { dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(String)); dt.Columns.Add("SeHao1", typeof(String)); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[0].Value != null) { if (!dataGridView1.Rows[i].Cells[0].Value.Equals(string.Empty)) { dt.Rows.Add(dataGridView1.Rows[i].Cells[2].Value, dataGridView1.Rows[i].Cells[1].Value, dataGridView1.Rows[i].Cells[0].Value); } } } } cal.insertSehao(dt); JingDu form = new JingDu(this.backgroundWorker1, "提交中");// 显示进度条窗体 form.ShowDialog(this); form.Close(); MessageBox.Show("提交成功!"); bindDatagridView(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { DialogResult dr = MessageBox.Show("确认要删除 面料号为:'" + cb_MianLiao.Text + "'的单耗表吗?", "提示", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { cal.deletps(cb_MianLiao.Text); this.backgroundWorker1.RunWorkerAsync(); JingDu form = new JingDu(this.backgroundWorker1, "删除中");// 显示进度条窗体 form.ShowDialog(this); form.Close(); MessageBox.Show("删除成功!"); PeiSeBiaoLuru_Load(sender, e); cb_MianLiao.Text = cb_MianLiao.Text; comboBox1_SelectedIndexChanged(sender, e); } } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } }
private void toolStripLabel2_Click(object sender, EventArgs e) { try { DialogResult queren = MessageBox.Show("确认提交?", "系统提示", MessageBoxButtons.YesNo); if (queren == DialogResult.Yes) { DataTable newDataTable = new DataTable(); newDataTable.Columns.Add("Id", typeof(int)); for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (!dataGridView1.Columns[i].HeaderCell.Value.ToString().Equals("Id")) { newDataTable.Columns.Add(dataGridView1.Columns[i].HeaderCell.Value.ToString(), typeof(String)); } } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[6].Value != null) { newDataTable.Rows.Add(dataGridView1.Rows[i].Cells[0].Value, dataGridView1.Rows[i].Cells[1].Value, dataGridView1.Rows[i].Cells[2].Value, dataGridView1.Rows[i].Cells[3].Value, dataGridView1.Rows[i].Cells[4].Value, dataGridView1.Rows[i].Cells[5].Value, dataGridView1.Rows[i].Cells[6].Value, dataGridView1.Rows[i].Cells[7].Value, dataGridView1.Rows[i].Cells[8].Value, dataGridView1.Rows[i].Cells[9].Value, dataGridView1.Rows[i].Cells[10].Value, dataGridView1.Rows[i].Cells[11].Value, dataGridView1.Rows[i].Cells[12].Value, dataGridView1.Rows[i].Cells[13].Value, dataGridView1.Rows[i].Cells[14].Value, dataGridView1.Rows[i].Cells[15].Value, "面料"); } } for (int i = 0; i < dataGridView2.Rows.Count; i++) { if (dataGridView2.Rows[i].Cells[6].Value != null) { newDataTable.Rows.Add(dataGridView2.Rows[i].Cells[0].Value, dataGridView2.Rows[i].Cells[1].Value, dataGridView2.Rows[i].Cells[2].Value, dataGridView2.Rows[i].Cells[3].Value, dataGridView2.Rows[i].Cells[4].Value, dataGridView2.Rows[i].Cells[5].Value, dataGridView2.Rows[i].Cells[6].Value, dataGridView2.Rows[i].Cells[7].Value, dataGridView2.Rows[i].Cells[8].Value, dataGridView2.Rows[i].Cells[9].Value, dataGridView2.Rows[i].Cells[10].Value, dataGridView2.Rows[i].Cells[11].Value, dataGridView2.Rows[i].Cells[12].Value, dataGridView2.Rows[i].Cells[13].Value, dataGridView2.Rows[i].Cells[14].Value, dataGridView2.Rows[i].Cells[15].Value, "辅料"); } } foreach (DataRow dr in newDataTable.Rows) { //if (dr[1] is DBNull || dr[1].Equals(string.Empty)) //{ dr[1] = comboBox1.Text; //} //if (dr[2] is DBNull || dr[2].Equals(string.Empty)) //{ dr[2] = txt_STYLE.Text; //} //if (dr[3] is DBNull || dr[3].Equals(string.Empty)) //{ dr[3] = txt_mfcf.Text; //} //if (dr[4] is DBNull || dr[4].Equals(string.Empty)) //{ dr[4] = dateTimePicker1.Text; //} //if (dr[5] is DBNull || dr[5].Equals(string.Empty)) //{ dr[5] = txt_JGC.Text; //} } this.backgroundWorker1.RunWorkerAsync(); // 运行 backgroundWorker 组件 JingDu form = new JingDu(this.backgroundWorker1, "提交中"); // 显示进度条窗体 form.ShowDialog(this); form.Close(); cal.insertDanhao(newDataTable); MessageBox.Show("提交成功!"); string comboboxtext = comboBox1.Text; DanHaoFrm_Load(sender, e); comboBox1.Text = comboboxtext; } } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } }
private void toolStripLabel3_Click(object sender, EventArgs e) { try { DialogResult queren = MessageBox.Show("读取的'EXCEL文件'后缀必须为.Xlsx,否则读取失败!", "系统提示!", MessageBoxButtons.YesNo); if (queren == DialogResult.Yes) { if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { string path = openFileDialog1.FileName; if (!path.Equals(string.Empty)) { if (!File.Exists(path)) { MessageBox.Show("文件不存在!"); return; } IntPtr vHandle = _lopen(path, OF_READWRITE | OF_SHARE_DENY_NONE); if (vHandle == HFILE_ERROR) { MessageBox.Show("文件被占用!"); return; } CloseHandle(vHandle); if (path.Trim().Contains("xlsx")) { this.backgroundWorker1.RunWorkerAsync(); // 运行 backgroundWorker 组件 JingDu form = new JingDu(this.backgroundWorker1, "读取中"); // 显示进度条窗体 form.ShowDialog(this); form.Close(); List <PeiSe> list = cal.ReaderPeiSe(path); DataTable dt = new DataTable(); if (list[0].Date != null) { string strDate = DateTime.FromOADate(Convert.ToInt32(list[0].Date)).ToString("d"); strDate = DateTime.Parse(strDate).ToString("dd-MMM-yyyy"); dateTimePicker1.Value = Convert.ToDateTime(strDate); } cb_MianLiao.DropDownStyle = ComboBoxStyle.DropDown; cb_MianLiao.Text = list[0].Fabrics; for (int i = 0; i < dataGridView1.Columns.Count; i++) { dt.Columns.Add(dataGridView1.Columns[i].HeaderCell.Value.ToString(), typeof(String)); } foreach (PeiSe s in list) { if (s.PingMing != null) { dt.Rows.Add(s.PingMing, s.HuoHao, s.GuiGe, s.C61601C1, s.C61602C1, s.C61603C1, s.C61605C1, s.C61606C1, s.C61607C1, s.C61609C1, s.C61611C1, s.C61618C1, s.C61624C1, s.C61627C1, s.C61631C1, s.C61632C1, s.C61633C1, s.C61634C1, s.MianLiaoYanSe, s.Id, s.Fabrics, s.Date); } } dataGridView1.DataSource = dt; MessageBox.Show("读取完成!"); } else { MessageBox.Show("读取失败!原因:读取文件后缀非'xlsx'"); } } } } } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } }
private void toolStripLabel3_Click(object sender, EventArgs e) { try { DialogResult queren = MessageBox.Show("读取的'EXCEL文件'后缀必须为.Xlsx,否则读取失败!", "系统提示!", MessageBoxButtons.YesNo); if (queren == DialogResult.Yes) { if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { string path = openFileDialog1.FileName; if (!path.Equals(string.Empty)) { if (!File.Exists(path)) { MessageBox.Show("文件不存在!"); return; } IntPtr vHandle = _lopen(path, OF_READWRITE | OF_SHARE_DENY_NONE); if (vHandle == HFILE_ERROR) { MessageBox.Show("文件被占用!"); return; } CloseHandle(vHandle); if (path.Trim().Contains("xlsx")) { List <DanHao> list = cal.Readerdh(path); this.backgroundWorker1.RunWorkerAsync(); // 运行 backgroundWorker 组件 JingDu form = new JingDu(this.backgroundWorker1, "读取中"); // 显示进度条窗体 form.ShowDialog(this); form.Close(); DataTable dt1 = new DataTable(); dt1.Columns.Add("Id", typeof(int)); DataTable dt2 = new DataTable(); dt2.Columns.Add("Id", typeof(int)); txt_STYLE.Text = list[0].Style; dateTimePicker1.Text = list[0].DATE; txt_mfcf.Text = list[0].FABRIC_CONTENT; txt_JGC.Text = list[0].JiaGongChang; this.comboBox1.DropDownStyle = ComboBoxStyle.DropDown; this.comboBox1.Text = list[0].CaiDanNo; for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (!dataGridView1.Columns[i].HeaderCell.Value.ToString().Equals("Id")) { dt1.Columns.Add(dataGridView1.Columns[i].HeaderCell.Value.ToString(), typeof(String)); dt2.Columns.Add(dataGridView1.Columns[i].HeaderCell.Value.ToString(), typeof(String)); } } foreach (DanHao s in list) { if (s.Type != null) { if (!s.Name.Contains("金额") && !s.Name.Equals("面料") && !s.Name.Contains("辅料") && !s.Name.Equals(string.Empty)) { if (s.Type.Equals("面料")) { dt1.Rows.Add(s.Id, s.CaiDanNo, s.Style, s.FABRIC_CONTENT, s.DATE, s.JiaGongChang, s.Name, s.HuoHao, s.GuiGe, s.Yanse, s.Danjia, s.DanHao1, s.Jine, s.BeiZhu, s.ChangShang, s.Type); } else { dt2.Rows.Add(s.Id, s.CaiDanNo, s.Style, s.FABRIC_CONTENT, s.DATE, s.JiaGongChang, s.Name, s.HuoHao, s.GuiGe, s.Yanse, s.Danjia, s.DanHao1, s.Jine, s.BeiZhu, s.ChangShang, s.Type); } } } } dataGridView1.DataSource = dt1; dataGridView2.DataSource = dt2; Jisuan(); } else { MessageBox.Show("读取失败!原因:读取文件后缀非'xlsx'"); } } } } } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } }
private void toolStripLabel4_Click(object sender, EventArgs e) { { try { DialogResult queren = MessageBox.Show("读取的'EXCEL文件'后缀必须为.Xlsx,否则读取失败!", "系统提示!", MessageBoxButtons.YesNo); if (queren == DialogResult.Yes) { this.backgroundWorker11.RunWorkerAsync(); // 运行 backgroundWorker 组件 JingDu form = new JingDu(this.backgroundWorker11, "提交中"); // 显示进度条窗体 form.ShowDialog(this); form.Close(); if (this.openFileDialog2.ShowDialog() == DialogResult.OK) { string path = openFileDialog2.FileName; if (!path.Equals(string.Empty)) { if (!File.Exists(path)) { MessageBox.Show("文件不存在!"); return; } IntPtr vHandle = _lopen(path, OF_READWRITE | OF_SHARE_DENY_NONE); if (vHandle == HFILE_ERROR) { MessageBox.Show("文件被占用!"); return; } CloseHandle(vHandle); if (path.Trim().Contains("xlsx")) { list2 = cal1.readerGongHuoFangExcel(path); DataTable dt = new DataTable(); dt.Columns.Add("Id22", typeof(int)); dt.Columns.Add("PingMing11", typeof(String)); dt.Columns.Add("HuoHao11", typeof(String)); dt.Columns.Add("Guige11", typeof(String)); dt.Columns.Add("SeHao12", typeof(String)); dt.Columns.Add("Yanse11", typeof(String)); dt.Columns.Add("DanJia11", typeof(String)); dt.Columns.Add("GongHuoFangA11", typeof(String)); dt.Columns.Add("GongHuoFangB11", typeof(String)); dt.Columns.Add("BeiZhu11", typeof(String)); foreach (clsBuiness.GongHuoFang s in list2) { dt.Rows.Add(s.Id, s.PingMing, s.HuoHao, s.Guige, s.SeHao, s.Yanse, s.DanJia, s.GongHuoFangA, s.GongHuoFangB, s.BeiZhu); } dataGridView2.DataSource = dt; MessageBox.Show("读取成功!"); } else { MessageBox.Show("读取失败!原因:读取文件后缀非'xlsx'"); } } } } } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } } }
private void button1_Click(object sender, EventArgs e) { this.backgroundWorker1.RunWorkerAsync(); JingDu frm = new JingDu(this.backgroundWorker1, "生成裁单表中...."); frm.ShowDialog(); frm.Close(); if (insertType.Equals("裁单")) { if (comboBox1.Text.Equals("RGL1")) { CaiDan C = new CaiDan(textBox1.Text, comboBox1.Text, f); if (!C.IsDisposed) { C.TopLevel = true; C.MdiParent = f; C.Show(); } } else if (comboBox1.Text.Equals("RGL2")) { try { CaiDanRGL2 C = new CaiDanRGL2(textBox1.Text, comboBox1.Text, f); if (!C.IsDisposed) { C.TopLevel = true; C.MdiParent = f; C.Show(); } } catch (Exception ex) { MessageBox.Show("异常:422363 " + ex); return; throw; } } else if (comboBox1.Text.Equals("SLIM")) { try { CaidanSLIM C = new CaidanSLIM(textBox1.Text, comboBox1.Text, f); if (!C.IsDisposed) { C.TopLevel = true; C.MdiParent = f; C.Show(); } } catch (Exception ex) { MessageBox.Show("异常:20023 " + ex); return; throw; } } else if (comboBox1.Text.Equals("RGLJ")) { try { CaiDanRGLJ C = new CaiDanRGLJ(textBox1.Text, comboBox1.Text, f); if (!C.IsDisposed) { C.TopLevel = true; C.MdiParent = f; C.Show(); } } catch (Exception ex) { MessageBox.Show("异常:457443 " + ex); return; throw; } } else if (comboBox1.Text.Equals("D.PANT")) { try { frmCaiDanD_PANT C = new frmCaiDanD_PANT(textBox1.Text, comboBox1.Text, f); if (!C.IsDisposed) { C.TopLevel = true; C.MdiParent = f; C.Show(); } } catch (Exception ex) { MessageBox.Show("异常:12314 " + ex); return; throw; } } else if (comboBox1.Text.Equals("C.PANT")) { try { frmCaiDanC C = new frmCaiDanC(textBox1.Text, comboBox1.Text, f); if (!C.IsDisposed) { C.TopLevel = true; C.MdiParent = f; C.Show(); } } catch (Exception ex) { MessageBox.Show("异常:75564 " + ex); return; throw; } } this.Close(); } }