protected override void DataPortal_Update() { //PLC写入下达任务 //throw new Exception("写入下达任务"); using (BypassPropertyChecks) { using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString)) { cn.Open(); using (var tran = cn.BeginTransaction()) { try { using (var cm = cn.CreateCommand()) { cm.Transaction = tran; StringBuilder SQL = new StringBuilder(); SQL.Append("UPDATE T_InTaskIssued "); SQL.Append(" SET ID = @ID,PLCFLAG = @PLCFLAG,PLCTASKNO = @PLCTASKNO,SLOCATION = @SLOCATION,CIGCODE = @CIGCODE,BARCODE = @BARCODE,INQTY = @INQTY "); SQL.Append(" WHERE ID = @ID"); cm.CommandText = SQL.ToString(); cm.Parameters.AddWithValue("@ID", ID); cm.Parameters.AddWithValue("@PLCFLAG", PLCFLAG); cm.Parameters.AddWithValue("@PLCTASKNO", PLCTASKNO); cm.Parameters.AddWithValue("@SLOCATION", SLOCATION); cm.Parameters.AddWithValue("@CIGCODE", CIGCODE); cm.Parameters.AddWithValue("@BARCODE", BARCODE); cm.Parameters.AddWithValue("@INQTY", INQTY); cm.ExecuteNonQuery(); } tran.Commit(); if (PLCTASKNO != "0" && SLOCATION != "0" && INQTY != 0) { m_inTask = InTask.GetInTaskByIndex(PLCTASKNO); if (m_inTask != null) { m_inTask.Status = 2; m_inTask.SaveInTaskProcess(PLCTASKNO); } MonitorLog monitorLog = MonitorLog.NewMonitorLog(); monitorLog.LOGNAME = "PLC任务下达"; monitorLog.LOGINFO = "PLCTASKNO:" + PLCTASKNO.PadRight(10); monitorLog.LOGINFO += CIGCODE + ":" + BARCODE + ":" + INQTY + " "; monitorLog.LOGLOCATION = "PLC"; monitorLog.LOGTYPE = 0; monitorLog.Save(); } //else //{ // m_sortingLineTask = SortingLineTask.GetSortingLineByIndex(PLCTASKNO); // if (m_sortingLineTask != null) // { // m_sortingLineTask.Status = 2; // m_sortingLineTask.SaveSortingTaskProcess(PLCTASKNO); // } //} } catch (Exception) { tran.Rollback(); throw; } } } } }
protected override void DataPortal_Insert() { //PLC写入下达任务 //throw new Exception("写入下达任务"); using (BypassPropertyChecks) { using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString)) { cn.Open(); using (var tran = cn.BeginTransaction()) { try { using (var cm = cn.CreateCommand()) { StringBuilder SQL = new StringBuilder(); SQL.Append("INSERT "); SQL.Append(" INTO T_SORTINGTASKISSUED "); SQL.Append(" ( "); SQL.Append(" ID,PLCFLAG,PLCTASKNO,SLOCATION,ORDERNUMBER "); SQL.Append(" ) "); SQL.Append(" VALUES "); SQL.Append(" ( "); SQL.Append(" @ID,@PLCFLAG,@PLCTASKNO,@SLOCATION,@ORDERNUMBER "); SQL.Append(" )"); cm.CommandText = SQL.ToString(); cm.Parameters.AddWithValue("@ID", ID); cm.Parameters.AddWithValue("@PLCFLAG", PLCFLAG); cm.Parameters.AddWithValue("@PLCTASKNO", PLCTASKNO); cm.Parameters.AddWithValue("@SLOCATION", SLOCATION); cm.Parameters.AddWithValue("@ORDERNUMBER", ORDERNUMBER); cm.ExecuteNonQuery(); } // update child objects FieldManager.UpdateChildren(this, tran); tran.Commit(); MonitorLog monitorLog = MonitorLog.NewMonitorLog(); monitorLog.LOGNAME = "PLC分拣任务下达"; monitorLog.LOGINFO = "PLCTASKNO:" + PLCTASKNO.PadRight(10); foreach (SortingTaskIssuedDetail sortingTaskIssuedDetail in SortingTaskIssuedDetails) { monitorLog.LOGINFO += sortingTaskIssuedDetail.LINEBOXCODE + ":" + sortingTaskIssuedDetail.ADDRESSCODE + ":" + sortingTaskIssuedDetail.QTY + " "; } monitorLog.LOGLOCATION = "PLC"; monitorLog.LOGTYPE = 0; monitorLog.Save(); } catch (Exception) { tran.Rollback(); throw; } } } } }
protected override void DataPortal_Insert() { //PLC写入下达任务 //throw new Exception("写入下达任务"); using (BypassPropertyChecks) { using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString)) { cn.Open(); using (var tran = cn.BeginTransaction()) { try { using (var cm = cn.CreateCommand()) { StringBuilder SQL = new StringBuilder(); SQL.Append("INSERT "); SQL.Append(" INTO T_InTaskIssued "); SQL.Append(" ( "); SQL.Append(" ID,PLCFLAG,PLCTASKNO,SLOCATION,CIGCODE,BARCODE,INQTY "); SQL.Append(" ) "); SQL.Append(" VALUES "); SQL.Append(" ( "); SQL.Append(" @ID,@PLCFLAG,@PLCTASKNO,@SLOCATION,@CIGCODE,@BARCODE,@INQTY "); SQL.Append(" )"); cm.CommandText = SQL.ToString(); cm.Parameters.AddWithValue("@ID", ID); cm.Parameters.AddWithValue("@PLCFLAG", PLCFLAG); cm.Parameters.AddWithValue("@PLCTASKNO", PLCTASKNO); cm.Parameters.AddWithValue("@SLOCATION", SLOCATION); cm.Parameters.AddWithValue("@CIGCODE", CIGCODE); cm.Parameters.AddWithValue("@BARCODE", BARCODE); cm.Parameters.AddWithValue("@INQTY", INQTY); cm.ExecuteNonQuery(); } MonitorLog monitorLog = MonitorLog.NewMonitorLog(); monitorLog.LOGNAME = "PLC补货任务下达"; monitorLog.LOGINFO = "PLCTASKNO:" + PLCTASKNO.PadRight(10); monitorLog.LOGINFO += CIGCODE + ":" + BARCODE + ":" + INQTY + " "; monitorLog.LOGLOCATION = "PLC"; monitorLog.LOGTYPE = 0; monitorLog.Save(); } catch (Exception) { tran.Rollback(); throw; } } } } }