示例#1
0
        private void butGuardarPrioridades_Click(object sender, System.EventArgs e)
        {
            for (int i = 0; i < lstTiempoEntrega.Items.Count; i++)
            {
                ITiempoEntrega oTiempoEntrega = TiempoEntregaFactory.GetTiempoEntrega();
                oTiempoEntrega.TiempoEntregaID      = Convert.ToInt32(lstTiempoEntrega.Items[i].Value);
                oTiempoEntrega.TiempoEntregaDescrip = lstTiempoEntrega.Items[i].Text.Trim();
                oTiempoEntrega.UnidadNegocioID      = this.UnidadNegocioID;
                oTiempoEntrega.TiempoMaximoEntrega  = Utiles.Validaciones.obtieneEntero(this.txtTiempoMaximoEntrega.Text);
                oTiempoEntrega.ActualizaPrioridad   = true;
                oTiempoEntrega.Prioridad            = i + 1;


                try
                {
                    if (oTiempoEntrega.Guardar())
                    {
                        string script = "<script language='javascript'>\n";
                        //script += "alert('Los datos se guardaron correctamente.');";
                        script += "window.location.href = 'TiempoEntregaConsul.aspx';\n";
                        script += "</script>";

                        Page.RegisterStartupScript("scriptOk", script);
                    }
                    else
                    {
                        string script = "<script language='javascript'>\n";
                        script += "alert('Los datos no se guardaron debido a errores.');\n";
                        script += "</script>";

                        Page.RegisterStartupScript("scriptError", script);
                    }
                }
                catch (Exception ex)
                {
                    string mensaje = ex.Message;
                    try
                    {
                        mensaje = this.TraducirTexto(ex.Message);
                        if (mensaje == "" || mensaje == null)
                        {
                            mensaje = ex.Message;
                        }
                    }
                    catch (Exception)
                    {
                        mensaje = ex.Message;
                    }
                    ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje);
                }
            }
        }
示例#2
0
        private void butGuardarTiempoEntrega_Click(object sender, System.EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            ITiempoEntrega tiempoEntrega = TiempoEntregaFactory.GetTiempoEntrega();

            tiempoEntrega.TiempoEntregaID      = Convert.ToInt32(this.txtTiempoEntregaID.Text);
            tiempoEntrega.TiempoEntregaDescrip = this.txtTiempoEntregaDescrip.Text;
            tiempoEntrega.TiempoMaximoEntrega  = Convert.ToInt32(this.txtTiempoMaximoEntrega.Text);
            tiempoEntrega.UnidadNegocioID      = this.UnidadNegocioID;
            if (this.txtTiempoEntregaID.Text != "0")
            {
                for (int i = 0; i < lstTiempoEntrega.Items.Count; i++)
                {
                    if (this.txtTiempoEntregaID.Text == lstTiempoEntrega.Items[i].Value)
                    {
                        tiempoEntrega.Prioridad = i + 1;
                    }
                }
            }

            try
            {
                if (tiempoEntrega.Guardar())
                {
                    string script = "<script language='javascript'>\n";
                    script += "alert('Los datos se guardaron correctamente.');";
                    //script += "window.location.href = 'TiempoEntregaConsul.aspx';\n";
                    script += "</script>";

                    this.txtTiempoEntregaID.Text = tiempoEntrega.TiempoEntregaID.ToString();
                    Page.RegisterStartupScript("scriptOk", script);
                    tiempoEntrega.Consultar();
                    int priori = tiempoEntrega.Prioridad;
                    this.CargarPrioridades();
                }
                else
                {
                    string script = "<script language='javascript'>\n";
                    script += "alert('Los datos no se guardaron debido a errores.');\n";
                    script += "</script>";

                    Page.RegisterStartupScript("scriptError", script);
                }
            }
            catch (Exception ex)
            {
                string mensaje = ex.Message;
                try
                {
                    mensaje = this.TraducirTexto(ex.Message);
                    if (mensaje == "" || mensaje == null)
                    {
                        mensaje = ex.Message;
                    }
                }
                catch (Exception)
                {
                    mensaje = ex.Message;
                }
                ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje);
            }
        }