private void CreateExcel(string path) { DataTable dt = new DataTable(); clsBuiness.CaiDan_D_PANT cd = new clsBuiness.CaiDan_D_PANT(); cd.STYLE = txt_Style.Text; cd.LABEL = txt_Label.Text; cd.DESC = this.txt_desc.Text; cd.FABRIC = this.txt_fabric.Text; cd.Jacket = this.txt_jacket.Text; cd.Pant = this.txt_pant.Text; cd.shuoming = this.txt_shuoming.Text; cd.JiaGongchang = this.cb_jgc.Text; cd.MianLiao = this.txt_mianlioa.Text; cd.CaiDanHao = this.txt_CaidanNo.Text; cd.ZhiDanRiqi = this.txt_zhidan.Text; cd.JiaoHuoRiqi = this.txt_jiaohuo.Text; cd.RN_NO = this.txt_RN.Text; for (int i = 0; i < headerUnitView1.Columns.Count; i++) { dt.Columns.Add(headerUnitView1.Columns[i].HeaderCell.Value.ToString(), typeof(String)); } for (int i = 0; i < headerUnitView1.Rows.Count; i++) { if (headerUnitView1.Rows[i].Cells[0].Value != null && headerUnitView1.Rows[i].Cells[0].Value.ToString() != "") { dt.Rows.Add(headerUnitView1.Rows[i].Cells[0].Value, headerUnitView1.Rows[i].Cells[1].Value, headerUnitView1.Rows[i].Cells[2].Value, headerUnitView1.Rows[i].Cells[3].Value, headerUnitView1.Rows[i].Cells[4].Value, headerUnitView1.Rows[i].Cells[5].Value, headerUnitView1.Rows[i].Cells[6].Value, headerUnitView1.Rows[i].Cells[7].Value, headerUnitView1.Rows[i].Cells[8].Value, headerUnitView1.Rows[i].Cells[9].Value, headerUnitView1.Rows[i].Cells[10].Value, headerUnitView1.Rows[i].Cells[11].Value, headerUnitView1.Rows[i].Cells[12].Value, headerUnitView1.Rows[i].Cells[13].Value, headerUnitView1.Rows[i].Cells[14].Value, headerUnitView1.Rows[i].Cells[15].Value, headerUnitView1.Rows[i].Cells[16].Value, headerUnitView1.Rows[i].Cells[17].Value, headerUnitView1.Rows[i].Cells[18].Value, headerUnitView1.Rows[i].Cells[19].Value, headerUnitView1.Rows[i].Cells[20].Value, headerUnitView1.Rows[i].Cells[21].Value, headerUnitView1.Rows[i].Cells[22].Value, headerUnitView1.Rows[i].Cells[23].Value, headerUnitView1.Rows[i].Cells[24].Value, headerUnitView1.Rows[i].Cells[25].Value, headerUnitView1.Rows[i].Cells[26].Value, headerUnitView1.Rows[i].Cells[27].Value, headerUnitView1.Rows[i].Cells[28].Value, headerUnitView1.Rows[i].Cells[29].Value, headerUnitView1.Rows[i].Cells[30].Value, headerUnitView1.Rows[i].Cells[31].Value, headerUnitView1.Rows[i].Cells[32].Value, headerUnitView1.Rows[i].Cells[33].Value, headerUnitView1.Rows[i].Cells[34].Value, headerUnitView1.Rows[i].Cells[35].Value, headerUnitView1.Rows[i].Cells[36].Value, headerUnitView1.Rows[i].Cells[37].Value, headerUnitView1.Rows[i].Cells[38].Value, headerUnitView1.Rows[i].Cells[39].Value, headerUnitView1.Rows[i].Cells[40].Value, headerUnitView1.Rows[i].Cells[41].Value, headerUnitView1.Rows[i].Cells[42].Value); } } //cal.InsertChima5(dt, "D.PANT"); gn2.CDEXCELD_PANT(dt, cd, path); foldPath = path + "\\裁单表-" + cd.CaiDanHao + ".xls"; }
private void frmCaiDanD_PANT_Load(object sender, EventArgs e) { headerUnitView1.CellValueChanged -= headerUnitView1_CellValueChanged; txt_Style.Text = StyleId; txt_Label.Text = chima; this.txt_desc.Text = cd[0].DESC.ToString(); this.txt_fabric.Text = cd[0].FABRIC.ToString(); this.txt_jacket.Text = cd[0].Jacket.ToString(); this.txt_pant.Text = cd[0].Pant.ToString(); this.txt_shuoming.Text = cd[0].shuoming.ToString(); cb_jgc.DataSource = jgc; cb_jgc.DisplayMember = "Name"; cb_jgc.ValueMember = "id"; txt_zhidan.Text = DateTime.Now.ToString(); List <clsBuiness.CaiDan_D_PANT> caidan = gn2.selectCaiDanD_PANT("").GroupBy(g => g.CaiDanHao).Select(s => s.First()).ToList <clsBuiness.CaiDan_D_PANT>(); clsBuiness.CaiDan_D_PANT c = new clsBuiness.CaiDan_D_PANT() { CaiDanHao = " " }; caidan.Add(c); txt_CaidanNo.SelectedIndexChanged -= txt_CaidanNo_SelectedIndexChanged; txt_CaidanNo.DataSource = caidan; txt_CaidanNo.DisplayMember = "CaiDanHao"; txt_CaidanNo.ValueMember = "id"; txt_CaidanNo.SelectedIndexChanged += txt_CaidanNo_SelectedIndexChanged; if (txt_CaidanNo.FindString(" ") >= 0) { txt_CaidanNo.SelectedIndex = txt_CaidanNo.FindString(" "); } headerUnitView1.CellValueChanged += headerUnitView1_CellValueChanged; }