Esempio n. 1
0
        protected void btn_actualizarEnv_AgregarEtapa_Click(object sender, EventArgs e)
        {
            int  nroEnvio;
            bool resultNroEnvio = int.TryParse(this.txt_actualizarEnv_nroEnv.Text, out nroEnvio);

            DateTime fechaIngreso = this.calendar_actualizarEnv_fchIngreso.SelectedDate;

            int           nroOficina;
            bool          resultOfi       = int.TryParse(this.ddl_actualizarEnv_Oficinas.SelectedValue, out nroOficina);
            OficinaPostal oficinaEntrante = elSis.BuscarOficinaXID(nroOficina);

            EtapaEnvio.Etapas etapaIngresada;
            bool resultEtapa = Enum.TryParse <EtapaEnvio.Etapas>(this.ddl_actualizarEnv_etapaEnv.SelectedValue, out etapaIngresada);

            string nombreRecibio = this.txt_actualizarEnv_nomRecibio.Text;
            string firmaRecibio  = "";
            string path          = "";
            string nomArchivo    = "";

            if (this.fileup_actualizarEnvio_firma.HasFile)
            {
                firmaRecibio = this.fileup_actualizarEnvio_firma.FileName;
                path         = HttpRuntime.AppDomainAppPath + "/fotosFirmas/";
                nomArchivo   = nroEnvio.ToString() + firmaRecibio.Substring(firmaRecibio.LastIndexOf("."));
            }

            Envio envioDeseado = null;

            if (resultNroEnvio)
            {
                envioDeseado = elSis.BuscarEnvio(nroEnvio);

                bool exito = false;

                if (envioDeseado != null)
                {
                    if (fechaIngreso.ToString() != "01/01/0001 12:00:00 a.m.")
                    {
                        if (resultOfi)       // esto siempre va a dar true porque es de un ddl
                        {
                            if (resultEtapa) // esto siempre va a dar true porque es de un ddl
                            {
                                if ((etapaIngresada == EtapaEnvio.Etapas.Entregado && path != "") || etapaIngresada != EtapaEnvio.Etapas.Entregado)
                                {
                                    this.fileup_actualizarEnvio_firma.SaveAs(path + nomArchivo);
                                    string mensajeError = null;
                                    exito = envioDeseado.AgregarEtapa(fechaIngreso, etapaIngresada, oficinaEntrante, nomArchivo, nombreRecibio, out mensajeError);

                                    if (exito)
                                    {
                                        this.p_actualizarEnv_message.InnerText = "Exito!!";
                                    }
                                    else
                                    {
                                        this.p_actualizarEnv_message.InnerText = mensajeError;
                                    }
                                }
                                else
                                {
                                    this.p_actualizarEnv_message.InnerText = "Debe ingresar un archivo";
                                }
                            }
                            else
                            {
                                this.p_actualizarEnv_message.InnerText = "Debe seleccionar una etapa para el envio";
                            }
                        }
                        else
                        {
                            this.p_actualizarEnv_message.InnerText = "Debe seleccionar una oficina postal";
                        }
                    }
                    else
                    {
                        this.p_actualizarEnv_message.InnerText = "Debe seleccionar una fecha";
                    }
                }
                else
                {
                    this.p_actualizarEnv_message.InnerText = "El número de envío ingresado no existe";
                }
            }
            else
            {
                this.p_actualizarEnv_message.InnerText = "El número de envío debe tener sólo números";
            }
        }