//查询 private void btnSearch_Click(object sender, EventArgs e) { try { this.VisibleWailt(false); listBill = wave.ScanNewBill("ScanNewBill", BillTypes); switch (listBill.Count) { case 0: billNo = ""; break; case 1: billNo = listBill[0]; break; default: SelectDialog selectDialog = new SelectDialog(listBill); if (selectDialog.ShowDialog() == DialogResult.OK) { billNo = selectDialog.SelectedBillID; } break; } this.VisibleWailt(true); RefreshData(); } catch (Exception ex) { THOKUtil.ShowError("读取数据失败,原因:" + ex.Message); this.VisibleWailt(false); return; } }
private void btnRefresh_Click(object sender, EventArgs e) { try { if (bsMain.Filter.Trim().Length != 0) { DialogResult result = MessageBox.Show("重新读入数据请选择'是(Y)',清除过滤条件请选择'否(N)'", "询问", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.No: DataGridViewAutoFilter.DataGridViewAutoFilterTextBoxColumn.RemoveFilter(dgvMain); return; case DialogResult.Cancel: return; } } ShelfCode.Clear(); DataTable dtShelf = cellDal.GetShelf(); for (int i = 0; i < dtShelf.Rows.Count; i++) { ShelfCode.Add(i + 1, dtShelf.Rows[i]["SHELF_CODE"].ToString()); } btnRefresh.Enabled = false; btnChart.Enabled = false; pnlProgress.Top = (pnlMain.Height - pnlProgress.Height) / 3; pnlProgress.Left = (pnlMain.Width - pnlProgress.Width) / 2; pnlProgress.Visible = true; Application.DoEvents(); cellTable = cellDal.GetCell(); bsMain.DataSource = cellTable; pnlProgress.Visible = false; btnRefresh.Enabled = true; btnChart.Enabled = true; } catch (Exception exp) { THOKUtil.ShowInfo("读入数据失败,原因:" + exp.Message); } }
//刷新数据 private void RefreshData() { if (listBill == null) { dgvMain.DataSource = null; return; } sslBillID.Text = "单据号:" + billNo + " "; sslOperator.Text = "操作员:" + Environment.MachineName; this.VisibleWailt(true); DataTable billTable = wave.ImportData(BillString, billNo).Tables["DETAIL"]; InTask = true; if (billTable != null && billTable.Rows.Count != 0) { dgvMain.DataSource = billTable; InTask = false; this.VisibleWailt(false); //double sum = 0; //foreach (DataRow row in billTable.Rows) //{ // sum += double.Parse(row["bb_handle_num"].ToString()); //} //string billType = ""; //switch (BillTypes) //{ // case "1": billType = "上架清单"; break; // case "2": billType = "盘点清单"; break; // case "3": billType = "移位清单"; break; // case "4": billType = "下架清单"; break; // default: billType = "异常单据"; break; //} //THOKUtil.ShowInfo("当前【" + billType + "】订单总数量:" + sum); } else { dgvMain.DataSource = null; InTask = false; this.VisibleWailt(false); THOKUtil.ShowError("当前没有数据!"); } }
//读取RFID private string ScanningRFID(string bb_area_type) { List <string> listRfid = new List <string>(); if (bb_area_type == "0") { this.VisibleWailt(true); try { listRfid = rRfid.LoadTagList(port, 115200, out errInfo); } catch (Exception ex) { this.VisibleWailt(false); THOKUtil.ShowError("扫描RFID失败,请检查串口是否匹配!原因:" + ex.Message + "," + RfidCode); return(null); } Application.DoEvents(); if (listRfid != null) { if (listRfid.Count > 0) { //MessageBox.Show("[" + RfidCode + "]"); RfidCode = listRfid[0].ToString(); return(RfidCode); } else { return(null); } } else { return(null); } } else { return(null); } }
public CellQueryForm() { InitializeComponent(); //设置双缓冲 SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); THOKUtil.EnableFilter(dgvMain); pnlData.Visible = true; pnlData.Dock = DockStyle.Fill; pnlChart.Visible = false; pnlChart.Dock = DockStyle.Fill; pnlChart.MouseWheel += new MouseEventHandler(pnlChart_MouseWheel); }
//确认 private void btnConfirm_Click(object sender, EventArgs e) { string getRFID = ""; if (dgvMain.SelectedRows.Count != 0) { string bb_area_type = dgvMain.Rows[0].Cells["bb_area_type"].Value.ToString(); if (bb_area_type == "0") //0:主储存区,1:零件烟区,2:零条烟区 { getRFID = ScanningRFID(bb_area_type); //读取RFID if (getRFID == null) { THOKUtil.ShowError("操作失败!"); this.VisibleWailt(false); return; } } else if (bb_area_type == "1") { getRFID = ""; } else { THOKUtil.ShowError("浪潮给的<bb_area_type>是:" + bb_area_type + ",注释 0:主储存区,1:零件烟区,2:零条烟区"); this.VisibleWailt(false); return; } try { this.VisibleWailt(true); DataSet ds = GenerateEmptyTables(); foreach (DataGridViewRow row in dgvMain.SelectedRows) { DataRow detailRow = ds.Tables["DETAIL"].NewRow(); //主表信息 detailRow["bb_result_info"] = "0"; detailRow["bb_type"] = BillString; detailRow["bb_order_id"] = row.Cells["bb_order_id"].Value.ToString(); detailRow["bb_pda_device_id"] = Environment.MachineName; detailRow["bb_confirmor_name"] = Environment.MachineName; detailRow["bb_confirm_date"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); detailRow["bb_corporation_id"] = row.Cells["bb_corporation_id"].Value.ToString(); detailRow["bb_corporation_name"] = row.Cells["bb_corporation_name"].Value.ToString(); //细表信息 detailRow["bb_detail_id"] = row.Cells["bb_detail_id"].Value.ToString(); detailRow["bb_operate_type"] = row.Cells["bb_operate_type"].Value.ToString(); detailRow["bb_pallet_move_flg"] = row.Cells["bb_pallet_move_flg"].Value.ToString(); detailRow["bb_cargo_no"] = row.Cells["bb_cargo_no"].Value.ToString(); if (BillTypes == "1") { detailRow["bb_pallet_no"] = getRFID;//此标签改为RFID传入值 } else { detailRow["bb_pallet_no"] = row.Cells["bb_pallet_no"].Value.ToString(); } detailRow["bb_brand_id"] = row.Cells["bb_brand_id"].Value.ToString(); detailRow["bb_brand_name"] = row.Cells["bb_brand_name"].Value.ToString(); detailRow["bb_handle_num"] = Convert.ToDecimal(row.Cells["bb_handle_num"].Value.ToString()); detailRow["bb_inventory_num"] = Convert.ToDecimal(row.Cells["bb_inventory_num"].Value.ToString()); detailRow["bb_unit"] = row.Cells["bb_unit"].Value.ToString(); detailRow["bb_operator_name"] = Environment.UserName; detailRow["bb_operate_date"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ConfirmDialog confirmForm = new ConfirmDialog(BillTypes, row.Cells["bb_cargo_no"].Value.ToString(), row.Cells["bb_cargo_no"].Value.ToString(), row.Cells["bb_operate_type"].Value.ToString(), row.Cells["bb_brand_name"].Value.ToString()); confirmForm.Piece = Convert.ToInt32(row.Cells["bb_handle_num"].Value.ToString()); confirmForm.Bar = 0; if (confirmForm.ShowDialog() == DialogResult.OK) { if (BillTypes == "2") { detailRow["bb_inventory_num"] = confirmForm.Piece; } ds.Tables["DETAIL"].Rows.Add(detailRow); try { if (BillTypes == "1") { wave.confirmData(ds.Tables["DETAIL"], BillTypes); } else { if (getRFID == detailRow["bb_pallet_no"].ToString() || detailRow["bb_pallet_no"].ToString() == "" || detailRow["bb_pallet_no"].ToString() == null) { try { wave.confirmData(ds.Tables["DETAIL"], BillTypes); THOKUtil.ShowInfo("操作完成"); this.RefreshData(); } catch (Exception ex) { THOKUtil.ShowError("操作失败!Catch:" + ex.Message); this.VisibleWailt(false); return; } } else { THOKUtil.ShowError("RFID不匹配!请选择正确的货位,重新出库!"); this.VisibleWailt(false); return; } } } catch (Exception ex) { THOKUtil.ShowError("执行浪潮confirmData失败!原因:" + ex.Message); this.VisibleWailt(false); return; } } else { this.VisibleWailt(false); return; } } this.VisibleWailt(false); } catch (Exception ex) { THOKUtil.ShowError("执行失败,原因:" + ex.Message); this.VisibleWailt(false); return; } } else { THOKUtil.ShowInfo("当前操作失败!原因:没有选择数据,请选择!"); this.VisibleWailt(false); return; } }
private void btnRefresh_Click(object sender, EventArgs e) { try { if (bsMain.Filter.Trim().Length != 0) { DialogResult result = MessageBox.Show("重新读入数据请选择'是(Y)',清除过滤条件请选择'否(N)'", "询问", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.No: DataGridViewAutoFilter.DataGridViewAutoFilterTextBoxColumn.RemoveFilter(dgvMain); return; case DialogResult.Cancel: return; } } btnRefresh.Enabled = false; btnChart.Enabled = false; pnlProgress.Top = (pnlMain.Height - pnlProgress.Height) / 3; pnlProgress.Left = (pnlMain.Width - pnlProgress.Width) / 2; pnlProgress.Visible = true; Application.DoEvents(); url = configUtil.GetConfig("URL")["URL"]; Task task = new Task(url); try { task.Getshelf(); task.GetShelf += new Task.GetShelfEventHandler(delegate(bool isSuccess, string msg, ShelfInfo[] shelfInfo) { if (shelfInfo != null) { //bsMain.DataSource = shelfInfo; cellTable = new DataTable(); cellTable.Columns.Add("ShelfCode"); cellTable.Columns.Add("ShelfName"); cellTable.Columns.Add("CellCode"); cellTable.Columns.Add("CellName"); cellTable.Columns.Add("ProductCode"); cellTable.Columns.Add("ProductName"); cellTable.Columns.Add("QuantityTiao", typeof(decimal)); cellTable.Columns.Add("QuantityJian", typeof(decimal)); cellTable.Columns.Add("WareCode"); cellTable.Columns.Add("WareName"); cellTable.Columns.Add("IsActive"); cellTable.Columns.Add("RowNum"); cellTable.Columns.Add("ColNum"); cellTable.Columns.Add("Shelf"); foreach (ShelfInfo shelf in shelfInfo) { this.ShelfInfo = shelf; DataRow dr = cellTable.NewRow(); dr["ShelfCode"] = shelf.ShelfCode; dr["ShelfName"] = shelf.ShelfName; dr["CellCode"] = shelf.CellCode; dr["CellName"] = shelf.CellName; dr["ProductCode"] = shelf.ProductCode; dr["ProductName"] = shelf.ProductName; dr["QuantityTiao"] = shelf.QuantityTiao; dr["QuantityJian"] = shelf.QuantityJian; dr["WareCode"] = shelf.WareCode; dr["WareName"] = shelf.WareName; dr["IsActive"] = shelf.IsActive; dr["RowNum"] = shelf.RowNum; dr["ColNum"] = shelf.ColNum; dr["Shelf"] = shelf.Shelf; cellTable.Rows.Add(dr); } if (cellTable.Rows.Count > 0) { btnChart.Enabled = true; pnlProgress.Visible = false; btnRefresh.Enabled = true; } bsMain.DataSource = cellTable; } else { bsMain.DataSource = null; } }); } catch (Exception ex) { MessageBox.Show("读取数据失败,原因:" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception exp) { THOKUtil.ShowInfo("读入数据失败,原因:" + exp.Message); } }