Esempio n. 1
0
        protected void btn_Registrar_ServerClick(object sender, EventArgs e)
        {
            try
            {
                asignar_folio();
                SqlConnection Conn = new SqlConnection
                {
                    ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["GESTION.Properties.Settings.CadenadeConeccion"].ToString()
                };
                SqlCommand    cmd = new SqlCommand();
                SqlDataReader dr;
                Conn.Open();
                cmd.Connection = Conn;
                DateTime Hoy = DateTime.Today;
                cmd.CommandText = "INSERT INTO Guia_Despachos(Correlativo_Guia_Despacho,Usuario_Solicitante,Fecha_Solicitud,Empresa,Nombre_Cliente,Rut_Cliente,Nombre_Conductor,Patente_Vehiculo,Detalle_guia_Despacho)  VALUES ('" + Session["Correlativo_Guia_Despacho"] + "','" + Session["Usuario"] + "','" + Hoy.ToString("") + "','" + ddlEmpresa.SelectedItem + "','" + txt_Nombre.Text + "','" + txt_Rut.Text + "','" + txt_Conductor.Text + "','" + txt_Patente.Text + "','" + txt_Detalle.Text + "')";
                dr = cmd.ExecuteReader();
                dr.Read();
                lbl_ID.Text           = Session["Correlativo_Guia_Despacho"].ToString();
                Registro_OK.Visible   = true;
                Registro_NOOK.Visible = false;
                Eliminar_OK.Visible   = false;
                Sin_Permisos.Visible  = false;

                Conn.Close();
                txt_Conductor.Text = "";
                txt_Detalle.Text   = "";
                txt_Nombre.Text    = "";
                txt_Patente.Text   = "";
                txt_Rut.Text       = "";
                GV_Guias_Despachos.DataBind();
            } catch (Exception) {
                Registro_OK.Visible   = false;
                Registro_NOOK.Visible = true;
                Eliminar_OK.Visible   = false;
                Sin_Permisos.Visible  = false;
            }
        }
Esempio n. 2
0
        protected void GV_Guias_Despachos_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int           num  = Convert.ToInt32(e.CommandArgument);
            SqlConnection Conn = new SqlConnection
            {
                ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["GESTION.Properties.Settings.CadenadeConeccion"].ToString()
            };
            SqlCommand    cmd = new SqlCommand();
            SqlDataReader dr;

            if (e.CommandName == "Imprimir")
            {
                Session["Numero_Guia_Imprimir"] = e.CommandArgument.ToString();
                string str;
                str = "window.open('~/Guia_Despacho.aspx','Guia de Despacho','width=980px,height=980px,sc rollbars=no,resizable=no')";
                Response.Write("<script languaje=javascript>" + str + "</script>");
            }
            if (e.CommandName == "Detalle")
            {
                string script = @"window.location.href = '#modalHtml2';";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true);
                Conn.Open();
                cmd.Connection  = Conn;
                cmd.CommandText = "select * FROM Guia_Despachos with(nolock) WHERE Correlativo_Guia_Despacho='" + num + "'";
                dr = cmd.ExecuteReader();
                dr.Read();
                lbl_ID_Mod.Text       = dr["Correlativo_Guia_Despacho"].ToString();
                ddl_empresa_mod.Text  = dr["Empresa"].ToString();
                txtconductor_mod.Text = dr["Nombre_Conductor"].ToString();
                txtdetalle_mod.Text   = dr["Detalle_guia_Despacho"].ToString();
                txtnombre_mod.Text    = dr["Nombre_Conductor"].ToString();
                txtpatente_mod.Text   = dr["Patente_Vehiculo"].ToString();
                txtrut_mod.Text       = dr["Rut_Cliente"].ToString();
            }
            if (e.CommandName == "Eliminar")
            {
                string validar = Session["Eliminar"].ToString();
                if (validar == "SI")
                {
                    Conn.Open();
                    cmd.Connection  = Conn;
                    cmd.CommandText = "DELETE FROM Guia_Despachos WHERE Correlativo_Guia_Despacho='" + num + "'";
                    dr = cmd.ExecuteReader();
                    dr.Read();
                    Conn.Close();
                    GV_Guias_Despachos.DataBind();
                    gvDescargar.DataBind();
                    Eliminar_OK.Visible   = true;
                    Registro_OK.Visible   = false;
                    Registro_NOOK.Visible = false;
                    Sin_Permisos.Visible  = false;
                }
                else
                {
                    Sin_Permisos.Visible  = true;
                    Eliminar_OK.Visible   = false;
                    Registro_OK.Visible   = false;
                    Registro_NOOK.Visible = false;
                }
            }
        }