//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 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(); } }
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(); } }
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(); } }
private void UpdateDisposition(object obj, IDBManager dbmgr) { Disposition item = (Disposition)obj; System.Data.Common.DbParameter new_disp_id; try { dbmgr.Open(); dbmgr.BeginTransaction(); if (item.disp_id == 0) { // if is id null then create new object dbmgr.CreateParameters(3); dbmgr.AddParameters(0, "@id", 0, true); dbmgr.AddParameters(1, "@disp", item.disp); dbmgr.AddParameters(2, "@disp_desc", item.disp_desc); dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.DISPLIST_i"); // get item id new_disp_id = (System.Data.Common.DbParameter)dbmgr.Parameters.GetValue(0); item.disp_id = Convert.ToInt32(new_disp_id.Value); } else { // update table dbmgr.CreateParameters(3); dbmgr.AddParameters(0, "@disp_id", item.disp_id); dbmgr.AddParameters(1, "@disp", item.disp); dbmgr.AddParameters(2, "@disp_desc", item.disp_desc); dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.DISPLIST_u"); } dbmgr.CommitTransaction(); } catch (Exception ex) { dbmgr.RollbackTransaction(); throw ex; } finally { dbmgr.Dispose(); } }
// 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(); } }
// 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(); } }
// 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(); } }
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(); } }
// 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(); } }
// updates cable private void UpdateCable(object obj, IDBManager dbmgr) { Cable item = (Cable)obj; System.Data.Common.DbParameter new_cable_id; try { dbmgr.Open(); dbmgr.BeginTransaction(); // check to see if new object if (item.cable_id == 0) { // if id is null then create new object dbmgr.CreateParameters(4); dbmgr.AddParameters(0, "@id", 0, true); dbmgr.AddParameters(1, "@cable", item.cable); dbmgr.AddParameters(2, "@fr_equip_id", item.fr_equip_id); dbmgr.AddParameters(3, "@to_equip_id", item.to_equip_id); dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.CABLIST_i"); // get item id new_cable_id = (System.Data.Common.DbParameter)dbmgr.Parameters.GetValue(0); item.cable_id = Convert.ToInt32(new_cable_id.Value); } else { // update CABLIST table dbmgr.CreateParameters(12); dbmgr.AddParameters(0, "@cable_id", item.cable_id); dbmgr.AddParameters(1, "@cable", item.cable); dbmgr.AddParameters(2, "@fr_equip_id", item.fr_equip_id); dbmgr.AddParameters(3, "@to_equip_id", item.to_equip_id); dbmgr.AddParameters(4, "@fr_dwg_id", item.fr_dwg_id); dbmgr.AddParameters(5, "@to_dwg_id", item.to_dwg_id); dbmgr.AddParameters(6, "@fr_equip_bd", item.fr_equip_bd); dbmgr.AddParameters(7, "@to_equip_bd", item.to_equip_bd); dbmgr.AddParameters(8, "@cable_len", item.cable_len); dbmgr.AddParameters(9, "@cable_size", item.cable_size); dbmgr.AddParameters(10, "@cable_code", item.cable_code); dbmgr.AddParameters(11, "@comment", item.comment); dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.CABLIST_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(); } }
private void UpdateUser(object obj, IDBManager dbmgr) { User item = (User)obj; try { dbmgr.Open(); dbmgr.CreateParameters(7); dbmgr.BeginTransaction(); dbmgr.AddParameters(0, "@name", item.name); dbmgr.AddParameters(1, "@lname", item.lname); dbmgr.AddParameters(2, "@fname", item.fname); dbmgr.AddParameters(3, "@initial", item.initial); dbmgr.AddParameters(4, "@level", item.level); dbmgr.AddParameters(5, "@password", item.password); dbmgr.AddParameters(6, "@plant", item.plant); dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.USERLIST_u"); dbmgr.CommitTransaction(); } catch (Exception ex) { dbmgr.RollbackTransaction(); throw ex; } finally { dbmgr.Dispose(); } }
private void DeleteUser(object obj, IDBManager dbmgr) { User item = (User)obj; try { dbmgr.Open(); dbmgr.BeginTransaction(); dbmgr.CreateParameters(1); dbmgr.AddParameters(0, "NAME", item.name); dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.USERLIST_d"); dbmgr.CommitTransaction(); } catch (Exception ex) { dbmgr.RollbackTransaction(); throw ex; } finally { dbmgr.Dispose(); } }
//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; } } }
// 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(); } }
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(); } }
// 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(); } }
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(); } }
private void UpdatePSBkrCab(object obj, IDBManager dbmgr) { PSBkrCab item = (PSBkrCab)obj; System.Data.Common.DbParameter new_psbkrcab_id; try { dbmgr.Open(); dbmgr.BeginTransaction(); // check if new item if (item.psbkrcab_id == 0) { // if id is null then create new item dbmgr.CreateParameters(3); dbmgr.AddParameters(0, "@id", 0, true); dbmgr.AddParameters(1, "@psload_id", item.psload_id); dbmgr.AddParameters(2, "@cable_id", item.cable_id); dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.PSBKRCAB_i"); // get item id new_psbkrcab_id = (System.Data.Common.DbParameter)dbmgr.Parameters.GetValue(0); item.psbkrcab_id = Convert.ToInt32(new_psbkrcab_id.Value); } else { // update PSBKRCAB table dbmgr.CreateParameters(3); dbmgr.AddParameters(0, "@psbkrcab_id", item.psbkrcab_id); dbmgr.AddParameters(1, "@psload_id", item.psload_id); dbmgr.AddParameters(2, "@cable_id", item.cable_id); dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.PSBKRCAB_u"); } // 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) { // if there is problem with transaction roll back to original dbmgr.RollbackTransaction(); throw ex; } finally { dbmgr.Dispose(); } }