protected override void AddParameter(TipoDocumentoParametro par, string id, string style) { if (dia > 31) { dia = 1; } switch (par.Nombre) { case CamposCombustible.Dia: AddLiteral((dia++).ToString()); break; case CamposCombustible.Cliente: AddLabel(id, style); break; case CamposCombustible.Actividad: var cb = AddDropDownList(id, style); cb.Items.Clear(); cb.Items.Add(new ListItem(" ", "")); cb.Items.Add(new ListItem("PERFORA - REPASA - REPERFORA - CIRCULA - REG VERTICALIDAD", "PC")); cb.Items.Add(new ListItem("REG VERTICALIDAD TOCTO - ENSAYA - SACA SONDEO - BAJA SONDEO - CALIBRA POZO - ARMA PM - COLOCA VASTAGO", "MA")); cb.Items.Add(new ListItem("MONTAJE BOP - TEST BOP - VINCULA CSG - TEST MNIFOLD", "BP")); cb.Items.Add(new ListItem("PERFILA", "LG")); cb.Items.Add(new ListItem("ENTUBA", "EN")); cb.Items.Add(new ListItem("ESPERA", "ES")); cb.Items.Add(new ListItem("REPARACION MECANICA", "RM")); cb.Items.Add(new ListItem("REPARACION OPERATIVA", "RO")); cb.Items.Add(new ListItem("MANIOBRA HERRAMIENTA APRISIONADA", "AP")); cb.Items.Add(new ListItem("PREPARACION INYECCION - ACUMULA AGUA - PERFILA VAINAS", "AC")); cb.Items.Add(new ListItem("DTM", "DM")); cb.Items.Add(new ListItem("REPARACION ELECTRICA", "RE")); cb.Items.Add(new ListItem("OPERATIVA", "OP")); cb.Items.Add(new ListItem("ESPERA POR FUERZA MAYOR-HUELGA-PARO-CORTE DE RUTA", "FM")); break; case CamposCombustible.StockDiario: case CamposCombustible.TotalCantidad: case CamposCombustible.TotalMotores: case CamposCombustible.TotalGenerador: case CamposCombustible.TotalEgresosPropios: case CamposCombustible.TotalEgresosTerceros: case CamposCombustible.TotalStockDiario: AddLabel(id, style); break; default: base.AddParameter(par, id, style); if (par.Nombre == CamposCombustible.Mes) { (GetControlFromView(TipoDocumentoHelper.GetControlName(par)) as TextBox).Text = DateTime.Now.Month.ToString(); } if (par.Nombre == CamposCombustible.Anio) { (GetControlFromView(TipoDocumentoHelper.GetControlName(par)) as TextBox).Text = DateTime.Now.Year.ToString(); } break; } }
/// <summary> /// Constructor /// </summary> /// <param name="tipoDoc">El tipo de documento a procesar</param> /// <param name="view">La vista donde se va a presentar el documento</param> /// <param name="daof">DAOFactory</param> public GenericPresenter(TipoDocumento tipoDoc, IDocumentView view, DAOFactory daof) { TipoDocumento = tipoDoc; TipoDocumentoHelper = new TipoDocumentoHelper(TipoDocumento); this.view = view; DAOFactory = daof; }
protected override void Validate() { base.Validate(); var cbEquipo = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI19) as DropDownList; if (cbEquipo.SelectedIndex < 0) { throw new ApplicationException("No se encontro el valor de Equipo"); } foreach (TipoDocumentoParametro parametro in TipoDocumento.Parametros) { switch (parametro.Nombre) { case CamposCombustible.Tanque: var cb = GetControlFromView(TipoDocumentoHelper.GetControlName(parametro)) as DropDownList; if (cb == null || cb.SelectedIndex < 0) { throw new ApplicationException("No se encontro el valor de " + parametro.Nombre); } break; case CamposCombustible.Mes: case CamposCombustible.Anio: var txt = GetControlFromView(TipoDocumentoHelper.GetControlName(parametro)) as TextBox; int a; if (txt == null || !int.TryParse(txt.Text, out a)) { throw new ApplicationException("Valor invalido para campo " + parametro.Nombre); } if (parametro.Nombre == CamposCombustible.Mes && (a < 1 || a > 12)) { throw new ApplicationException("Valor invalido para campo " + parametro.Nombre); } if (parametro.Nombre == CamposCombustible.Anio && (a < 1900 || a > 3000)) { throw new ApplicationException("Valor invalido para campo " + parametro.Nombre); } break; case CamposCombustible.StockInicial: var txtd = GetControlFromView(TipoDocumentoHelper.GetControlName(parametro)) as TextBox; double d; if (txtd == null || !double.TryParse(txtd.Text, out d)) { throw new ApplicationException("Valor invalido para campo " + parametro.Nombre); } break; } } }
private void SetCliente() { var cbCliente = GetControlFromView(TipoDocumentoHelper.GetControlName(TipoDocumentoHelper.GetByName(CamposCombustible.Cliente))) as Label; cbCliente.Text = string.Empty; var cbEquipo = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI19) as DropDownList; if (cbEquipo.SelectedIndex < 0) { return; } var equipo = DAOFactory.EquipoDAO.FindById(Convert.ToInt32(cbEquipo.SelectedValue)); cbCliente.Text = equipo.Cliente.Descripcion; }
protected override void SetParameterValue(DocumentoValor val) { if (val.Parametro.Nombre == CamposCombustible.Actividad) { var id = (val.Parametro.Repeticion != 1) ? TipoDocumentoHelper.GetControlName(val.Parametro, val.Repeticion) : TipoDocumentoHelper.GetControlName(val.Parametro); var control = GetControlFromView(id); if (control == null) { return; } SetDropDownValue(control, val.Valor); } else { base.SetParameterValue(val); } }
protected override void AfterValidate(Documento doc) { var txtCodigo = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_CODIGO) as TextBox; var cbEquipo = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI19) as DropDownList; var eq = cbEquipo.SelectedItem.Text; var mes = string.Empty; var anio = string.Empty; foreach (TipoDocumentoParametro parametro in TipoDocumento.Parametros) { switch (parametro.Nombre) { case CamposCombustible.Mes: mes = (GetControlFromView(TipoDocumentoHelper.GetControlName(parametro)) as TextBox).Text; break; case CamposCombustible.Anio: anio = (GetControlFromView(TipoDocumentoHelper.GetControlName(parametro)) as TextBox).Text; break; } } txtCodigo.Text = eq + " - " + mes + "/" + anio; }
private string GetClientID(TipoDocumentoParametro parametro, short repeticion) { return(GetControlFromView(TipoDocumentoHelper.GetControlName(parametro, repeticion)).ClientID); }
private string GetClientID(TipoDocumentoParametro parametro) { return(GetControlFromView(TipoDocumentoHelper.GetControlName(parametro)).ClientID); }
/// <summary> /// Parsea el documento /// </summary> public override void Parse() { OnLiteral(string.Concat("<table style='padding: 10px; width:100%; border: solid 1px #DDDDDD;height: auto;' align='center'><tr><td><div style='font-size: 14px; font-weight: bold; text-align: center;'>", TipoDocumentoHelper.TipoDocumento.Nombre)); OnLiteral(string.Concat("</div></td></tr></table>")); OnLiteral("<br/><table style='padding: 0px; width:100%; border: solid 1px #DDDDDD;background-color: #E7E7E7;' align='center'>"); OnLiteral("<tr><td>Distrito</td><td>"); OnBase(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_PARENTI01, string.Empty)); OnLiteral("</td></tr>"); OnLiteral("<tr><td>Base</td><td>"); OnPlanta(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_PARENTI02, string.Empty)); OnLiteral("</td></tr>"); OnLiteral("<tr><td>Codigo</td><td>"); OnCodigo(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_CODIGO, string.Empty)); OnLiteral("</td></tr>"); //OnLiteral("<tr><td>Descripcion<td><td>"); //OnDescripcion(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_DESCRIPCION, string.Empty)); //OnLiteral("</td></tr>"); OnLiteral("<tr><td>Fecha</td><td>"); OnFecha(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_FECHA, string.Empty)); OnLiteral("</td></tr>"); //OnLiteral("<tr><td>Presentacion<td><td>"); //OnPresentacion(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_PRESENTACION, string.Empty)); //OnLiteral("</td></tr>"); OnLiteral("<tr><td>Vencimiento</td><td>"); OnVencimiento(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_VENCIMIENTO, string.Empty)); OnLiteral("</td></tr>"); //OnLiteral("<tr><td>Estado<td><td>"); //OnEstado(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_ESTADO, string.Empty)); //OnLiteral("</td></tr>"); //-------------------------------------------- if (TipoDocumentoHelper.TipoDocumento.AplicarATransportista) { OnLiteral("<tr><td>Transportista</td><td>"); OnTransportista(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_PARENTI07, string.Empty)); OnLiteral("</td></tr>"); } if (TipoDocumentoHelper.TipoDocumento.AplicarAVehiculo) { OnLiteral("<tr><td>Vehiculo</td><td>"); OnVehiculo(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_PARENTI03, string.Empty)); OnLiteral("</td></tr>"); } if (TipoDocumentoHelper.TipoDocumento.AplicarAEmpleado) { OnLiteral("<tr><td>Empleado</td><td>"); OnEmpleado(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_PARENTI09, string.Empty)); OnLiteral("</td></tr>"); } if (TipoDocumentoHelper.TipoDocumento.AplicarAEquipo) { OnLiteral("<tr><td>Equipo</td><td>"); OnEquipo(new DocumentoParametroEventArgs(TipoDocumentoHelper.CONTROL_NAME_PARENTI19, string.Empty)); OnLiteral("</td></tr>"); } //--------------- OnLiteral("</table>"); OnLiteral("<br />"); var parametros = TipoDocumentoHelper.GetParametros(); OnLiteral("<table style='padding: 0px; width:100%;border: solid 1px #DDDDDD;background-color: #EEEEEE;' align='center'>"); var repetidos = new List <TipoDocumentoParametro>(); var lastOrder = -1; var repeating = false; foreach (var parametro in parametros) { var order = (int)Math.Floor(parametro.Orden); if (repeating && lastOrder != order) { OnLiteral("<tr><td colspan='2'><br/><table border='1' align='center' cellspacing='0' cellpadding='2' style='text-align: center;'>"); int repeatTimes = repetidos[0].Repeticion; for (short i = -1; i < repeatTimes; i++) { OnLiteral("<tr>"); foreach (var repetido in repetidos) { OnLiteral("<td>"); if (i == -1) { OnLiteral(repetido.Nombre); } else { var id = TipoDocumentoHelper.GetControlName(repetido, i); OnParametro(new DocumentoParametroEventArgs(id, "width: 100px", repetido)); } OnLiteral("</td>"); } OnLiteral("</tr>"); } OnLiteral("</table><br/></td></tr>"); repetidos.Clear(); } if (parametro.Repeticion == 0 || parametro.Repeticion == 1) { var id = TipoDocumentoHelper.GetControlName(parametro); OnLiteral(string.Concat("<tr><td>", parametro.Nombre, "</td><td>")); OnParametro(new DocumentoParametroEventArgs(id, string.Empty, parametro)); OnLiteral("</td></tr>"); } else { repetidos.Add(parametro); } lastOrder = order; repeating = parametro.Repeticion != 1; } if (repeating) { OnLiteral("<tr><td colspan='2'><table>"); int repeatTimes = repetidos[0].Repeticion; for (short i = -1; i < repeatTimes; i++) { OnLiteral("<tr>"); foreach (var repetido in repetidos) { OnLiteral("<td>"); if (i == -1) { OnLiteral(repetido.Nombre); } else { var id = TipoDocumentoHelper.GetControlName(repetido, i); OnParametro(new DocumentoParametroEventArgs(id, string.Empty, repetido)); } OnLiteral("</td>"); } OnLiteral("</tr>"); } OnLiteral("</table></td></tr>"); repetidos.Clear(); } OnLiteral("</table>"); }
public MobileParser(TipoDocumentoHelper tipoDocHelper) : base(tipoDocHelper) { }
protected override string GetParameterValue(TipoDocumentoParametro parameter, short repeticion) { if (dia > 31) { dia = 1; } switch (parameter.Nombre) { case CamposCombustible.Dia: return((dia++).ToString()); case CamposCombustible.Actividad: var combo = GetControlFromView(TipoDocumentoHelper.GetControlName(parameter, repeticion)) as DropDownList; return(combo.SelectedValue); case CamposCombustible.StockDiario: case CamposCombustible.TotalCantidad: case CamposCombustible.TotalMotores: case CamposCombustible.TotalGenerador: case CamposCombustible.TotalEgresosPropios: case CamposCombustible.TotalEgresosTerceros: case CamposCombustible.TotalStockDiario: return("0"); case CamposCombustible.Cliente: var cbEquipo = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI19) as DropDownList; var equipo = DAOFactory.EquipoDAO.FindById(Convert.ToInt32(cbEquipo.SelectedValue)); return(equipo.Cliente.Id.ToString()); default: var val = base.GetParameterValue(parameter, repeticion); double d = GetFloat(val); if (d == -999) { d = 0; } if (parameter.Nombre == CamposCombustible.Cantidad) { cantidad += d; if (!diario.ContainsKey(repeticion)) { diario.Add(repeticion, 0); } diario[repeticion] += d; return(d.ToString()); } if (parameter.Nombre == CamposCombustible.Motores) { motores += d; if (!diario.ContainsKey(repeticion)) { diario.Add(repeticion, 0); } diario[repeticion] += d; return(d.ToString()); } if (parameter.Nombre == CamposCombustible.Generador) { generador += d; if (!diario.ContainsKey(repeticion)) { diario.Add(repeticion, 0); } diario[repeticion] += d; return(d.ToString()); } if (parameter.Nombre == CamposCombustible.EgresosPropios) { propios += d; if (!diario.ContainsKey(repeticion)) { diario.Add(repeticion, 0); } diario[repeticion] += d; return(d.ToString()); } if (parameter.Nombre == CamposCombustible.EgresosTerceros) { terceros += d; if (!diario.ContainsKey(repeticion)) { diario.Add(repeticion, 0); } diario[repeticion] += d; return(d.ToString()); } return(val); } }
/// <summary> /// Saves the Document. /// </summary> /// <param name="doc"></param> /// <param name="user"></param> public virtual void Save(Documento doc) { TipoDocumentoHelper = new TipoDocumentoHelper(TipoDocumento); editMode = doc.Id > 0; Validate(); AfterValidate(doc); var cbEmpresa = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI01) as DropDownList; var cbLinea = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI02) as DropDownList; var txtCodigo = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_CODIGO) as TextBox; var txtDescripcion = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_DESCRIPCION) as TextBox; var txtFecha = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_FECHA) as TextBox; var txtVencimiento = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_VENCIMIENTO) as TextBox; var txtPresentacion = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PRESENTACION) as TextBox; var txtCierre = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_CIERRE) as TextBox; var cbEstado = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_ESTADO) as DropDownList; var cbVehiculo = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI03) as DropDownList; var cbEmpleado = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI09) as DropDownList; var cbTransportista = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI07) as DropDownList; var cbEquipo = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI19) as DropDownList; var idLinea = Convert.ToInt32(cbLinea.SelectedValue); doc.Empresa = DAOFactory.EmpresaDAO.FindById(Convert.ToInt32(cbEmpresa.SelectedValue)); doc.Linea = idLinea > 0 ? DAOFactory.LineaDAO.FindById(idLinea) : null; doc.Codigo = GetRequiredNotEmpty("Codigo", txtCodigo.Text); if (TipoDocumento.AplicarAVehiculo) { var vehiculo = GetRequiredInt("Vehiculo", cbVehiculo.SelectedValue); if (vehiculo > 0) { doc.Vehiculo = DAOFactory.CocheDAO.FindById(vehiculo); } } if (TipoDocumento.AplicarAEmpleado) { var empleado = GetRequiredInt("Empleado", cbEmpleado.SelectedValue); if (empleado > 0) { doc.Empleado = DAOFactory.EmpleadoDAO.FindById(empleado); } } if (TipoDocumento.AplicarATransportista) { var transportista = GetRequiredInt("Transportista", cbTransportista.SelectedValue); if (transportista > 0) { doc.Transportista = DAOFactory.TransportistaDAO.FindById(transportista); } } if (TipoDocumento.AplicarAEquipo) { var equipo = GetRequiredInt("Equipo", cbEquipo.SelectedValue); if (equipo > 0) { doc.Equipo = DAOFactory.EquipoDAO.FindById(equipo); } } var docs = DAOFactory.DocumentoDAO.FindByTipoYCodigo(TipoDocumento.Id, doc.Codigo); if (docs.Count > 0 && (docs[0] as Documento).Id != doc.Id) { throw new ApplicationException("Ya existe un documento con el mismo Codigo"); } doc.Descripcion = txtDescripcion != null?txtDescripcion.Text.Trim() : doc.Codigo; doc.Fecha = GetRequiredValidDate("Fecha", txtFecha.Text); var presentacion = txtPresentacion != null ? TipoDocumento.RequerirPresentacion ? GetRequiredValidDate("Fecha de Presentacion", txtPresentacion.Text) : GetValidDate(txtPresentacion.Text) : DateTime.UtcNow; doc.Presentacion = presentacion == DateTime.MinValue ? (DateTime?)null : presentacion; var vencimiento = TipoDocumento.RequerirVencimiento ? GetRequiredValidDate("Fecha de Vencimiento", txtVencimiento.Text) : txtVencimiento != null?GetValidDate(txtVencimiento.Text) : DateTime.MinValue; var actualizaVencimiento = doc.Vencimiento != vencimiento; doc.Vencimiento = vencimiento == DateTime.MinValue ? (DateTime?)null : vencimiento; if (actualizaVencimiento) { doc.EnviadoAviso1 = false; doc.EnviadoAviso2 = false; doc.EnviadoAviso3 = false; } var cierre = txtCierre != null?GetValidDate(txtCierre.Text) : DateTime.MinValue; doc.FechaCierre = cierre == DateTime.MinValue ? (DateTime?)null : cierre; doc.TipoDocumento = TipoDocumento; doc.Estado = cbEstado != null?Convert.ToInt16(cbEstado.SelectedValue) : (short)0; if (doc.Id == 0) { doc.FechaAlta = DateTime.UtcNow; doc.Usuario = DAOFactory.UsuarioDAO.FindById(WebSecurity.AuthenticatedUser.Id); } else { doc.FechaModificacion = DateTime.UtcNow; doc.UsuarioModificacion = DAOFactory.UsuarioDAO.FindById(WebSecurity.AuthenticatedUser.Id); } foreach (TipoDocumentoParametro parametro in doc.TipoDocumento.Parametros) { if (parametro.Repeticion == 1) { var valor = GetParameterValue(parametro, 1); if (valor != null) { SetValor(doc, parametro.Nombre, 1, valor); } } else { for (short i = 0; i < parametro.Repeticion; i++) { var valor = GetParameterValue(parametro, i); SetValor(doc, parametro.Nombre, i, valor); } } } BeforeSave(doc); DAOFactory.DocumentoDAO.SaveOrUpdate(doc); }