public object[] queryDataStsSerialPort(STS_SERIAL_PORT param) { log.Info("Start log INFO... queryDataStsSerialPort"); MsgForm msgError = new MsgForm(); STS_SERIAL_PORT form = new STS_SERIAL_PORT(); try { using (var db = new PaknampoScaleDBEntities()) { form = (from row in db.STS_SERIAL_PORT where row.SERIAL_PORT_ID == param.SERIAL_PORT_ID select row).FirstOrDefault(); db.Dispose(); msgError.statusFlag = MsgForm.STATUS_SUCCESS; } } catch (Exception ex) { log.Error(ex.ToString(), ex); msgError.statusFlag = MsgForm.STATUS_ERROR; msgError.messageDescription = ex.ToString(); } finally { log.Info("End log INFO... queryDataStsSerialPort"); } return(new object[] { msgError, form }); }
public object[] updateDataStsSerialPort(STS_SERIAL_PORT param) { log.Info("Start log INFO... updateDataStsSerialPort"); MsgForm msgError = new MsgForm(); STS_SERIAL_PORT form = new STS_SERIAL_PORT(); try { using (var db = new PaknampoScaleDBEntities()) { form = (from row in db.STS_SERIAL_PORT where row.SERIAL_PORT_ID == param.SERIAL_PORT_ID select row).FirstOrDefault(); if (Util.isNotEmpty(form)) { form.SERIAL_PORT_PORT_NO = param.SERIAL_PORT_PORT_NO; form.SERIAL_PORT_BAUD_RATE = param.SERIAL_PORT_BAUD_RATE; form.SERIAL_PORT_DATA_BITS = param.SERIAL_PORT_DATA_BITS; form.SERIAL_PORT_STOP_BITS = param.SERIAL_PORT_STOP_BITS; form.SERIAL_PORT_PARITY = param.SERIAL_PORT_PARITY; form.SERIAL_PORT_HAND_SHAKING = param.SERIAL_PORT_HAND_SHAKING; form.SERIAL_PORT_STATUS_FLAG = param.SERIAL_PORT_STATUS_FLAG; log.Info("Update Data form STS_SERIAL_PORT WHERE " + form.SERIAL_PORT_ID + " SERIAL_PORT_PORT_NO : " + form.SERIAL_PORT_PORT_NO + " SERIAL_PORT_BAUD_RATE : " + form.SERIAL_PORT_BAUD_RATE + " SERIAL_PORT_DATA_BITS : " + form.SERIAL_PORT_DATA_BITS + " SERIAL_PORT_STOP_BITS : " + form.SERIAL_PORT_STOP_BITS + " SERIAL_PORT_PARITY : " + form.SERIAL_PORT_PARITY + " SERIAL_PORT_HAND_SHAKING : " + form.SERIAL_PORT_HAND_SHAKING + " SERIAL_PORT_STATUS_FLAG : " + form.SERIAL_PORT_STATUS_FLAG ); } db.SaveChanges(); msgError.statusFlag = MsgForm.STATUS_SUCCESS; } } catch (Exception ex) { log.Error(ex.ToString(), ex); msgError.statusFlag = MsgForm.STATUS_ERROR; msgError.messageDescription = ex.ToString(); } finally { log.Info("End log INFO... updateDataStsSerialPort"); } return(new object[] { msgError }); }
public void updateDataStsSerialPort() { STS001Controller sts001Ctrl = new STS001Controller(); STS_SERIAL_PORT form = new STS_SERIAL_PORT(); Cursor.Current = Cursors.WaitCursor; try { form.SERIAL_PORT_ID = formStsSerialPort.SERIAL_PORT_ID; form.SERIAL_PORT_PORT_NO = cboPorts.Text; form.SERIAL_PORT_BAUD_RATE = Int32.Parse(cboBaudRate.Text); form.SERIAL_PORT_DATA_BITS = Int32.Parse(cboDataBits.Text); form.SERIAL_PORT_STOP_BITS = cboStopBits.Text; form.SERIAL_PORT_PARITY = cboParity.Text; form.SERIAL_PORT_HAND_SHAKING = cboHandShaking.Text; form.SERIAL_PORT_STATUS_FLAG = Util.chkboxToNumber(chkStatusConnectScale.Checked); if (Util.isEmpty(form)) { return; } object[] result = sts001Ctrl.updateDataStsSerialPort(form); MsgForm msgForm = (MsgForm)result[0]; if (msgForm.statusFlag.Equals(1)) { MessageBox.Show(CommonUtil.SAVE_DATA_SUCCESS); } else { MessageBox.Show("Error : " + msgForm.messageDescription); } } catch (Exception ex) { log.Error(ex.ToString(), ex); MessageBox.Show("Error : " + ex.ToString()); } }
public void queryDataStsSerialPort() { STS001Controller sts001Ctrl = new STS001Controller(); formStsSerialPort.SERIAL_PORT_ID = 1; try { object[] result = sts001Ctrl.queryDataStsSerialPort(formStsSerialPort); MsgForm msgForm = (MsgForm)result[0]; STS_SERIAL_PORT data = (STS_SERIAL_PORT)result[1]; if (msgForm.statusFlag.Equals(1)) { if (Util.isNotEmpty(data)) { formStsSerialPort = data; cboPorts.Text = data.SERIAL_PORT_PORT_NO.ToString(); cboBaudRate.Text = data.SERIAL_PORT_BAUD_RATE.ToString(); cboDataBits.Text = data.SERIAL_PORT_DATA_BITS.ToString(); cboStopBits.Text = data.SERIAL_PORT_STOP_BITS; cboParity.Text = data.SERIAL_PORT_PARITY; cboHandShaking.Text = data.SERIAL_PORT_HAND_SHAKING; chkStatusConnectScale.Checked = Util.chkboxToBool(data.SERIAL_PORT_STATUS_FLAG); } } else { MessageBox.Show("Error : " + msgForm.messageDescription); } } catch (Exception ex) { log.Error(ex.ToString(), ex); MessageBox.Show("Error : " + ex.ToString()); } }