private void 其他資產_Click(object sender, EventArgs e) { DataTable Dt = new DataTable(); Ad = new SqlDataAdapter("SELECT TOP 1 FDWG,FCDS,FSIZ,FSMT FROM BUGDA_ITEM ", GonGinVariable.SqlConnectString); Ad.SelectCommand.CommandType = CommandType.Text; Ad.SelectCommand.CommandTimeout = 600; Ad.SelectCommand.Parameters.Clear(); Dt.Clear(); Ad.Fill(Dt); string 判斷 = "其他"; 資產視窗 form = new 資產視窗(Dt, 判斷); if (form.ShowDialog() == DialogResult.Yes) { foreach (DataRow item in form.品項明細.Rows) { Dt_品項.ImportRow(item); } } }
private void 確定_Click(object sender, EventArgs e) { Dt.AcceptChanges(); if (Dt.Rows.Count == 0) { MessageBox.Show("無資料可帶入!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } 品項明細 = new DataTable(); //品項明細.Columns.Add("UID", typeof(String)); 品項明細.Columns.Add("FDWG", typeof(String)); 品項明細.Columns.Add("FCDS", typeof(String)); 品項明細.Columns.Add("FSIZ", typeof(String)); 品項明細.Columns.Add("FSMT", typeof(decimal)); //品項明細.Columns.Add("BGDEP", typeof(String)); //品項明細.Columns.Add("BGYM", typeof(String)); //品項明細.Columns.Add("BUGNO", typeof(String)); //品項明細.Columns.Add("BGTYPE", typeof(String)); DataTable AA = Dt.Select("SEL").CopyToDataTable(); int i = 0; foreach (DataRow item in AA.Rows) { 品項明細.Rows.Add(); 品項明細.Rows[i]["FDWG"] = item["FDWG"]; 品項明細.Rows[i]["FCDS"] = item["FCDS"]; 品項明細.Rows[i]["FSIZ"] = item["FSIZ"]; 品項明細.Rows[i]["FSMT"] = item["FSMT"]; i++; } int 資產 = 0; foreach (DataRow item in 品項明細.Rows) { if (item["FDWG"].ToString() == "其它設備") { 資產++; } } if (資產 > 0) { DataTable BB = 品項明細.Select("FDWG = '其它設備'").CopyToDataTable(); 資產視窗 pop = new 資產視窗(BB, "無"); if (pop.ShowDialog() == DialogResult.Yes) { foreach (DataRow item in pop.品項明細.Rows) { 品項明細.ImportRow(item); } } 品項明細.AcceptChanges(); int j = 0; foreach (DataRow item in 品項明細.Rows) { if (item["FDWG"].ToString() == "其它設備") { item.Delete(); } j++; } } 品項明細.AcceptChanges(); this.DialogResult = DialogResult.Yes; Close(); }