Ejemplo n.º 1
0
        public DAILY_UNKNOWNDC LoadByDailyID(DBConnection Connection, int DAILY_ID)
        {
            DAILY_UNKNOWNDC objDAILY_UNKNOW = new DAILY_UNKNOWNDC();
            StringBuilder   sql             = new StringBuilder();

            sql.Append("proc_DAILY_UNKNOWNLoadByDailyID");

            DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection);

            dbCommandWrapper.AddInParameter("p_DAILY_ID", DbType.Int32, DAILY_ID);


            DataSet ds = new DataSet();

            if (Connection.Transaction != null)
            {
                ds = Connection.dataBase.ExecuteDataSet(dbCommandWrapper.DBCommand, Connection.Transaction);
            }
            else
            {
                ds = Connection.dataBase.ExecuteDataSet(dbCommandWrapper.DBCommand);
            }

            objDAILY_UNKNOW = (Utility.ConvertToObject <DAILY_UNKNOWNDC>(ds.Tables[0]));
            return(objDAILY_UNKNOW);
        }
Ejemplo n.º 2
0
        private DAILY_UNKNOWNDC FillObject(DataRow row)
        {
            DAILY_UNKNOWNDC objDAILY_UNKNOW = null;

            objDAILY_UNKNOW                = new DAILY_UNKNOWNDC();
            objDAILY_UNKNOW.DU_DAILY_ID    = (int)row["DU_DAILY_ID"];
            objDAILY_UNKNOW.DAILY_ID       = (int)row["DAILY_ID"];
            objDAILY_UNKNOW.NODE_ID1       = (String)row["NODE_ID1"];
            objDAILY_UNKNOW.NODE_ID2       = (String)row["NODE_ID2"];
            objDAILY_UNKNOW.NODE_ID3       = (String)row["NODE_ID3"];
            objDAILY_UNKNOW.HUB            = (String)row["HUB"];
            objDAILY_UNKNOW.HYLAN_PM       = row["HYLAN_PM"] == DBNull.Value ? null : (int?)row["HYLAN_PM"];
            objDAILY_UNKNOW.STREET_ADDRESS = (String)row["STREET_ADDRESS"];
            objDAILY_UNKNOW.CITY           = (String)row["CITY"];
            objDAILY_UNKNOW.STATE          = (String)row["STATE"];
            objDAILY_UNKNOW.ZIP            = row["ZIP"] == DBNull.Value ? null : (String)row["ZIP"];
            objDAILY_UNKNOW.LAT            = (String)row["LAT"];
            objDAILY_UNKNOW.LONG           = (String)row["LONG"];
            objDAILY_UNKNOW.POLE_LOCATION  = (String)row["POLE_LOCATION"];
            objDAILY_UNKNOW.CLIENT_PM      = (String)row["CLIENT_PM"];
            objDAILY_UNKNOW.UNKNOWN_STATUS = (int)row["UNKNOWN_STATUS"];
            objDAILY_UNKNOW.CREATED_ON     = (DateTime)row["CREATED_ON"];
            objDAILY_UNKNOW.CREATED_BY     = (int)row["CREATED_BY"];
            objDAILY_UNKNOW.MODIFIED_ON    = (DateTime)row["MODIFIED_ON"];
            objDAILY_UNKNOW.MODIFIED_BY    = (int)row["MODIFIED_BY"];
            objDAILY_UNKNOW.LOCK_COUNTER   = (int)row["LOCK_COUNTER"];

            return(objDAILY_UNKNOW);
        }
Ejemplo n.º 3
0
        public int Delete(DBConnection Connection, DAILY_UNKNOWNDC objDAILY_UNKNOW)
        {
            int deleteCount = 0;

            StringBuilder sql = new StringBuilder();

            sql.Append("proc_DAILY_UNKNOWNDelete");

            DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection);

            dbCommandWrapper.AddInParameter("p_DU_DAILY_ID", DbType.Int32, objDAILY_UNKNOW.DU_DAILY_ID);

            if (Connection.Transaction != null)
            {
                deleteCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand, Connection.Transaction);
            }
            else
            {
                deleteCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand);
            }

            return(deleteCount);
        }
