private void BindGridRow(int currentPage) { try { if (Session["DsGridView"] != null) { IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); DataSet ds = Session["DsGridView"] as DataSet; guiastransfarmaco.GuiaID = Convert.ToInt32(Session["GuiaID"]); guiastransfarmaco.FechaDesde = Convert.ToDateTime(Session["FechaDesde"]); guiastransfarmaco.FechaHasta = Convert.ToDateTime(Session["FechaHasta"]); Session["Index"] = currentPage; ds = guiastransfarmaco.GetGuias(); if (ds.Tables[0].Rows.Count != 0) { this.dtgGuiasTransfarmacoObservacion.DataSource = ds.Tables[0]; this.dtgGuiasTransfarmacoObservacion.CurrentPageIndex = currentPage; this.dtgGuiasTransfarmacoObservacion.DataBind(); } } else { this.BindGrid(currentPage); } } catch (Exception ex) { throw ex; } }
protected void btnBuscarDesdeHasta_Click(object sender, EventArgs e) { if (txtBuscarNroGuia.Text != "") { txtFiltroDesde.Text = ""; txtFiltroHasta.Text = ""; } if (txtFiltroDesde.Text != "" && txtFiltroHasta.Text == "") { lblError.Visible = true; lblError.Text = "*Debe Ingresar Una Fecha en 'Hasta:'<br/>"; return; } else if (txtFiltroDesde.Text == "" && txtFiltroHasta.Text != "") { lblError.Visible = true; lblError.Text = "*Debe Ingresar Una Fecha en 'Desde:'<br/>"; return; } else { lblError.Visible = false; lblError.Text = string.Empty; } SisPackController.AdministrarGrillas.Configurar(this.dtgGuiasTransfarmacoObservacion, "guiaid", 20); IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); DataSet ds = new DataSet(); string desde = this.txtFiltroDesde.Text == "" ? "01/01/1900" : this.txtFiltroDesde.Text; string hasta = this.txtFiltroHasta.Text == "" ? "01/01/1900" : this.txtFiltroHasta.Text; DateTime desdeDateTime = DateTime.ParseExact(desde, "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime hastaDateTime = DateTime.ParseExact(hasta, "dd/MM/yyyy", CultureInfo.InvariantCulture); guiastransfarmaco.FechaDesde = desdeDateTime; guiastransfarmaco.FechaHasta = hastaDateTime; guiastransfarmaco.NroGuia = txtBuscarNroGuia.Text == "" ? 0 : Convert.ToInt32(txtBuscarNroGuia.Text); ds = guiastransfarmaco.GetGuias(); this.dtgGuiasTransfarmacoObservacion.DataSource = ds.Tables[0]; this.dtgGuiasTransfarmacoObservacion.CurrentPageIndex = 0; this.dtgGuiasTransfarmacoObservacion.DataBind(); this.Session["DsGridView"] = ds; this.Session["GuiaID"] = guiastransfarmaco.GuiaID; this.Session["FechaDesde"] = guiastransfarmaco.FechaDesde; this.Session["FechaHasta"] = guiastransfarmaco.FechaHasta; Session.Remove("Index"); }
private void BindGrid(int currentPage) { SisPackController.AdministrarGrillas.Configurar(this.dtgGuiasTransfarmacoObservacion, "guiaid", 400); IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); DataSet ds = new DataSet(); guiastransfarmaco.GuiasTransfarmacoObservacionID = 0; guiastransfarmaco.GuiaID = 0; guiastransfarmaco.FechaDesde = DateTime.Parse("1900-01-01 00:00:00.000"); guiastransfarmaco.FechaHasta = DateTime.Parse("1900-01-01 00:00:00.000"); ds = guiastransfarmaco.GetGuias(); this.Session["DsGridView"] = ds; this.Session["GuiaID"] = 0; this.Session["FechaDesde"] = "1900-01-01 00:00:00.000"; this.Session["FechaHasta"] = "1900-01-01 00:00:00.000"; this.dtgGuiasTransfarmacoObservacion.DataSource = ds.Tables[0]; this.dtgGuiasTransfarmacoObservacion.CurrentPageIndex = currentPage; this.dtgGuiasTransfarmacoObservacion.DataBind(); Session.Remove("Index"); }
protected void btnGuardarObservacion_Click(object sender, EventArgs e) { try { this.btnGuardarObservacion.Enabled = false; DataSet ds = new DataSet(); if (txtObservaciones.Text == "" || txtObservaciones.Text == string.Empty) { if (btnGuardarObservacion.Text == "Guardar") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Debe ingresar una Observación para Guardar');", true); this.btnGuardarObservacion.Enabled = true; return; } else if (btnGuardarObservacion.Text == "Guardar Modificación") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Debe ingresar una Observación para Guardar Modificación');", true); this.btnGuardarObservacion.Enabled = true; return; } } IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); IUsuarios usuario = (IUsuarios)Session["Usuario"]; guiastransfarmaco.UsuarioID = usuario.UsuarioID; guiastransfarmaco.GuiaID = Convert.ToInt32(this.hidGuiaID.Value); guiastransfarmaco.Observaciones = this.txtObservaciones.Text; guiastransfarmaco.GuiasTransfarmacoObservacionID = Convert.ToInt32(this.hidGuiasTransfarmacoObservacionID.Value); if (guiastransfarmaco.Guardar()) { this.txtNroGuia.Text = string.Empty; this.txtObservaciones.ReadOnly = true; this.txtObservaciones.Text = string.Empty; this.btnGuardarObservacion.Visible = false; this.hidGuiasTransfarmacoObservacionID.Value = string.Empty; this.hidGuiaID.Value = string.Empty; if (this.btnGuardarObservacion.Text == "Guardar") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Datos guardados correctamente.');", true); } else if (this.btnGuardarObservacion.Text == "Guardar Modificación") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Datos modificados correctamente.');", true); this.btnGuardarObservacion.Text = "Guardar"; } guiastransfarmaco.GuiaID = Convert.ToInt32(Session["GuiaID"]); guiastransfarmaco.FechaDesde = Convert.ToDateTime(Session["FechaDesde"]); guiastransfarmaco.FechaHasta = Convert.ToDateTime(Session["FechaHasta"]); ds = guiastransfarmaco.GetGuias(); this.Session["DsGridView"] = ds; this.dtgGuiasTransfarmacoObservacion.DataSource = ds.Tables[0]; if (Session["Index"] != null) { //Verificamos si el datagrid tiene ese numero de paginas if (this.dtgGuiasTransfarmacoObservacion.PageCount >= Convert.ToInt32(Session["Index"])) { this.dtgGuiasTransfarmacoObservacion.CurrentPageIndex = Convert.ToInt32(Session["Index"]); } else { this.dtgGuiasTransfarmacoObservacion.CurrentPageIndex = 0; } } else { this.dtgGuiasTransfarmacoObservacion.CurrentPageIndex = 0; } this.dtgGuiasTransfarmacoObservacion.DataBind(); this.btnGuardarObservacion.Enabled = true; } } catch (Exception ex) { throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region User IsAuthenticated if (Session["Usuario"] != null) { this.usuario = (IUsuarios)Session["Usuario"]; } if (User.Identity.IsAuthenticated) { string sOpcion = "guiasTransfarmacoObservacion"; SisPacK.Menu oMenu = (SisPacK.Menu) this.FindControl("Menu1"); this.ValidarSeguridad(oMenu, sOpcion); } #endregion this.Session.Remove("dtgPagos"); this.btnAgregar.Text = "Agregar"; this.btnGuardar.Visible = false; this.btnAgregar.Enabled = true; btnGuardar.Enabled = true; IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); guiastransfarmaco.NroGuia = Convert.ToInt32(this.Request.QueryString["numeroguia"]) == null ? 0 : Convert.ToInt32(this.Request.QueryString["numeroguia"]); if (guiastransfarmaco.NroGuia != 0) { this.btnAgregar.Visible = true; } try { if (guiastransfarmaco.NroGuia != 0) { DataSet ds = new DataSet(); guiastransfarmaco.GuiasTransfarmacoObservacionID = 0; guiastransfarmaco.FechaDesde = DateTime.Parse("1900-01-01 00:00:00.000"); guiastransfarmaco.FechaHasta = DateTime.Parse("1900-01-01 00:00:00.000"); ds = guiastransfarmaco.GetGuias(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { this.txtGuiaID.Text = ds.Tables[0].Rows[i]["numeroguia"].ToString(); this.txtImporteTotal.Text = ds.Tables[0].Rows[i]["importetotalguia"].ToString(); this.txtFechaEmision.Text = ds.Tables[0].Rows[i]["fechaemision"].ToString(); this.txtFechaEntrega.Text = ds.Tables[0].Rows[i]["fechaentrega"].ToString(); this.txtObservaciones.Text = ds.Tables[0].Rows[i]["observacion"].ToString(); } ds.Clear(); ds = guiastransfarmaco.GetGuiasTransfarmacoPagosALL(); decimal total = 0; if (ds.Tables[0].Rows.Count > 0) { int contar = 1; SisPackController.AdministrarGrillas.Configurar(this.dtgPagos, "tipo", 20); ds.Tables[0].Columns.Add("detallenro", typeof(int)); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { total += Convert.ToDecimal(ds.Tables[0].Rows[i]["importe"].ToString()); ds.Tables[0].Rows[i]["detallenro"] = contar; contar += 1; if (ds.Tables[0].Rows[i]["tipo"].ToString() == "EF") { ds.Tables[0].Rows[i]["tipo"] = "Efectivo"; } else if (ds.Tables[0].Rows[i]["tipo"].ToString() == "CH") { ds.Tables[0].Rows[i]["tipo"] = "Cheque"; } else if (ds.Tables[0].Rows[i]["tipo"].ToString() == "TB") { ds.Tables[0].Rows[i]["tipo"] = "Transferencia Bancaria"; } } this.Session["dtgPagos"] = ds; DataRow dr1 = null; dr1 = ds.Tables[0].NewRow(); dr1["tipo"] = "TOTAL:"; dr1["importe"] = total.ToString(); ds.Tables[0].Rows.Add(dr1); this.dtgPagos.DataSource = ds; this.dtgPagos.CurrentPageIndex = 0; this.dtgPagos.DataBind(); this.btnGuardar.Visible = true; this.btnGuardar.Text = "Modificar"; } else { this.btnGuardar.Visible = false; this.btnGuardar.Text = "Guardar"; } } } catch (Exception ex) { throw ex; } } }