using DBFactory; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace wcfControlMonitorClient { public partial class FrmAGVTask : Form {//20151120 DBOperator dbo = CStaticClass.dbo; private static FrmAGVTask _formInstance; public static FrmAGVTask FormInstance { get { if (_formInstance == null) { _formInstance = new FrmAGVTask(); } return _formInstance; } set { _formInstance = value; } } public FrmAGVTask() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { button_Refresh_Click(null, EventArgs.Empty); } private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { if ((e.ColumnIndex >= 0) && (e.RowIndex >= 0) && (e.Button == MouseButtons.Right)) { dataGridView1.ClearSelection(); dataGridView1.Rows[e.RowIndex].Selected = true; dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]; } } private void tsmEdit_Click(object sender, EventArgs e) { if (dataGridView1.RowCount <= 0) { return; } this.tbUserID.Text = this.dataGridView1.CurrentRow.Cells["调度任务号"].Value.ToString() + ""; this.tbMaxCount.Text = this.dataGridView1.CurrentRow.Cells["任务状态"].Value.ToString() + ""; //this.tbExeMaxCount.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString() + ""; } private void btSave_Click(object sender, EventArgs e) { try { if (tbUserID.Text == "") { MessageBox.Show("请先选定要修改的记录!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("确定调度任务号" + tbUserID.Text + ",报告完成???", "", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { string sql = string.Format("update AGV_TASK set AGV_TASK_STATUS = 5 where FID = {0}", tbUserID.Text); int i_ret = dbo.ExecuteSql(sql); if (i_ret == 1) { MessageBox.Show("保存成功!", "操作提示:"); button_Refresh_Click(null, EventArgs.Empty); } else { MessageBox.Show("保存失败!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (Exception ex) { throw ex; } } private void FrmAGVTask_FormClosing(object sender, FormClosingEventArgs e) { _formInstance = null; } private void button_Refresh_Click(object sender, EventArgs e) { string CommomSql = "select FID as 调度任务号, AGV_TASK_ID as AGV任务号, PALLET_BARCODE as 托盘信息,START_DEVICE_CODE as 起点,FINISH_DEVICE_CODE as 终点,AGV_TASK_STATUS as 任务状态,AGV_CODE as 车号,INSERT_TIME as 任务时间,TASKTYPE as 任务类型,MIDDLE as 中间点 from AGV_TASK"; DataView dv = dbo.ExceSQL(CommomSql).Tables[0].DefaultView; this.dataGridView1.DataSource = dv; } private void BtDel_Click(object sender, EventArgs e) { try { if (tbUserID.Text == "") { MessageBox.Show("请先选定要删除的记录!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.tbMaxCount.Text == "5") { if (MessageBox.Show("确定删除调度任务号" + tbUserID.Text + "???", "", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { string sql = $"delete from AGV_TASK where AGV_TASK_STATUS = 5 and FID = {tbUserID.Text};"; int i_ret = dbo.ExecuteSql(sql); if (i_ret >= 1) { MessageBox.Show("删除成功!", "操作提示:"); button_Refresh_Click(null, EventArgs.Empty); } else { MessageBox.Show("删除失败!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } else { MessageBox.Show("删除调度任务号" + tbUserID.Text + ",未完成,请先报告完成。。。", "操作提示:"); } } catch (Exception ex) { throw ex; } } } }