//确定挑选 private void btnComfirm_Click(object sender, EventArgs e) { PmIds = string.Empty; BaseView ViewType = gridCMain.MainView; if (ViewType.GetType().ToString() == "DevExpress.XtraGrid.Views.Grid.GridView") { GridView grid = ViewType as GridView; for (int i = 0; i < grid.RowCount; i++) { if (grid.GetDataRow(i)["Checked"].ToString() == "True") { PmIds += grid.GetDataRow(i)["PM_Id"].ToString() + ","; } } } if (ViewType.GetType().ToString() == "DevExpress.XtraGrid.Views.Layout.LayoutView") { LayoutView layout = ViewType as LayoutView; for (int i = 0; i < layout.RowCount; i++) { if (layout.GetDataRow(i)["Checked"].ToString() == "True") { PmIds += layout.GetDataRow(i)["PM_Id"].ToString() + ","; } } } if (ViewType.GetType().ToString() == "DevExpress.XtraGrid.Views.Card.CardView") { CardView cardView1 = ViewType as CardView; for (int i = 0; i < cardView1.RowCount; i++) { if (cardView1.GetDataRow(i)["Checked"].ToString() == "True") { PmIds += cardView1.GetDataRow(i)["PM_Id"].ToString() + ","; } } } //if (PmIds.TrimEnd(',').Split(',').Length == 1 && PmIds.Trim().Length > 0) //{ // DataTable dtOne = dt.Select("PM_Id = '" + PmIds.TrimEnd(',') + "' AND Fy_Id='" + dplFy.EditValue.ToString().Trim() + "' ").CopyToDataTable(); // frmSelectProdOne frmOne = new frmSelectProdOne(dsLoad.Tables[1], dtOne, PmIds.TrimEnd(',')); // if (frmOne.ShowDialog() == DialogResult.OK) // { // if (frmOne.IsSelect == true) // { // dtProd.Rows.Remove(dtProd.Select("PM_Id = '" + PmIds.TrimEnd(',') + "' ")[0]); // gridCMain.DataSource = dtProd; // } // } //} //else //{ //自动生成营销款号插入数据库 if (PmIds == string.Empty) { MessageBox.Show("请先选择款式"); return; } frmSelectProdMany frmMany = new frmSelectProdMany(dt, PmIds); if (frmMany.ShowDialog() == DialogResult.OK) { if (frmMany.IsSelect == true) { string[] pmPmIds = PmIds.TrimEnd(',').Split(','); for (int i = 0; i < pmPmIds.Length; i++) { dtProd.Rows.Remove(dtProd.Select("PM_Id = '" + pmPmIds[i].ToString() + "' ")[0]); } gridCMain.DataSource = dtProd; } this.grpPic.Controls.Clear(); x = 10; y = 25; path = string.Empty; } //} }
private void btnComfirm_Click(object sender, EventArgs e) { ids = string.Empty; BaseView ViewType = gridCMain.MainView; if (ViewType.GetType().ToString() == "DevExpress.XtraGrid.Views.Grid.GridView") { GridView grid = ViewType as GridView; for (int i = 0; i < grid.RowCount; i++) { if (grid.GetDataRow(i)["Checked"].ToString() == "True") { ids += grid.GetDataRow(i)["PM_Id"].ToString() + ","; } } } if (ViewType.GetType().ToString() == "DevExpress.XtraGrid.Views.Layout.LayoutView") { LayoutView layout = ViewType as LayoutView; for (int i = 0; i < layout.RowCount; i++) { if (layout.GetDataRow(i)["Checked"].ToString() == "True") { ids += layout.GetDataRow(i)["PM_Id"].ToString() + ","; } } } if (ViewType.GetType().ToString() == "DevExpress.XtraGrid.Views.Card.CardView") { CardView cardView1 = ViewType as CardView; for (int i = 0; i < cardView1.RowCount; i++) { if (cardView1.GetDataRow(i)["Checked"].ToString() == "True") { ids += cardView1.GetDataRow(i)["PM_Id"].ToString() + ","; } } } // MessageBox.Show("选中了" + ids.TrimEnd(',')); if (ids.TrimEnd(',').Split(',').Length == 1 && ids.Trim().Length > 0) { DataTable dtOne = dt.Select("PM_Id = '" + ids.TrimEnd(',') + "' AND Fy_Id='" + dplFy.EditValue.ToString().Trim() + "' ").CopyToDataTable(); frmSelectProdOne frmOne = new frmSelectProdOne(dsLoad.Tables[1], dtOne, ids.TrimEnd(',')); if (frmOne.ShowDialog() == DialogResult.OK) { if (frmOne.IsSelect == true) { dtProd.Rows.Remove(dtProd.Select("PM_Id = '" + ids.TrimEnd(',') + "' ")[0]); gridCMain.DataSource = dtProd; } } } else { //自动生成营销款号插入数据库 frmSelectProdMany frmMany = new frmSelectProdMany(dt, ids); if (frmMany.ShowDialog() == DialogResult.OK) { if (frmMany.IsSelect == true) { string[] pmids = ids.TrimEnd(',').Split(','); for (int i = 0; i < pmids.Length; i++) { dtProd.Rows.Remove(dtProd.Select("PM_Id = '" + pmids[i].ToString() + "' ")[0]); } gridCMain.DataSource = dtProd; } } } }