//INSERE UM NOVO REGISTRO public void Insert(PCMSO ObjPCMSO) { Database db = DatabaseFactory.CreateDatabase(); using (DbConnection connection = db.CreateConnection()) { connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { int idPCMSO = 0; if (ObjPCMSO.id == 0) { DbCommand command = db.GetStoredProcCommand("PCMSOInsert"); db.AddInParameter(command, "@idCliente", DbType.String, ObjPCMSO.idCliente); if (ObjPCMSO.id == 0) { //Parametros de OutPut db.AddOutParameter(command, "@id", DbType.Int32, 8); } //Executa a procedure db.ExecuteNonQuery(command, transaction); idPCMSO = Convert.ToInt32(db.GetParameterValue(command, "@id")); } else { idPCMSO = ObjPCMSO.id; } //Delete os registros para que sejam cadastrados novamente DeleteSetor(idPCMSO, ObjPCMSO.RefObjPCMSOXSetor.idSetor, ObjPCMSO.RefObjPCMSOXSetor.idCargo); DeleteRiscos(idPCMSO, ObjPCMSO.RefObjPCMSOXSetor.idCargo); DeleteExames(idPCMSO, ObjPCMSO.RefObjPCMSOXSetor.idCargo); //Inserts //Chama o DAL que vai fazer insert da tabela PCMSOXSetor PCMSOXSetorDAL ObjPCMSOXSetorDAL = new PCMSOXSetorDAL(); ObjPCMSOXSetorDAL.Insert(transaction, ObjPCMSO.RefObjPCMSOXSetor, idPCMSO); //Chama o DAL que vai fazer insert da tabela PCMSOXRiscosOcupacionais PCMSOXRiscosOcupacionaisDAL ObjPCMSOXRiscosOcupacionaisDAL = new PCMSOXRiscosOcupacionaisDAL(); ObjPCMSOXRiscosOcupacionaisDAL.Insert(transaction, ObjPCMSO.RefPCMSOXRiscosOcupacionais, idPCMSO); //Chama o DAL que vai fazer insert da tabela PCMSOXExamesComplementares PCMSOXExamesComplementaresDAL ObjPCMSOXExamesComplementaresDAL = new PCMSOXExamesComplementaresDAL(); ObjPCMSOXExamesComplementaresDAL.Insert(transaction, ObjPCMSO.RefPCMSOXExamesComplementares, idPCMSO); //Commit na transação transaction.Commit(); } catch (Exception ex) { // Roll back na transação transaction.Rollback(); throw ex; } connection.Close(); } }
//Carrega os combos com os exames de mudança de função private void MudancaFuncao(int idPCMSO, int idCargo, int idTipoAtestado) { PCMSO ObjPCMSO = new PCMSO(); PCMSOXExamesComplementaresDAL ObjPCMSOXExamesComplementaresDAL = new PCMSOXExamesComplementaresDAL(); ObjPCMSO = ObjPCMSOXExamesComplementaresDAL.SelectByID(idPCMSO, idCargo, idTipoAtestado); //Admissional if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 1) { ddlMud1.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[0].idExamesComplementares); } else { ddlMud1.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 2) { ddlMud2.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[1].idExamesComplementares); } else { ddlMud2.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 3) { ddlMud3.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[2].idExamesComplementares); } else { ddlMud3.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 4) { ddlMud4.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[3].idExamesComplementares); } else { ddlMud4.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 5) { ddlMud5.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[4].idExamesComplementares); } else { ddlMud5.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 6) { ddlMud6.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[5].idExamesComplementares); } else { ddlMud6.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 7) { ddlMud7.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[6].idExamesComplementares); } else { ddlMud7.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 8) { ddlMud8.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[7].idExamesComplementares); } else { ddlMud8.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 9) { ddlMud9.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[8].idExamesComplementares); } else { ddlMud9.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 10) { ddlMud10.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[9].idExamesComplementares); } else { ddlMud10.ValorInformado = string.Empty; } }
//Carrega os combos com os exames periodicos private void ExamePeriodico(int idPCMSO, int idCargo, int idTipoAtestado) { PCMSO ObjPCMSO = new PCMSO(); PCMSOXExamesComplementaresDAL ObjPCMSOXExamesComplementaresDAL = new PCMSOXExamesComplementaresDAL(); ObjPCMSO = ObjPCMSOXExamesComplementaresDAL.SelectByID(idPCMSO, idCargo, idTipoAtestado); //Admissional if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 1) { ddlPer1.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[0].idExamesComplementares); ddlPeriodicidade1.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[0].idPeriodicidade); } else { ddlPer1.ValorInformado = string.Empty; ddlPeriodicidade1.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 2) { ddlPer2.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[1].idExamesComplementares); ddlPeriodicidade2.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[1].idPeriodicidade); } else { ddlPer2.ValorInformado = string.Empty; ddlPeriodicidade2.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 3) { ddlPer3.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[2].idExamesComplementares); ddlPeriodicidade3.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[2].idPeriodicidade); } else { ddlPer3.ValorInformado = string.Empty; ddlPeriodicidade3.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 4) { ddlPer4.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[3].idExamesComplementares); ddlPeriodicidade4.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[3].idPeriodicidade); } else { ddlPer4.ValorInformado = string.Empty; ddlPeriodicidade4.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 5) { ddlPer5.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[4].idExamesComplementares); ddlPeriodicidade5.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[4].idPeriodicidade); } else { ddlPer5.ValorInformado = string.Empty; ddlPeriodicidade5.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 6) { ddlPer6.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[5].idExamesComplementares); ddlPeriodicidade6.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[5].idPeriodicidade); } else { ddlPer6.ValorInformado = string.Empty; ddlPeriodicidade6.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 7) { ddlPer7.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[6].idExamesComplementares); ddlPeriodicidade7.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[6].idPeriodicidade); } else { ddlPer7.ValorInformado = string.Empty; ddlPeriodicidade7.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 8) { ddlPer8.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[7].idExamesComplementares); ddlPeriodicidade8.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[7].idPeriodicidade); } else { ddlPer8.ValorInformado = string.Empty; ddlPeriodicidade8.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 9) { ddlPer9.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[8].idExamesComplementares); ddlPeriodicidade9.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[8].idPeriodicidade); } else { ddlPer9.ValorInformado = string.Empty; ddlPeriodicidade9.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 10) { ddlPer10.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[9].idExamesComplementares); ddlPeriodicidade10.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[9].idPeriodicidade); } else { ddlPer10.ValorInformado = string.Empty; ddlPeriodicidade10.ValorInformado = string.Empty; } }
//Carrega os combos com os exames de mudança de função private void MudancaFuncao(int idPCMSO, int idCargo, int idTipoAtestado) { PCMSO ObjPCMSO = new PCMSO(); PCMSOXExamesComplementaresDAL ObjPCMSOXExamesComplementaresDAL = new PCMSOXExamesComplementaresDAL(); ObjPCMSO = ObjPCMSOXExamesComplementaresDAL.SelectByID(idPCMSO, idCargo,idTipoAtestado); //Admissional if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 1) { ddlMud1.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[0].idExamesComplementares); } else { ddlMud1.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 2) { ddlMud2.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[1].idExamesComplementares); } else { ddlMud2.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 3) { ddlMud3.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[2].idExamesComplementares); } else { ddlMud3.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 4) { ddlMud4.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[3].idExamesComplementares); } else { ddlMud4.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 5) { ddlMud5.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[4].idExamesComplementares); } else { ddlMud5.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 6) { ddlMud6.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[5].idExamesComplementares); } else { ddlMud6.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 7) { ddlMud7.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[6].idExamesComplementares); } else { ddlMud7.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 8) { ddlMud8.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[7].idExamesComplementares); } else { ddlMud8.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 9) { ddlMud9.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[8].idExamesComplementares); } else { ddlMud9.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 10) { ddlMud10.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[9].idExamesComplementares); } else { ddlMud10.ValorInformado = string.Empty; } }
//Carrega os combos com os exames periodicos private void ExamePeriodico(int idPCMSO, int idCargo, int idTipoAtestado) { PCMSO ObjPCMSO = new PCMSO(); PCMSOXExamesComplementaresDAL ObjPCMSOXExamesComplementaresDAL = new PCMSOXExamesComplementaresDAL(); ObjPCMSO = ObjPCMSOXExamesComplementaresDAL.SelectByID(idPCMSO, idCargo,idTipoAtestado); //Admissional if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 1) { ddlPer1.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[0].idExamesComplementares); ddlPeriodicidade1.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[0].idPeriodicidade); } else { ddlPer1.ValorInformado = string.Empty; ddlPeriodicidade1.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 2) { ddlPer2.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[1].idExamesComplementares); ddlPeriodicidade2.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[1].idPeriodicidade); } else { ddlPer2.ValorInformado = string.Empty; ddlPeriodicidade2.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 3) { ddlPer3.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[2].idExamesComplementares); ddlPeriodicidade3.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[2].idPeriodicidade); } else { ddlPer3.ValorInformado = string.Empty; ddlPeriodicidade3.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 4) { ddlPer4.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[3].idExamesComplementares); ddlPeriodicidade4.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[3].idPeriodicidade); } else { ddlPer4.ValorInformado = string.Empty; ddlPeriodicidade4.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 5) { ddlPer5.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[4].idExamesComplementares); ddlPeriodicidade5.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[4].idPeriodicidade); } else { ddlPer5.ValorInformado = string.Empty; ddlPeriodicidade5.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 6) { ddlPer6.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[5].idExamesComplementares); ddlPeriodicidade6.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[5].idPeriodicidade); } else { ddlPer6.ValorInformado = string.Empty; ddlPeriodicidade6.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 7) { ddlPer7.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[6].idExamesComplementares); ddlPeriodicidade7.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[6].idPeriodicidade); } else { ddlPer7.ValorInformado = string.Empty; ddlPeriodicidade7.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 8) { ddlPer8.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[7].idExamesComplementares); ddlPeriodicidade8.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[7].idPeriodicidade); } else { ddlPer8.ValorInformado = string.Empty; ddlPeriodicidade8.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 9) { ddlPer9.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[8].idExamesComplementares); ddlPeriodicidade9.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[8].idPeriodicidade); } else { ddlPer9.ValorInformado = string.Empty; ddlPeriodicidade9.ValorInformado = string.Empty; } if (ObjPCMSO.RefPCMSOXExamesComplementares.Count >= 10) { ddlPer10.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[9].idExamesComplementares); ddlPeriodicidade10.ValorInformado = Convert.ToString(ObjPCMSO.RefPCMSOXExamesComplementares[9].idPeriodicidade); } else { ddlPer10.ValorInformado = string.Empty; ddlPeriodicidade10.ValorInformado = string.Empty; } }