Ejemplo n.º 1
0
        public bool ClearSerialInEpicor(SessionInfo _session, ProductionHeadModel model, out string msg)
        {
            msg = string.Empty; bool IsSuccess = false; Session currSession;
            try
            {
                currSession = new Session(_session.UserID, _session.UserPassword, _session.AppServer, Session.LicenseType.Default);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return false;
            }

            foreach (var item in model.SerialLines.Where(i => i.CutSeq.Equals(model.CutSeq)))
            {
                try
                {
                    LotSelectUpdate lotPart = new LotSelectUpdate(currSession.ConnectionPool);
                    lotPart.DeleteByID(item.MCSSNo, item.SerialNo);
                }
                catch (Exception ex)
                {
                    msg = ex.Message + ": Status = " + IsSuccess.ToString();
                    IsSuccess = false;
                }
            }
            string sql = string.Format(@"DELETE FROM ucc_pln_SerialGenerated WHERE WorkOrderID = {0} ", model.WorkOrderID);
            Repository.Instance.ExecuteWithTransaction(sql, "Delete Serial");
            return true;
        }
Ejemplo n.º 2
0
        public bool ClearSerialInEpicor(SessionInfo _session, PlanningHeadModel model, out string msg)
        {
            msg = string.Empty;
            bool IsSuccess = true;
            string sql = string.Empty;
            Session currSession = null;
            var resultContinue = GetSerialAllByWorkOrder(model.WorkOrderID).ToList();
            try
            {
                currSession = new Session(_session.UserID, _session.UserPassword, _session.AppServer, Session.LicenseType.Default);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                IsSuccess = false;
            }

            foreach (var item in resultContinue)
            {
                try
                {
                    LotSelectUpdate lotPart = new LotSelectUpdate(currSession.ConnectionPool);
                    lotPart.DeleteByID(string.IsNullOrEmpty(item.NORNum) ? item.MCSSNo : item.NORNum, item.SerialNo);
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                    IsSuccess = false;
                }

                //TODO : There are has one more case for delete S/N.
                sql += string.Format(@"DELETE FROM ucc_pln_SerialGenerated WHERE WorkOrderID = {0} AND SerialNo = '{1}' {2}{3}{4}"
                                        , item.WorkOrderID, item.SerialNo, Environment.NewLine, "", Environment.NewLine);
            }

            sql += string.Format(@"UPDATE ucc_pln_PlanHead SET GenSerialFlag = 0 WHERE WorkOrderID = {0} ", model.WorkOrderID);
            Repository.Instance.ExecuteWithTransaction(sql, "Delete Serial");
            return IsSuccess;
        }