private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { try { if (comboBox1.SelectedValue != "") { List <DanHao> list = cal.SelectDanHao(comboBox1.Text.ToString()); 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; 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.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; //MessageBox.Show("刷新成功!"); } } catch (Exception ex) { //throw ex; MessageBox.Show(ex.Message); } }
private void PingMingSelect_Load(object sender, EventArgs e) { //List<clsBuiness.DanHao> dh = cal.SelectDanHao(""); List <clsBuiness.DanHao> list = cal.SelectDanHao("").FindAll(d => d.CaiDanNo.Trim().Equals(cdhao)).GroupBy(gp => gp.Name.Trim()).Select(s => s.First()).ToList <DanHao>(); comboBox1.DataSource = list; comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "Id"; }
private void ETD_ETA_LDP_Load(object sender, EventArgs e) { List <clsBuiness.DanHao> danhao = cal.SelectDanHao("").FindAll(f => f.Style.Trim().Contains(style.Trim()) && f.JiaGongChang.Trim().Equals(jiagongchang.Trim()) && f.CaiDanNo.Trim().Equals(caidanhao.Trim())); if (danhao.Count > 0) { textBox6.Text = danhao.Average(d => Convert.ToDouble(d.Jine)).ToString(); textBox7.Text = danhao.Sum(sc => Convert.ToDouble(sc.Jine)).ToString(); textBox16.Text = hs.Sum(s => Convert.ToInt32(s.实际出口数量)).ToString(); } else { MessageBox.Show("生成失败!原因:找不到预计成本/实际成本单!"); this.Close(); return; } }