Esempio n. 1
0
 public void Insert(DynamicParameters parameters)
 {
     try
     {
         CommandDefinition command = dbManager.GetStoredProcedureCommand(InsertStoreProcedure, parameters, 600);
         dbManager.ExecuteNonQuery(command);
     }
     catch (SqlException ex)
     {
         throw new DataBaseException(ex.Message, ex.Server);
     }
 }
        internal void LogError(string errorNameSpace, string eventName, string errorStack, string errorByUser)
        {
            IDBManager dbManager = CommonConnection.Connectionstring();

            try
            {
                dbManager.Open();
                dbManager.CreateParameters(4);
                if (ConfigurationSettings.AppSettings["DataB"] == "SQL")
                {
                    dbManager.AddParameters(0, "@ErrorNameSpace", errorNameSpace, ParameterDirection.Input);
                    dbManager.AddParameters(1, "@ErrorEvent", eventName, ParameterDirection.Input);
                    dbManager.AddParameters(2, "@ErrorStack", errorStack, ParameterDirection.Input);
                    dbManager.AddParameters(3, "@ErrorByUser", errorByUser, ParameterDirection.Input);
                    dbManager.ExecuteNonQuery(CommandType.StoredProcedure, "SAVE_ERROR_LOG");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbManager.Dispose();
            }
        }
        private static bool InsertDataInVerticalTable(IDBManager dbManager, int lastID, decimal calculatedValue, string verticalName, string verticalSubType)
        {
            string insertQuery = string.Format("INSERT INTO AccountMonthVerticalData(MasterID,VerticalName,SubVerticalName,Value) Values ('{0}','{1}','{2}','{3}')", lastID, verticalName, verticalSubType, Math.Round(calculatedValue, 2));
            int    result      = dbManager.ExecuteNonQuery(CommandType.Text, insertQuery);

            if (result <= 0)
            {
                return(false);
            }
            return(true);
        }
        private static bool InsertDataInChildTable(IDBManager dbManager, int lastID, decimal calculatedValue, string particularName, string particularSubType)
        {
            int particularID        = 0;
            int particularSubTypeID = 0;

            GetParticularIDAndTypeID(dbManager, particularName, particularSubType, out particularID, out particularSubTypeID);
            string insertQuery = string.Format("INSERT INTO AccountMonthChildData(MasterID,ParticularID,ParticularSubTypeID,Value) Values ('{0}','{1}','{2}','{3}')", lastID, particularID, particularSubTypeID, Math.Round(calculatedValue, 2));
            int    result      = dbManager.ExecuteNonQuery(CommandType.Text, insertQuery);

            if (result <= 0)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        //Insert Department
        public bool InsertArbitration(ArbitrationDTO AR)
        {
            bool _val = false;

            try
            {
                dbManager.Open();
                dbManager.BeginTransaction();
                dbManager.CreateParameters(4);
                dbManager.AddParameters(0, "ArbitrationTitle", AR.ArbitrationName, ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(1, "ArbitrationDescription", AR.Description, ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(2, "Action", 'I', ParameterDirection.Input, DaoConstants.InParamSize);
                // dbManager.AddParameters(2, "IpAddress", _accessor.HttpContext.Connection.RemoteIpAddress.ToString(), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(3, "CreatedBy", AR.CreatedBy, ParameterDirection.Input, DaoConstants.InParamSize);
                Int32 iResult = Convert.ToInt32(dbManager.ExecuteNonQuery(CommandType.StoredProcedure, "GLI_GetArbitration"));
                if (iResult > 0)
                {
                    dbManager.CommitTransaction();
                    _val = true;
                }
                else
                {
                    dbManager.RollBackTransaction();
                    _val = false;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                dbManager.Dispose();
                dbManager = null;
            }
            return(_val);
        }
        private void DeleteSubcomp(object obj, IDBManager dbmgr)
        {
            Subcomp item = (Subcomp)obj;												    // cast object to proper item type

            try
            {
                dbmgr.Open();															    // open database
                dbmgr.BeginTransaction();
                dbmgr.CreateParameters(2);												    // create required paramaters
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@subcomp", item.subcomp);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.SUBCOMPS_d");	    // execute stored procedure

                // save history, set current item to null
                SaveHistory(null, _oldobj, item.argUser.name, "SUBCOMPS", item.subcomp, item.comp, dbmgr, _fieldlist);

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 7
0
        private void UpdateVFDR(object obj, IDBManager dbmgr)
        {
            FAVFDR item = (FAVFDR)obj;

            try
            {
                dbmgr.Open();
                dbmgr.CreateParameters(6);
                dbmgr.AddParameters(0, "@fa_id", item.fa_id);
                dbmgr.AddParameters(1, "@vfdr_id", item.vfdr_id);
                dbmgr.AddParameters(2, "@vfdr", item.vfdr);
                dbmgr.AddParameters(3, "@vfdr_disp", item.vfdr_disp);
                dbmgr.AddParameters(4, "@status", item.status);
                dbmgr.AddParameters(5, "@fre_ref", item.fre_ref);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FAVFDR_u");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 8
0
        private void UpdatePG(object obj, IDBManager dbmgr)
        {
            FAPG item = (FAPG)obj;

            try
            {
                dbmgr.Open();
                dbmgr.CreateParameters(4);
                dbmgr.AddParameters(0, "@fa_id", item.fa_id);
                dbmgr.AddParameters(1, "@pg", item.pg);
                dbmgr.AddParameters(2, "@method", item.method);
                dbmgr.AddParameters(3, "@comment", item.comment);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FAPG_u");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 9
0
        private void UpdateDocument(object obj, IDBManager dbmgr)
        {
            FADoc item = (FADoc)obj;

            try
            {
                dbmgr.Open();
                dbmgr.CreateParameters(3);
                dbmgr.AddParameters(0, "@fa_id", item.fa_id);
                dbmgr.AddParameters(1, "@doc_id", item.doc_id);
                dbmgr.AddParameters(2, "@comment", item.comment);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FADOC_u");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 10
0
 private void DeleteVFDR(object obj, IDBManager dbmgr)
 {
     FAVFDR item = (FAVFDR)obj;
     try
     {
         dbmgr.Open();
         dbmgr.CreateParameters(2);
         dbmgr.AddParameters(0, "@fa_id", item.fa_id);
         dbmgr.AddParameters(1, "@vfdr_id", item.vfdr_id);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FAVFDR_d");
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         dbmgr.Dispose();
     }
 }
Esempio n. 11
0
 private void DeleteCabDisp(object obj, IDBManager dbmgr)
 {
     FACabDisp item = (FACabDisp)obj;									            // cast object to proper item type
     try
     {
         dbmgr.Open();															    // open database
         dbmgr.CreateParameters(4);												    // create required paramaters
         dbmgr.AddParameters(0, "@fa_id", item.fa_id);
         dbmgr.AddParameters(1, "@comp_id", item.comp_id);
         dbmgr.AddParameters(2, "@cable_id", item.cable_id);
         dbmgr.AddParameters(3, "@disp_id", item.disp_id);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FACABDISP_d");	    // execute stored procedure
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         dbmgr.Dispose();
     }
 }
Esempio n. 12
0
        private void UpdateRouteloca(object obj, IDBManager dbmgr)
        {
            Routeloca item = (Routeloca)obj;							                        // cast object to proper item type
            try
            {
                dbmgr.Open();															        // open database
                dbmgr.CreateParameters(3);												        // create required paramaters
                dbmgr.AddParameters(0, "@node_id", item.node_id);

                switch (_user.locaType)
                {
                    case Constant.type_FR:
                        dbmgr.AddParameters(1, "@loca_id", item.rm_id);
                        break;
                    default:
                        dbmgr.AddParameters(1, "@loca_id", item.fz_id);
                        break;
                }

                dbmgr.AddParameters(2, "@locatype_id", _user.locaType);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.ROUTELOCA_u");          // execute stored procedure
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 13
0
        private void DeleteFireRoom(object obj, IDBManager dbmgr)
        {
            FireRoom item = (FireRoom)obj;
            try
            {
                dbmgr.Open();															    // open database
                dbmgr.BeginTransaction();
                dbmgr.CreateParameters(1);												    // create required paramaters
                dbmgr.AddParameters(0, "@rm_id", item.rm_id);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FRLIST_d");	        // execute stored procedure

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 14
0
        // porcedure update incominginterlock
        private void UpdateInterlock(object obj, IDBManager dbmgr)
        {
            CompIntlk item = (CompIntlk)obj;

            try
            {
                dbmgr.Open();															    // open database
                dbmgr.CreateParameters(9);												    // create required paramaters
                dbmgr.BeginTransaction();
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@intlk_id", item.intlk_id);
                dbmgr.AddParameters(2, "@device", item.device);
                dbmgr.AddParameters(3, "@contacts", item.contacts);
                dbmgr.AddParameters(4, "@note", item.note);
                dbmgr.AddParameters(5, "@ssd_req", item.ssd_req);
                dbmgr.AddParameters(6, "@pra_req", item.pra_req);
                dbmgr.AddParameters(7, "@npo_req", item.npo_req);
                dbmgr.AddParameters(8, "@cfp_req", item.cfp_req);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPINTLKS_u");	    // execute stored procedure

                // save hisotry
                SaveHistory(item, _oldobj, item.argUser.name, "COMPINTLKS", item.intlk, item.comp, dbmgr, _fieldlist);

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 15
0
        // updates key safety function
        private void UpdateKSF(object obj, IDBManager dbmgr)
        {
            CompKSF item = (CompKSF)obj;

            try
            {
                dbmgr.Open();															    // open database
                dbmgr.CreateParameters(4);												    // create required paramaters
                dbmgr.BeginTransaction();
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@ksf_id", item.ksf_id);
                dbmgr.AddParameters(2, "@mode_id", item.mode_id);
                dbmgr.AddParameters(3, "@note", item.note);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPKSF_u");	    // execute stored procedure
                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 16
0
        // updates drawing
        private void UpdateDrawing(object obj, IDBManager dbmgr)
        {
            CompDwg item = (CompDwg)obj;

            try
            {
                dbmgr.Open();															    // open database
                dbmgr.CreateParameters(5);												    // create required paramaters
                dbmgr.BeginTransaction();
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@dwg_id", item.dwg_id);
                dbmgr.AddParameters(2, "@dwgtype_id", 4);                                   // other drawing
                dbmgr.AddParameters(3, "@dwg_rev", item.dwg_rev);
                dbmgr.AddParameters(4, "@dwg_cp", item.dwg_cp);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPDWGS_u");	    // execute stored procedure

                // save history
                SaveHistory(item, _oldobj, item.argUser.name, "COMPDWGS", item.dwg_ref, item.comp, dbmgr, _fieldlist);

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 17
0
        // updates component
        private void UpdateComponent(object obj, IDBManager dbmgr)
        {
            Component item = (Component)obj;
            System.Data.Common.DbParameter new_comp_id;

            try
            {
                dbmgr.Open();
                dbmgr.BeginTransaction();

                // check to see if new object
                if (item.comp_id == 0)
                {
                    // if id is null then create new object
                    dbmgr.CreateParameters(11);
                    dbmgr.AddParameters(0, "@id", 0, true);
                    dbmgr.AddParameters(1, "@comp", item.comp);
                    dbmgr.AddParameters(2, "@pri_sub", item.pri_sub);
                    dbmgr.AddParameters(3, "@unit_id", item.unit_id);
                    dbmgr.AddParameters(4, "@sys_id", item.sys_id);
                    dbmgr.AddParameters(5, "@comp_type_id", item.comp_type_id);
                    dbmgr.AddParameters(6, "@comp_desc", item.comp_desc);
                    dbmgr.AddParameters(7, "@ssd_req", item.ssd_req);
                    dbmgr.AddParameters(8, "@pra_req", item.pra_req);
                    dbmgr.AddParameters(9, "@npo_req", item.npo_req);
                    dbmgr.AddParameters(10, "@cfp_req", item.cfp_req);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPLIST_i");

                    // get item id
                    new_comp_id = (System.Data.Common.DbParameter)dbmgr.Parameters.GetValue(0);
                    item.comp_id = Convert.ToInt32(new_comp_id.Value);

                    // set old object to null to prevent it from taking value from existing page
                    SaveHistory(item, null, item.argUser.name, "COMPLIST", item.comp, item.comp, dbmgr, null);
                }

                // otherwise updating existing object
                else
                {
                    // update COMPLIST table
                    dbmgr.CreateParameters(28);
                    dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                    dbmgr.AddParameters(1, "@pri_sub", item.pri_sub);
                    dbmgr.AddParameters(2, "@unit_id", item.unit_id);
                    dbmgr.AddParameters(3, "@sys_id", item.sys_id);
                    dbmgr.AddParameters(4, "@train_id", item.train_id);
                    dbmgr.AddParameters(5, "@comp_type_id", item.comp_type_id);
                    dbmgr.AddParameters(6, "@comp", item.comp);
                    dbmgr.AddParameters(7, "@comp_desc", item.comp_desc);
                    dbmgr.AddParameters(8, "@np_id", item.np_id);
                    dbmgr.AddParameters(9, "@hsbp_id", item.hsbp_id);
                    dbmgr.AddParameters(10, "@hsp_id", item.hsp_id);
                    dbmgr.AddParameters(11, "@csp_id", item.csp_id);
                    dbmgr.AddParameters(12, "@prap_id", item.prap_id);
                    dbmgr.AddParameters(13, "@cfpp_id", item.cfpp_id);
                    dbmgr.AddParameters(14, "@npop_id", item.npop_id);
                    dbmgr.AddParameters(15, "@npo_np_id", item.npo_np_id);
                    dbmgr.AddParameters(16, "@fail_elect_id", item.fail_elect_id);
                    dbmgr.AddParameters(17, "@fail_air_id", item.fail_air_id);
                    dbmgr.AddParameters(18, "@hi_lo", item.hi_lo);
                    dbmgr.AddParameters(19, "@ssd_req", item.ssd_req);
                    dbmgr.AddParameters(20, "@pra_req", item.pra_req);
                    dbmgr.AddParameters(21, "@npo_req", item.npo_req);
                    dbmgr.AddParameters(22, "@cfp_req", item.cfp_req);
                    dbmgr.AddParameters(23, "@nsca_req", item.nsca_req);
                    dbmgr.AddParameters(24, "@method_id", item.method_id);
                    dbmgr.AddParameters(25, "@box_id", item.box_id);
                    dbmgr.AddParameters(26, "@comment", item.comment);
                    dbmgr.AddParameters(27, "@error_num", 0, true);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPLIST_u");

                    // update master drawings
                    UpdateMasterDrawing(dbmgr, item, item.ee_id, item.ee_ref, item.ee_rev, item.ee_cp, 1);      // elementary
                    UpdateMasterDrawing(dbmgr, item, item.pid_id, item.pid_ref, item.pid_rev, item.pid_cp, 2);   // p&id
                    UpdateMasterDrawing(dbmgr, item, item.ol_id, item.ol_ref, item.ol_rev, item.ol_cp, 3);      // one-line

                    // update status
                    UpdateStatus(dbmgr, item, 1, item.prep_by, item.prep_date);
                    UpdateStatus(dbmgr, item, 5, item.chkd_by, item.chkd_date);

                    // save to history
                    SaveHistory(item, _oldobj, item.argUser.name, "COMPLIST", item.comp, item.comp, dbmgr, _fieldlist);
                }

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 18
0
        // updates cable
        private void UpdateCable(object obj, IDBManager dbmgr)
        {
            CompCab item = (CompCab)obj;

            try
            {
                dbmgr.Open();															    // open database
                dbmgr.CreateParameters(11);												    // create required paramaters
                dbmgr.BeginTransaction();
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@cable_id", item.cable_id);
                dbmgr.AddParameters(2, "@note", item.note);
                dbmgr.AddParameters(3, "@fault", item.fault);
                dbmgr.AddParameters(4, "@fault_type", item.fault_type);
                dbmgr.AddParameters(5, "@fr_dwg_rev", item.fr_dwg_rev);
                dbmgr.AddParameters(6, "@to_dwg_rev", item.to_dwg_rev);
                dbmgr.AddParameters(7, "@ssd_req", item.ssd_req);
                dbmgr.AddParameters(8, "@pra_req", item.pra_req);
                dbmgr.AddParameters(9, "@npo_req", item.npo_req);
                dbmgr.AddParameters(10, "@cfp_req", item.cfp_req);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPCAB_u");	    //execute stored procedure

                // save history
                SaveHistory(item, _oldobj, item.argUser.name, "COMPCAB", item.cable, item.comp, dbmgr, _fieldlist);

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 19
0
        private void UpdateDrawing(object obj, IDBManager dbmgr)
        {
            RoutelocaDwg item = (RoutelocaDwg)obj;							                // cast object to proper item type

            try
            {
                dbmgr.Open();															    // open database
                dbmgr.CreateParameters(5);												    // create required paramaters
                dbmgr.AddParameters(0, "@nodeloca_id", item.nodeloca_id);
                dbmgr.AddParameters(1, "@dwg_id", item.dwg_id);
                dbmgr.AddParameters(2, "@dwg_rev", item.dwg_rev);
                dbmgr.AddParameters(3, "@dwgtype_id", 4);                                   // "Other" drawing type
                dbmgr.AddParameters(4, "@col_ref", item.col_ref);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.ROUTELOCADWGS_u");  // execute stored procedure
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 20
0
        private void UpdateFireRoom(object obj, IDBManager dbmgr)
        {
            FireRoom item = (FireRoom)obj;
            System.Data.Common.DbParameter param;

            try
            {
                dbmgr.Open();
                dbmgr.BeginTransaction();

                // check to see if new object
                if (item.rm_id == 0)
                {
                    // if id is null then new object
                    dbmgr.CreateParameters(4);
                    dbmgr.AddParameters(0, "@rm", item.rm);
                    dbmgr.AddParameters(1, "@id", 0, true);
                    dbmgr.AddParameters(2, "@fz_id", item.fz_id);
                    dbmgr.AddParameters(3, "@rm_desc", item.rm_desc);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FRLIST_i");

                    // get item id
                    param = (System.Data.Common.DbParameter)dbmgr.Parameters.GetValue(1);
                    item.rm_id = Convert.ToInt32(param.Value);
                }

                // otherwise update existing object
                else
                {
                    // update FRLIST table
                    dbmgr.CreateParameters(11);
                    dbmgr.AddParameters(0, "@rm_id", item.rm_id);
                    dbmgr.AddParameters(1, "@rm", item.rm);
                    dbmgr.AddParameters(2, "@rm_desc", item.rm_desc);
                    dbmgr.AddParameters(3, "@bldg", item.bldg);
                    dbmgr.AddParameters(4, "@elev", item.elev);
                    dbmgr.AddParameters(5, "@fz_id", item.fz_id);
                    dbmgr.AddParameters(6, "@req", item.req);
                    dbmgr.AddParameters(7, "@supp", item.supp);
                    dbmgr.AddParameters(8, "@det", item.det);
                    dbmgr.AddParameters(9, "@dwg_id", item.dwg_id);
                    dbmgr.AddParameters(10, "@dwg_rev", item.dwg_rev);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FRLIST_u");
                }

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 21
0
        private void UpdateRoute(object obj, IDBManager dbmgr)
        {
            Route item = (Route)obj;
            System.Data.Common.DbParameter param;

            try
            {
                dbmgr.Open();
                dbmgr.BeginTransaction();

                // check to see if new object
                if (item.node_id == 0)
                {
                    // if id is null then new object
                    dbmgr.CreateParameters(2);
                    dbmgr.AddParameters(0, "@id", 0, true);
                    dbmgr.AddParameters(1, "@node", item.node);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.ROUTELIST_i");

                    // get item id
                    param = (System.Data.Common.DbParameter)dbmgr.Parameters.GetValue(0);
                    item.node_id = Convert.ToInt32(param.Value);
                }

                // otherwise update existing object
                else
                {
                    // update ROUTELIST table
                    dbmgr.CreateParameters(2);
                    dbmgr.AddParameters(0, "@node_id", item.node_id);
                    dbmgr.AddParameters(1, "@node", item.node);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.ROUTELIST_u");
                }

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 22
0
        private void UpdateStatus(IDBManager dbmgr, Component item, int statustype_id, string user_id, DateTime status_date)
        {
            if ((user_id == "N/A") || (user_id == ""))
            {
                // delete status
                dbmgr.CreateParameters(2);
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@statustype_id", statustype_id);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPSTATUS_d");
            }
            else
            {

                if (status_date == Convert.ToDateTime(null))
                {
                    // update status
                    dbmgr.CreateParameters(3);
                    dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                    dbmgr.AddParameters(1, "@statustype_id", statustype_id);
                    dbmgr.AddParameters(2, "@user_id", user_id);
                }
                else
                {
                    // update status
                    dbmgr.CreateParameters(4);
                    dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                    dbmgr.AddParameters(1, "@statustype_id", statustype_id);
                    dbmgr.AddParameters(2, "@user_id", user_id);
                    dbmgr.AddParameters(3, "@status_date", status_date);
                }
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPSTATUS_u");
            }
        }
Esempio n. 23
0
        // updates recovery action
        private void UpdateRA(object obj, IDBManager dbmgr)
        {
            CompRA item = (CompRA)obj;

            try
            {
                dbmgr.Open();															    // open database
                dbmgr.CreateParameters(6);												    // create required paramaters
                dbmgr.BeginTransaction();
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@fa_id", item.fa_id);
                dbmgr.AddParameters(2, "@ra_disp", item.ra_disp);
                dbmgr.AddParameters(3, "@bin", item.bin);
                dbmgr.AddParameters(4, "@ra_type", item.ra_type);
                dbmgr.AddParameters(5, "@ra_feasible", item.ra_feasible);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FACOMPRA_u");	    // execute stored procedure
                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                // if there is problem with transaction roll back to original
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 24
0
        private void DeleteDrawing(object obj, IDBManager dbmgr)
        {
            Drawing item = (Drawing)obj;

            try
            {
                dbmgr.Open();
                dbmgr.CreateParameters(2);
                dbmgr.AddParameters(0, "@dwg_id", item.dwg_id);
                dbmgr.AddParameters(1, "@error_num", 0, true);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.DWGLIST_d");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 25
0
 private void DeleteFireArea(object obj, IDBManager dbmgr)
 {
     FireArea item = (FireArea)obj;											        //cast object to proper item type
     try
     {
         dbmgr.Open();															    //open database
         dbmgr.CreateParameters(1);												    //create required paramaters
         dbmgr.AddParameters(0, "@fa_id", item.fa_id);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FALIST_d");	    //execute stored procedure
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         dbmgr.Dispose();
     }
 }
Esempio n. 26
0
        private void UpdateDrawing(object obj, IDBManager dbmgr)
        {
            Drawing item = (Drawing)obj;
            System.Data.Common.DbParameter param;

            try
            {
                dbmgr.Open();
                dbmgr.BeginTransaction();

                // check to see if new object
                if (item.dwg_id == 0)
                {
                    // if id is null then new object
                    dbmgr.CreateParameters(3);
                    dbmgr.AddParameters(0, "@id", 0, true);
                    dbmgr.AddParameters(1, "@dwg_ref", item.dwg_ref);
                    dbmgr.AddParameters(2, "@dwg_rev", item.dwg_rev);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.DWGLIST_i");

                    // get item id
                    param = (System.Data.Common.DbParameter)dbmgr.Parameters.GetValue(0);
                    item.dwg_id = Convert.ToInt32(param.Value);
                }

                // otherwise update existing object
                else
                {
                    dbmgr.CreateParameters(5);
                    dbmgr.AddParameters(0, "@dwg_id", item.dwg_id);
                    dbmgr.AddParameters(1, "@dwg_ref", item.dwg_ref);
                    dbmgr.AddParameters(2, "@dwg_rev", item.dwg_rev);
                    dbmgr.AddParameters(3, "@dwg_type", item.dwg_type);
                    dbmgr.AddParameters(4, "@dwg_desc", item.dwg_desc);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.DWGLIST_u");
                }

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 27
0
        private void UpdateCompDisp(object obj, IDBManager dbmgr)
        {
            FACompDisp item = (FACompDisp)obj;										        // cast object to proper item type

            try
            {
                dbmgr.Open();
                dbmgr.CreateParameters(5);												    // create required paramaters
                dbmgr.AddParameters(0, "@fa_id", item.fa_id);
                dbmgr.AddParameters(1, "@comp_id", item.comp_id);
                dbmgr.AddParameters(2, "@old_disp_id", item.old_disp_id);
                dbmgr.AddParameters(3, "@disp_id", item.disp_id);
                dbmgr.AddParameters(4, "@status", item.status);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FACOMPDISP_u");	    // execute stored procedure
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 28
0
 private void UpdateMasterDrawing(IDBManager dbmgr, Component item, int dwg_id, string dwg_ref, string dwg_rev, string dwg_cp, int dwg_type)
 {
     // if drawing ref is empty or N/A then delete
     if (dwg_ref == "")
     {
         dbmgr.CreateParameters(3);
         dbmgr.BeginTransaction();
         dbmgr.AddParameters(0, "@comp_id", item.comp_id);
         dbmgr.AddParameters(1, "@dwg_id", dwg_id);
         dbmgr.AddParameters(2, "@dwgtype_id", dwg_type);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPDWGS_d");
     }
     // otherwise update
     else
     {
         // add updated/new
         dbmgr.CreateParameters(5);
         dbmgr.AddParameters(0, "@comp_id", item.comp_id);
         dbmgr.AddParameters(1, "@dwg_id", dwg_id);
         dbmgr.AddParameters(2, "@dwgtype_id", dwg_type);
         dbmgr.AddParameters(3, "@dwg_rev", dwg_rev);
         dbmgr.AddParameters(4, "@dwg_cp", dwg_cp);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPDWGS_MASTER_u");
     }
 }
Esempio n. 29
0
        private void UpdateFireArea(object obj, IDBManager dbmgr)
        {
            FireArea item = (FireArea)obj;
            System.Data.Common.DbParameter param;
            try
            {
                dbmgr.Open();
                dbmgr.BeginTransaction();

                // check to see if new object
                if (item.fa_id == 0)
                {
                    dbmgr.CreateParameters(3);
                    dbmgr.AddParameters(0, "@id", 0, true);
                    dbmgr.AddParameters(1, "@fa", item.fa);
                    dbmgr.AddParameters(2, "@fa_desc", item.fa_desc);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FALIST_i");

                    // get item id
                    param = (System.Data.Common.DbParameter)dbmgr.Parameters.GetValue(0);
                    item.fa_id = (int)param.Value;
                }
                // otherwise update existing object
                else
                {
                    dbmgr.CreateParameters(14);
                    dbmgr.AddParameters(0, "@fa_id", item.fa_id);
                    dbmgr.AddParameters(1, "@fa", item.fa);
                    dbmgr.AddParameters(2, "@fa_desc", item.fa_desc);
                    dbmgr.AddParameters(3, "@bldg", item.bldg);
                    dbmgr.AddParameters(4, "@elev", item.elev);
                    dbmgr.AddParameters(5, "@ssd_path", item.ssd_path);
                    dbmgr.AddParameters(6, "@req", item.req);
                    dbmgr.AddParameters(7, "@supp", item.supp);
                    dbmgr.AddParameters(8, "@det", item.det);
                    dbmgr.AddParameters(9, "@comment", item.comment);
                    dbmgr.AddParameters(10, "@dwg_id", item.dwg_id);
                    dbmgr.AddParameters(11, "@dwg_rev", item.dwg_rev);
                    dbmgr.AddParameters(12, "@risk_summary", item.risk_summary);
                    dbmgr.AddParameters(13, "@reg_basis", item.reg_basis);
                    dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FALIST_u");	        // execute the stored procedure

                    //update status
                    UpdateStatus(dbmgr, item, 1, item.prep_by, item.prep_date);
                    UpdateStatus(dbmgr, item, 5, item.chkd_by, item.chkd_date);
                }

                dbmgr.CommitTransaction();
            }
            catch (Exception ex)
            {
                dbmgr.RollbackTransaction();
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 30
0
 private void UpdateRoutechg(object obj, IDBManager dbmgr)
 {
     CabRoute item = (CabRoute)obj;									    		    // cast object to proper item type
     try
     {
         dbmgr.Open();															    // open database
         dbmgr.CreateParameters(8);												    // create required paramaters
         dbmgr.AddParameters(0, "@cable_id", item.cable_id);
         dbmgr.AddParameters(1, "@seq", item.seq);
         dbmgr.AddParameters(2, "@node_id", item.node_id);
         dbmgr.AddParameters(3, "@fz_id", item.fz_id);
         dbmgr.AddParameters(4, "@add_del", item.add_del);
         dbmgr.AddParameters(5, "@dwg_id", item.dwg_id);
         dbmgr.AddParameters(6, "@dwg_rev", item.dwg_rev);
         dbmgr.AddParameters(7, "@col_ref", item.col_ref);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.CABROUTE_CHGS_u");  // execute stored procedure
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         dbmgr.Dispose();
     }
 }
Esempio n. 31
0
 private void UpdateStatus(IDBManager dbmgr, FireArea item, int statustype_id, string user_id, DateTime status_date)
 {
     if ((user_id == "N/A") || (user_id == ""))
     {
         // delete status
         dbmgr.CreateParameters(2);
         dbmgr.AddParameters(0, "@fa_id", item.fa_id);
         dbmgr.AddParameters(1, "@statustype_id", statustype_id);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FASTATUS_d");
     }
     else
     {
         // update status
         dbmgr.CreateParameters(4);
         dbmgr.AddParameters(0, "@fa_id", item.fa_id);
         dbmgr.AddParameters(1, "@statustype_id", statustype_id);
         dbmgr.AddParameters(2, "@user_id", user_id);
         if (status_date == Convert.ToDateTime(null))
             // set date to null
             dbmgr.AddParameters(3, "@status_date", null);
         else
             // update date
             dbmgr.AddParameters(3, "@status_date", status_date);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.FASTATUS_u");
     }
 }
Esempio n. 32
0
 private void UpdateBDEndpoint(object obj, IDBManager dbmgr)
 {
     RouteBDEndpoint item = (RouteBDEndpoint)obj;							        // cast object to proper item type
     try
     {
         dbmgr.Open();															    // open database
         dbmgr.CreateParameters(2);												    // create required paramaters
         dbmgr.AddParameters(0, "@endpt", item.endpt);
         dbmgr.AddParameters(1, "@bdendpt", item.bd_endpt);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.BDENDPOINTS_u");    // execute stored procedure
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         dbmgr.Dispose();
     }
 }
Esempio n. 33
0
        //To Insert Proforma1 Details to Db
        public bool InsertProforma1Details(Proforma1 entity)
        {
            bool        val = false;
            IDataReader dr  = null;

            try
            {
                dbManager.Open();
                dbManager.BeginTransaction();
                dbManager.CreateParameters(28);
                dbManager.AddParameters(0, "", GetDBNullOrValue(entity.districts.DistrictCode), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(1, "", GetDBNullOrValue(entity.mandals.MandalCode), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(2, "", GetDBNullOrValue(entity.villages.VillageCode), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(3, "", GetDBNullOrValue(entity.WlRsrBaseSurveyNo), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(4, "", GetDBNullOrValue(entity.WlRsrSubDivNo), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(5, "", GetDBNullOrValue(entity.WlRsrExtent), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(6, "", GetDBNullOrValue(entity.OriginalBaseSurveyNo), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(7, "", GetDBNullOrValue(entity.OriginalSubDivNo), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(8, "", GetDBNullOrValue(entity.OriginalExtent), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(9, "", GetDBNullOrValue(entity.OriginalRsrExtentType), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(10, "", GetDBNullOrValue(entity.OriginalClasfctn), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(11, "", GetDBNullOrValue(entity.OriginalLandNature), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(12, "", GetDBNullOrValue(entity.WebLandLandNature), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(13, "", GetDBNullOrValue(entity.PattadarCategory), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(14, "", GetDBNullOrValue(entity.IsExtentSame), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(15, "", GetDBNullOrValue(entity.IsClassificationSame), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(16, "", GetDBNullOrValue(entity.IsLandNatureSame), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(17, "", GetDBNullOrValue(entity.IsRecordTallied), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(18, "", GetDBNullOrValue(entity.ExtentDiffEntered), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(19, "", GetDBNullOrValue(entity.RectificationReasonType), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(20, "", GetDBNullOrValue(entity.PendingReasonType), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(21, "", GetDBNullOrValue(entity.WeblandClasfctn), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(22, "", GetDBNullOrValue(entity.WebLandRsrRemarks), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(23, "", GetDBNullOrValue(entity.OriginalRsrRemarks), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(24, "", GetDBNullOrValue(entity.FilePath), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(25, "", GetDBNullOrValue(entity.BaseFrom), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(26, "", GetDBNullOrValue(entity.Recordstatus), ParameterDirection.Input, DaoConstants.InParamSize);
                dbManager.AddParameters(27, "", GetDBNullOrValue(entity.RecordApprovedStatus), ParameterDirection.Input, DaoConstants.InParamSize);
                int iResult = Convert.ToInt32(dbManager.ExecuteNonQuery(CommandType.StoredProcedure, "USP_InsertScrollingTextInfo"));
                if (iResult > 0)
                {
                    dbManager.CommitTransaction();
                    val = true;
                }
                else
                {
                    dbManager.RollBackTransaction();
                    val = false;
                }
                return(val);
            }
            catch (Exception ex)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                val = false;
                //Errorlog.WriteToErrorLog(ex, "", "", "Class : CommonDal, Method : InsertScrollingText,SP : USP_InsertScrollingTextInfo");
                dbManager.RollBackTransaction();
                return(false);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                if (entity != null)
                {
                    dbManager.Dispose();
                    dbManager = null;
                }
            }
        }
Esempio n. 34
0
        // deletes component
        private void DeleteComponent(object obj, IDBManager dbmgr)
        {
            Component item = (Component)obj;
            try
            {
                dbmgr.Open();
                dbmgr.CreateParameters(2);
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@error_num", 0, true);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPLIST_d");

                // save to history, make current object null
                SaveHistory(null, _oldobj, item.argUser.name, "COMPLIST", item.comp, item.comp, dbmgr, _fieldlist);

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }
Esempio n. 35
0
 private void DeleteRoute(object obj, IDBManager dbmgr)
 {
     Route item = (Route)obj;
     try
     {
         dbmgr.Open();															    // open database
         dbmgr.CreateParameters(2);												    // create required paramaters
         dbmgr.AddParameters(0, "@node_id", item.node_id);
         dbmgr.AddParameters(1, "@error_num", 0, true);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.ROUTELIST_d");	    // execute stored procedure
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         dbmgr.Dispose();
     }
 }
Esempio n. 36
0
        private void UpdateDrawing(object obj, IDBManager dbmgr)
        {
            CabDwg item = (CabDwg)obj;										    		    //cast object to proper item type

            int dwgtype;
            switch (_user.plant)
            {
                case "ANO":
                    dwgtype = item.dwgtype_id;
                    break;
                default:
                    dwgtype = 4;
                    break;
            }

            try
            {
                dbmgr.Open();															    //open database
                dbmgr.CreateParameters(5);												    //create required paramaters
                dbmgr.AddParameters(0, "@comp_id", item.comp_id);
                dbmgr.AddParameters(1, "@cable_id", item.cable_id);
                dbmgr.AddParameters(2, "@dwg_id", item.dwg_id);
                dbmgr.AddParameters(3, "@dwgtype_id", dwgtype);                                   //other drawing type
                dbmgr.AddParameters(4, "@dwg_rev", item.dwg_rev);
                dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.COMPCABDWGS_u");    //execute stored procedure
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbmgr.Dispose();
            }
        }