private void cboLh_SelectionChangeCommitted(object sender, EventArgs e) { if (PackingBoxService.IsExistsNoGenerateBox()) { if (MetroMessageBox.Show(this, "存在未生成交接单的箱记录,是否继续未生产交接单的箱记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { currentBoxList = PackingBoxService.GetUnGenerateBoxListWithDetail(); grid.Rows.Clear(); //errorCount = 0; if (currentBoxList != null && currentBoxList.Count > 0) { foreach (PBBoxInfo item in currentBoxList) { AddBoxDetailGrid(item); } string lh = currentBoxList.First().LH; currentLh = lh; cboLh.Text = lh; } UpdateBtnDocDetailStatus(); UpdateTotalInfo(); } else { if (string.IsNullOrEmpty(currentLh)) { cboLh.SelectedItem = null; } else { cboLh.Text = currentLh; } } } else { if (grid.Rows.Count > 0) { if (MetroMessageBox.Show(this, "是否删除列表箱记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { List <string> huList = new List <string>(); foreach (DataGridViewRow row in grid.Rows) { if (!huList.Contains((row.Tag as PBBoxInfo).HU)) { huList.Add((row.Tag as PBBoxInfo).HU); } } if (PackingBoxService.DeleteBoxByHu(huList)) { grid.Rows.Clear(); currentBoxList.Clear(); } } } } }
private void button1_Click(object sender, EventArgs e) { List <PBBoxInfo> rowBoxList = new List <PBBoxInfo>(); List <DataGridViewRow> rows = GetCheckedRows(); if (rows != null && rows.Count > 0) { foreach (DataGridViewRow row in rows) { PBBoxInfo box = row.Tag as PBBoxInfo; if (box != null) { if (!rowBoxList.Exists(r => r.HU == box.HU)) { rowBoxList.Add(box); } } } } if (rowBoxList.Count > 0) { if (MetroMessageBox.Show(this, "确认清除列表中箱记录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { if (PackingBoxService.DeleteBoxByHu(rowBoxList.Select(i => i.HU).Distinct().ToList())) { MetroMessageBox.Show(this, "清除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; currentBoxList.RemoveAll(i => rowBoxList.Exists(j => j.HU == i.HU)); updateGrid(); } else { MetroMessageBox.Show(this, "清除失败,可能是网络不稳定,请稍候再试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } //清除提示 //if (boxList != null && boxList.Count > 0) //{ // if (MetroMessageBox.Show(this, "确认清除列表中所有箱记录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) // { // if (PackingBoxService.DeleteBoxByHu(boxList.Select(i => i.HU).Distinct().ToList())) // { // MetroMessageBox.Show(this, "清除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // DialogResult = DialogResult.OK; // Close(); // } // else // { // MetroMessageBox.Show(this, "清除失败,可能是网络不稳定,请稍候再试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // } // } //} }
private void metroButton1_del_Click(object sender, EventArgs e) { try { if (metroTextBox1_hu.Text.Trim() == "") { MessageBox.Show("请输入箱号"); return; } string hu = metroTextBox1_hu.Text.Trim(); List <string> hus = new List <string>(); hus.Add(hu); if (PackingBoxService.DeleteBoxByHu(hus)) { MessageBox.Show("操作成功"); } } catch (Exception) { } }