private bool validaContratoSisDetalle(eContratoSys contratoSis) { var filters = new Object[3] { 0, 10000, "IDE_CONTRATO ASC" }; var contratoDetSis = new CONTRATO_SIS_DET() { IDE_CONTRATO = Convert.ToInt32(contratoSis._ide_Contrato) }; var listContratoSisDet = new nContratoSisDetalle().getlistContratoDetalle(contratoDetSis, filters, out total); var totalPorcenteje = 0.00m; foreach (var item in listContratoSisDet) { totalPorcenteje += Convert.ToDecimal(item.PRC_PARTICIACION); } if (contratoSis._nro_empresa == listContratoSisDet.Count && Math.Round(totalPorcenteje) == 100) { return(true); } else { return(false); } }
public static object ContratoSisDetalleList(int jtStartIndex, int jtPageSize, string jtSorting, String WhereBy) { var contratoDetalle = new CONTRATO_SIS_DET() { IDE_CONTRATO = Convert.ToInt32(WhereBy.Trim()) }; var filterOptions = new Object[3] { jtStartIndex, jtPageSize, jtSorting }; var listDetalle = new nContratoSisDetalle().getlistContratoDetalle(contratoDetalle, filterOptions, out total); return(new { Result = "OK", Records = listDetalle, TotalRecordCount = total }); }
//Solo la suma de porcentajes private decimal sumPorcentaje(CONTRATO_SIS_DET contratoSisDetalle) { var filterOptions = new Object[3] { 0, 10000, "IDE_CONTRATO ASC" }; var listEmpresa = new nContratoSisDetalle().getlistContratoDetalle(contratoSisDetalle, filterOptions, out total); var sumaPorcentaje = 0.00m; foreach (var item in listEmpresa) { sumaPorcentaje += Convert.ToDecimal(item.PRC_PARTICIACION); } return(sumaPorcentaje); }
private int verificarExisteCompaniaSeguro(CONTRATO_SIS_DET ContratoSisDetalle) { //seteas los filtros del procedure var filterOptions = new Object[3] { 0, 10000, "IDE_CONTRATO ASC" }; //llamas la clase de negocio contrato sisdetalle donde se encuentra el metodo de listar var listCompania = new nContratoSisDetalle().getlistContratoDetalle(ContratoSisDetalle, filterOptions, out total); // el metodo de listar trae todas los registros de contrato sis detalle de un contrato seleccionado //declaras tu variable para buscar si el codigo de compania ya existe var existeCompania = listCompania.FindAll(a => a.COD_CSV == ContratoSisDetalle.COD_CSV); //esta variable va filtrar en esa lista atodos los registros cuyo COD_CSV coniceda con la que se selecciono en la panatalla //finalmente evaluas return(existeCompania.Count); }
public void SetEliminarParamentro(String tabla, String indice) { try { if (tabla.Equals("CONTRATO") && indice != "0") { bContratoVC bc = new bContratoVC(); Int32 resp = bc.SetEliminarContrato(Int32.Parse(indice)); if (resp != 0) { MessageBox(resp + "Registro Eliminado Correctamente!"); SetLLenadoContrato(); } else { MessageBox("Ocurrio un Error en el Servidor!"); } } else if (tabla.Equals("CONTRATO_DETALLE") && indice != "0") { bContratoDetalleVC bcd = new bContratoDetalleVC(); Int32 resp = bcd.SetEliminarContratoDetalle(Int32.Parse(indice)); if (resp != 0) { MessageBox(resp + "Registro Eliminado Correctamente!"); } else { MessageBox("Ocurrio un Error en el Servidor!"); } } else if (tabla.Equals("CONTRATO_SYS") && indice != "0") { var resp = new bContratoSys().SetEliminarContratoSys(Int32.Parse(indice)); MessageBox(resp + "Registro Eliminado Correctamente!"); } else if (tabla.Equals("CONTRATO_SIS_DETALLE") && indice != "0") { var resp = new nContratoSisDetalle().setEliminarContratoDetalle(Int32.Parse(indice)); MessageBox(resp + " Registros (s) eliminado (s) correctamente"); } } catch (Exception ex) { MessageBoxcCatch("Ocurrio el siguiente error " + ex.Message.ToString()); } }
private int verificarSiExisteNroOrden(CONTRATO_SIS_DET contratoSisDetalle) { var filterOptions = new Object[3] { 0, 10000, "IDE_CONTRATO ASC" }; var listEmpresa = new nContratoSisDetalle().getlistContratoDetalle(contratoSisDetalle, filterOptions, out total); var listOrdenExiste = listEmpresa.FindAll(a => a.NRO_ORDEN == contratoSisDetalle.NRO_ORDEN); if (listOrdenExiste.Count > 0) { return(1); } else { return(0); } }
private decimal verificarSumaTotalPorcentaje(CONTRATO_SIS_DET contratoSisDetalle) { var filterOptions = new Object[3] { 0, 10000, "IDE_CONTRATO ASC" }; var listEmpresa = new nContratoSisDetalle().getlistContratoDetalle(contratoSisDetalle, filterOptions, out total); var sumaPorcentaje = 0.00m; var eContratoSisDet = listEmpresa.Find(a => a.IDE_CONTRATO_DET == contratoSisDetalle.IDE_CONTRATO_DET); foreach (var item in listEmpresa) { sumaPorcentaje += Convert.ToDecimal(item.PRC_PARTICIACION); } var residuo = eContratoSisDet != null?Convert.ToDecimal(sumaPorcentaje - eContratoSisDet.PRC_PARTICIACION) : sumaPorcentaje; return(residuo + Convert.ToDecimal(contratoSisDetalle.PRC_PARTICIACION)); }
private int validaNumeroMaximoEmpresa(CONTRATO_SIS_DET ContratoSisDetalle) { var filterOptions = new Object[3] { 0, 10000, "IDE_CONTRATO ASC" }; var contratosis = new CONTRATO_SYS() { IDE_CONTRATO = Convert.ToInt32(ContratoSisDetalle.IDE_CONTRATO) }; var nContratoSis = new nContratoSis().listContratoByID(contratosis); var nContratoDetalle = new nContratoSisDetalle().getlistContratoDetalle(ContratoSisDetalle, filterOptions, out total); numero_empresa = Convert.ToInt32(nContratoSis.NRO_EMPRESAS); if (nContratoDetalle.Count == nContratoSis.NRO_EMPRESAS) { return(1); } else { return(0); } }
private void setInsertarActualizarContratoSisDetalle() { try { var ContratoSisDetalle = new CONTRATO_SIS_DET() { IDE_CONTRATO_DET = Convert.ToInt32(txt_ide_contrato_sis_det.Value), IDE_CONTRATO = Convert.ToInt32(ddl_contrato_sis.SelectedItem.Value), COD_CSV = Convert.ToInt32(ddl_compania_seg_vida.SelectedItem.Value), PRC_PARTICIACION = Convert.ToDecimal(txt_participacion_sis.Text), NRO_ORDEN = Convert.ToInt32(txt_orden_empresa_sis.Text), ESTADO = "A", FEC_REG = DateTime.Now, FEC_MOD = DateTime.Now, USU_REG = Session["username"].ToString(), USU_MOD = Session["username"].ToString() }; if (ContratoSisDetalle.IDE_CONTRATO_DET == 0) { //validar el numero maximo de empresas permitido if (validaNumeroMaximoEmpresa(ContratoSisDetalle) == 1) { MessageBox("El número de máximo empresas CSV es de " + numero_empresa.ToString()); return; } //CREAR UN METODOD RECIBE COMO PARAMETRO LA ENTIDAD DE CONTRATOSISDETALLE //navegar al metodo con f12 //aki lo evaluasa si viene mayor a 0 , quere decir que si encontrato si no pasa. if (verificarExisteCompaniaSeguro(ContratoSisDetalle) > 0) { MessageBox("La CSV " + ddl_compania_seg_vida.SelectedItem.Text + " ya esta en la lista : "); return; } //listo termina la valadacion if (verificarSiExisteNroOrden(ContratoSisDetalle) == 1) { MessageBox("El numero de orden ya existe."); return; } if (verificarSumaTotalPorcentaje(ContratoSisDetalle) > 100.00m) { MessageBox("La suma de los porcentajes ingresados supera el limite maximo de 100"); return; } ; // Validar que la suma de los % de participacion esten correctos var valorPorc = sumPorcentaje(ContratoSisDetalle); var restaRes = 100 - valorPorc; if (Math.Abs(restaRes) > 0.001m) { var resp = new nContratoSisDetalle().setGuardarContratoDetalle(ContratoSisDetalle); nlog.setLLenarEntidad(Convert.ToInt32(ContratoSisDetalle.IDE_CONTRATO), "I", "I02", resp.ToString(), Session["username"].ToString(), "ContratoSisDetalle"); MessageBox("Registro grabado corretamente"); } else { MessageBox("La suma de los porcentajes parciales no es equivalente al 100%"); return; } } else { if (verificarSumaTotalPorcentaje(ContratoSisDetalle) > 100.00m) { MessageBox("La suma de los porcentajes ingresados supera el limite maximo de 100"); return; } else { var resp = new nContratoSisDetalle().setActualizarContratoDetalle(ContratoSisDetalle); nlog.setLLenarEntidad(Convert.ToInt32(ContratoSisDetalle.IDE_CONTRATO), "A", "A05", ContratoSisDetalle.IDE_CONTRATO_DET.ToString(), Session["username"].ToString(), "ContratoSisDetalle"); MessageBox(resp + " Registro actualizado corretamente"); } } } catch (Exception ex) { MessageBox("Ocurrio el siguiente error : " + ex.Message.ToString()); } }