private void cargar_tipoFactura() { try { string sql = "select * from tipo_factura limit 10;"; MySqlConnection conn = new MySqlConnection(connStr); conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader rdr = cmd.ExecuteReader(); DataTable tab = new DataTable(); tab.Columns.Add("Numero", typeof(string)); tab.Columns.Add("Nombre", typeof(string)); while (rdr.Read()) { tab.Rows.Add(rdr[1], rdr[2]); } rdr.Close(); GridViewFacturas.DataSource = tab; GridViewFacturas.DataBind(); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + (ex.Message) + "');", true); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] != null) { TopMenu.Visible = false; //Login LogingMenu.Visible = true; //Logout } else { TopMenu.Visible = true; //Login LogingMenu.Visible = false; //Logout if (!HttpContext.Current.Request.Url.AbsoluteUri.Contains("login")) { if (Page.IsCallback) { ASPxWebControl.RedirectOnCallback("/Account/login.aspx"); } else { Response.Redirect("/Account/login.aspx"); } } } DateTime?defecha = null; DateTime?afecha = null; if (!Page.IsPostBack) { Session["buttonclick"] = "date"; defecha = Convert.ToDateTime(fechahoy.ToString("01/MMM/yyy")); afecha = Convert.ToDateTime(DateTime.DaysInMonth(fechahoy.Year, fechahoy.Month) + "/" + fechahoy.Month + "/" + fechahoy.Year); } if ((dtfromDate.Date != null || dttoDate.Date != null) && Convert.ToString(Session["buttonclick"]) == "date") { defecha = dtfromDate.Date; afecha = dttoDate.Date; } var Cliente = (Clientes)Session["User"]; GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas("", Cliente.AutoCliente, defecha, afecha); GridViewFacturas.DataBind(); string SerieFactura = string.Empty; if (GridViewFacturas.GetSelectedFieldValues("SerieFactura").Count > 0) { SerieFactura = Convert.ToString(GridViewFacturas.GetSelectedFieldValues("SerieFactura").Select(c => c).FirstOrDefault()); } else { SerieFactura = Convert.ToString(GridViewFacturas.GetRowValues(0, "SerieFactura")); } GridViewFacturasDetail.DataSource = FacturasRepository.GetFacturasDetail(SerieFactura); GridViewFacturasDetail.DataBind(); }
protected void GridViewFacturas_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e) { var Cliente = (Clientes)Session["User"]; if (Cliente == null) { if (Page.IsCallback) { ASPxWebControl.RedirectOnCallback("/Account/login.aspx"); } else { Response.Redirect("/Account/login.aspx"); } } if (e.Parameters.Contains("searchalbaran")) { Session["buttonclick"] = "searchalbaran"; GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas("", Cliente.AutoCliente, null, null); } else if (e.Parameters.Contains("searchfectura")) { Session["buttonclick"] = "searchfectura"; GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas(searchfectura.Text, Cliente.AutoCliente, null, null); } else if (e.Parameters.Contains("date")) { Session["buttonclick"] = "date"; GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas("", Cliente.AutoCliente, dtfromDate.Date, dttoDate.Date); } else { Session["buttonclick"] = "showall"; GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas("", Cliente.AutoCliente, null, null); } GridViewFacturas.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { if (Page.IsCallback) { ASPxWebControl.RedirectOnCallback("/Account/login.aspx"); } else { Response.Redirect("/Account/login.aspx"); } } // if (Request.Browser.IsMobileDevice) // { // if (Page.IsCallback) // { // ASPxWebControl.RedirectOnCallback("/mobile/Facturas.aspx"); // } // else // { // Response.Redirect("/mobile/Facturas.aspx"); // } // } DateTime?defecha = null; DateTime?afecha = null; if (!Page.IsPostBack) { Session["buttonclick"] = "date"; defecha = Convert.ToDateTime(fechahoy.ToString("01/MMM/yyy")); afecha = Convert.ToDateTime(DateTime.DaysInMonth(fechahoy.Year, fechahoy.Month) + "/" + fechahoy.Month + "/" + fechahoy.Year); } if ((dtfromDate.Date != null || dttoDate.Date != null) && Convert.ToString(Session["buttonclick"]) == "date") { defecha = dtfromDate.Date; afecha = dttoDate.Date; } var Cliente = (Clientes)Session["User"]; GridViewFacturas.DataSource = FacturasRepository.GetAllFacturas("", Cliente.AutoCliente, defecha, afecha); GridViewFacturas.DataBind(); string SerieFactura = string.Empty; if (GridViewFacturas.GetSelectedFieldValues("SerieFactura").Count > 0) { SerieFactura = Convert.ToString(GridViewFacturas.GetSelectedFieldValues("SerieFactura").Select(c => c).FirstOrDefault()); } else { SerieFactura = Convert.ToString(GridViewFacturas.GetRowValues(0, "SerieFactura")); } GridViewFacturasDetail.DataSource = FacturasRepository.GetFacturasDetail(SerieFactura); GridViewFacturasDetail.DataBind(); }