Ejemplo n.º 4
0
        public DailyDTO Update(DailyDTO dailyDTO)
        {
            DAILYDC      objDAILYDC     = dailyDTO.DAILYDC;
            int          updatedCount   = 0;
            DBConnection objConnection  = new DBConnection();
            DAILYDA      objDAILDA      = new DAILYDA();
            bool         exceptionFound = true;

            try
            {
                objConnection.Open(true);
                DateTime currentDateTime = DateTime.Now;
                objDAILYDC.MODIFIED_ON = currentDateTime;
                updatedCount           = objDAILDA.Update(objConnection, objDAILYDC);
                if (updatedCount > 0)
                {
                    exceptionFound = false;
                    #region Unknown Daily - Insert/Update
                    try
                    {
                        if (objDAILYDC.PROJECT_ID == -1 || objDAILYDC.JOB_ID == -1)
                        {
                            DAILY_UNKNOWNDA unknownDailyDA  = new DAILY_UNKNOWNDA();
                            DAILY_UNKNOWNDC DAILY_UNKNOWNDC = unknownDailyDA.LoadByDailyID(objConnection, objDAILYDC.DAILY_ID);
                            if (DAILY_UNKNOWNDC != null && DAILY_UNKNOWNDC.DU_DAILY_ID != 0)
                            {
                                objDAILYDC.DU_DAILY_ID  = DAILY_UNKNOWNDC.DU_DAILY_ID;
                                objDAILYDC.LOCK_COUNTER = DAILY_UNKNOWNDC.LOCK_COUNTER; // Retain previous lock counter
                                unknownDailyDA.Update(objConnection, objDAILYDC);
                            }
                            else
                            {
                                objDAILYDC.CREATED_BY  = objDAILYDC.MODIFIED_BY;
                                objDAILYDC.CREATED_ON  = currentDateTime;
                                objDAILYDC.MODIFIED_ON = objDAILYDC.CREATED_ON;
                                unknownDailyDA.Insert(objConnection, objDAILYDC);
                            }
                        }
                    }
                    catch (Exception unkDailyException)
                    {
                        exceptionFound = true;
                        dailyDTO.DAILYDC.POST_MESSAGEDC.Type = "EXCEPTION";
                        if (unkDailyException.Message.Contains("CONCURRENCY_ERROR"))
                        {
                            dailyDTO.DAILYDC.POST_MESSAGEDC.Type    = "CONCURRENCY_ERROR";
                            dailyDTO.DAILYDC.POST_MESSAGEDC.Message = "CONCURRENCY_ERROR";
                        }
                        else
                        {
                            dailyDTO.DAILYDC.POST_MESSAGEDC.Message    = unkDailyException.Message;
                            dailyDTO.DAILYDC.POST_MESSAGEDC.StackTrace = unkDailyException.StackTrace;
                        }
                    }
                    #endregion

                    #region ManPower - Insert/Update
                    MAN_POWERBL manPowerBL = new MAN_POWERBL();
                    foreach (MAN_POWERDC mpDC in dailyDTO.listMAN_POWERDC)
                    {
                        try
                        {
                            mpDC.DAILY_ID = objDAILYDC.DAILY_ID;
                            if (mpDC.MAN_POWER_ID == 0)
                            {
                                mpDC.CREATED_ON  = objDAILYDC.MODIFIED_ON;
                                mpDC.MODIFIED_ON = mpDC.CREATED_ON;
                                mpDC.CREATED_BY  = objDAILYDC.MODIFIED_BY;
                                mpDC.MODIFIED_BY = mpDC.CREATED_BY;
                                manPowerBL.Insert(objConnection, mpDC);
                            }
                            else
                            {
                                mpDC.MODIFIED_ON = objDAILYDC.MODIFIED_ON;
                                mpDC.MODIFIED_BY = objDAILYDC.MODIFIED_BY;
                                manPowerBL.Update(objConnection, mpDC);
                            }
                        }
                        catch (Exception mpException)
                        {
                            exceptionFound           = true;
                            mpDC.POST_MESSAGEDC.Type = "EXCEPTION";
                            if (mpException.Message.Contains("CONCURRENCY_ERROR"))
                            {
                                mpDC.POST_MESSAGEDC.Type    = "CONCURRENCY_ERROR";
                                mpDC.POST_MESSAGEDC.Message = "CONCURRENCY_ERROR";
                            }
                            else
                            {
                                mpDC.POST_MESSAGEDC.Message    = mpException.Message;
                                mpDC.POST_MESSAGEDC.StackTrace = mpException.StackTrace;
                            }
                        }
                    }
                    #endregion

                    #region Vehicle - Insert/Update
                    VEHICLEBL vehicleBL = new VEHICLEBL();
                    foreach (VEHICLEDC vehicleDC in dailyDTO.listVEHICLEDC)
                    {
                        try
                        {
                            vehicleDC.DAILY_ID = objDAILYDC.DAILY_ID;
                            if (vehicleDC.VEHICLE_VALUE_ID == 0)
                            {
                                vehicleDC.CREATED_ON  = objDAILYDC.MODIFIED_ON;
                                vehicleDC.MODIFIED_ON = vehicleDC.CREATED_ON;
                                vehicleDC.CREATED_BY  = objDAILYDC.MODIFIED_BY;
                                vehicleDC.MODIFIED_BY = objDAILYDC.MODIFIED_BY;
                                vehicleBL.Insert(objConnection, vehicleDC);
                            }
                            else
                            {
                                vehicleDC.MODIFIED_ON = objDAILYDC.MODIFIED_ON;
                                vehicleDC.MODIFIED_BY = objDAILYDC.MODIFIED_BY;
                                vehicleBL.Update(objConnection, vehicleDC);
                            }
                        }
                        catch (Exception vvException)
                        {
                            exceptionFound = true;
                            vehicleDC.POST_MESSAGEDC.Type = "EXCEPTION";
                            if (vvException.Message.Contains("CONCURRENCY_ERROR"))
                            {
                                vehicleDC.POST_MESSAGEDC.Type    = "CONCURRENCY_ERROR";
                                vehicleDC.POST_MESSAGEDC.Message = "CONCURRENCY_ERROR";
                            }
                            else
                            {
                                vehicleDC.POST_MESSAGEDC.Message    = vvException.Message;
                                vehicleDC.POST_MESSAGEDC.StackTrace = vvException.StackTrace;
                            }
                        }
                    }
                    #endregion

                    #region Labor - Insert/Update
                    LABORBL laborBL = new LABORBL();
                    foreach (LABORDC laborDC in dailyDTO.listLABORDC)
                    {
                        try
                        {
                            laborDC.DAILY_ID = objDAILYDC.DAILY_ID;
                            if (laborDC.LABOR_VALUE_ID == 0)
                            {
                                laborDC.CREATED_ON  = objDAILYDC.MODIFIED_ON;
                                laborDC.MODIFIED_ON = laborDC.CREATED_ON;
                                laborDC.CREATED_BY  = objDAILYDC.MODIFIED_BY;
                                laborDC.MODIFIED_BY = objDAILYDC.MODIFIED_BY;
                                laborBL.Insert(objConnection, laborDC);
                            }
                            else
                            {
                                laborDC.MODIFIED_ON = objDAILYDC.MODIFIED_ON;
                                laborDC.MODIFIED_BY = objDAILYDC.MODIFIED_BY;
                                laborBL.Update(objConnection, laborDC);
                            }
                        }
                        catch (Exception lbrException)
                        {
                            exceptionFound = true;
                            laborDC.POST_MESSAGEDC.Type = "EXCEPTION";
                            if (lbrException.Message.Contains("CONCURRENCY_ERROR"))
                            {
                                laborDC.POST_MESSAGEDC.Type    = "CONCURRENCY_ERROR";
                                laborDC.POST_MESSAGEDC.Message = "CONCURRENCY_ERROR";
                            }
                            else
                            {
                                laborDC.POST_MESSAGEDC.Message    = lbrException.Message;
                                laborDC.POST_MESSAGEDC.StackTrace = lbrException.StackTrace;
                            }
                        }
                    }
                    #endregion

                    #region Material - Insert/Update
                    InsertUpdateMaterials(objConnection, objDAILYDC, dailyDTO.listMATERIALDC, ref exceptionFound);
                    #endregion

                    #region Labor Item - Insert/Update
                    InsertUpdateMaterials(objConnection, objDAILYDC, dailyDTO.listLaborItemDC, ref exceptionFound);
                    #endregion

                    #region Aerial - Insert/Update
                    InsertUpdateMaterials(objConnection, objDAILYDC, dailyDTO.listAerialDC, ref exceptionFound);
                    #endregion

                    #region MDU - Insert/Update
                    InsertUpdateMaterials(objConnection, objDAILYDC, dailyDTO.listMDUDC, ref exceptionFound);
                    #endregion

                    #region Work Detail - Insert/Update
                    WORK_DETAILBL workDetailBL = new WORK_DETAILBL();
                    foreach (WORK_DETAILDC workDetailDC in dailyDTO.listWORK_DETAILDC)
                    {
                        try
                        {
                            workDetailDC.DAILY_ID = objDAILYDC.DAILY_ID;
                            if (workDetailDC.WORK_DETAIL_VALUE_ID == 0)
                            {
                                workDetailDC.CREATED_ON  = objDAILYDC.MODIFIED_ON;
                                workDetailDC.MODIFIED_ON = workDetailDC.CREATED_ON;
                                workDetailDC.CREATED_BY  = objDAILYDC.MODIFIED_BY;
                                workDetailDC.MODIFIED_BY = objDAILYDC.MODIFIED_BY;
                                workDetailBL.Insert(objConnection, workDetailDC);
                            }
                            else
                            {
                                workDetailDC.MODIFIED_ON = objDAILYDC.MODIFIED_ON;
                                workDetailDC.MODIFIED_BY = objDAILYDC.MODIFIED_BY;
                                workDetailBL.Update(objConnection, workDetailDC);
                            }
                        }
                        catch (Exception wvException)
                        {
                            exceptionFound = true;
                            workDetailDC.POST_MESSAGEDC.Type = "EXCEPTION";
                            if (wvException.Message.Contains("CONCURRENCY_ERROR"))
                            {
                                workDetailDC.POST_MESSAGEDC.Type    = "CONCURRENCY_ERROR";
                                workDetailDC.POST_MESSAGEDC.Message = "CONCURRENCY_ERROR";
                            }
                            else
                            {
                                workDetailDC.POST_MESSAGEDC.Message    = wvException.Message;
                                workDetailDC.POST_MESSAGEDC.StackTrace = wvException.StackTrace;
                            }
                        }
                    }
                    #endregion
                }
            }
            catch (Exception exception)
            {
                exceptionFound = true;
                dailyDTO.DAILYDC.POST_MESSAGEDC.Type = "EXCEPTION";
                if (exception.Message.Contains("CONCURRENCY_ERROR"))
                {
                    dailyDTO.DAILYDC.POST_MESSAGEDC.Type    = "CONCURRENCY_ERROR";
                    dailyDTO.DAILYDC.POST_MESSAGEDC.Message = "CONCURRENCY_ERROR";
                }
                else
                {
                    dailyDTO.DAILYDC.POST_MESSAGEDC.Message    = exception.Message;
                    dailyDTO.DAILYDC.POST_MESSAGEDC.StackTrace = exception.StackTrace;
                }
            }
            finally
            {
                if (exceptionFound)
                {
                    dailyDTO.DAILYDC.TRANSACTION_SUCCESS = false;
                    objConnection.Rollback();
                }
                else
                {
                    dailyDTO.DAILYDC.TRANSACTION_SUCCESS = true;
                    objConnection.Commit();
                }

                objConnection.Close();
            }
            return(dailyDTO);
        }