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 Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region User IsAuthenticated if (Session["Usuario"] != null) { this.usuario = (IUsuarios)Session["Usuario"]; Session["AgenciaConectadaID"] = usuario.AgenciaID; } if (User.Identity.IsAuthenticated) { string sOpcion = "guiasTransfarmacoCierreOperativo"; SisPacK.Menu oMenu = (SisPacK.Menu) this.FindControl("Menu1"); this.ValidarSeguridad(oMenu, sOpcion); } #endregion this.Session.Remove("listadoGuias"); this.Session.Remove("DsGridView"); this.btnGuardarCierreOperativo.Enabled = true; IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); this.BindGrid(0); } }
protected void btnGuardarCierreOperativo_Click(object sender, EventArgs e) { this.btnGuardarCierreOperativo.Enabled = false; if (Session["listadoGuias"] != null) { IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); guiastransfarmaco.List = Session["listadoGuias"] as List <int>; guiastransfarmaco.Observaciones = txtObservaciones.Text; IUsuarios usuario = (IUsuarios)Session["Usuario"]; guiastransfarmaco.UsuarioID = usuario.UsuarioID; if (guiastransfarmaco.GuardarCierreOperativo()) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Rendición Guardada Correctamente.');", true); this.txtObservaciones.Text = string.Empty; this.txtBuscarNroGuia.Text = string.Empty; this.txtFiltroDesde.Text = string.Empty; this.txtFiltroHasta.Text = string.Empty; this.Session.Remove("listadoGuias"); this.BindGrid(0); } } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Debe seleccionar al menos una Guia para Guardar Rendición.');", true); this.btnGuardarCierreOperativo.Enabled = true; } }
private void BindGridRow(int currentPage) { try { if (Session["DsGridView"] != null) { IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); DataSet ds = Session["DsGridView"] as DataSet; guiastransfarmaco.NroGuia = Convert.ToInt32(Session["NroGuia"]); guiastransfarmaco.FechaDesde = Convert.ToDateTime(Session["FechaDesde"]); guiastransfarmaco.FechaHasta = Convert.ToDateTime(Session["FechaHasta"]); Session["Index"] = currentPage; ds = guiastransfarmaco.GetGuiasFechaRealEntregaALL(int.Parse(Session["AgenciaConectadaID"].ToString())); if (ds.Tables[0].Rows.Count != 0) { this.dtgTransfarmacoFechaRealEntrega.DataSource = ds.Tables[0]; this.dtgTransfarmacoFechaRealEntrega.CurrentPageIndex = currentPage; this.dtgTransfarmacoFechaRealEntrega.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.dtgGuiasTransfarmacoCierreOperativo, "guiaid", 400); IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); DataSet ds = new DataSet(); ds = guiastransfarmaco.GetGuiasSinCierreOperativo(int.Parse(Session["AgenciaConectadaID"].ToString())); this.dtgGuiasTransfarmacoCierreOperativo.DataSource = ds.Tables[0]; this.dtgGuiasTransfarmacoCierreOperativo.CurrentPageIndex = currentPage; this.dtgGuiasTransfarmacoCierreOperativo.DataBind(); //this.Session["DsGridView"] = ds; }
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"); }
private void BindGrid(int currentPage) { try { SisPackController.AdministrarGrillas.Configurar(this.dtgTransfarmacoCierreOperativoReporte, "GuiasTransfarmacoCierreOperativoID", 40); IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); DataSet ds = new DataSet(); guiastransfarmaco.GuiasTransfarmacoCierreOperativoID = 0; guiastransfarmaco.NroGuia = 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.GetRendicionesEmitidas(); this.Session["DsGridView"] = ds; this.dtgTransfarmacoCierreOperativoReporte.DataSource = ds.Tables[0]; this.dtgTransfarmacoCierreOperativoReporte.CurrentPageIndex = currentPage; this.dtgTransfarmacoCierreOperativoReporte.DataBind(); } catch (Exception ex) { throw ex; } }
private void BindGrid(int currentPage) { try { SisPackController.AdministrarGrillas.Configurar(this.dtgTransfarmacoFechaRealEntrega, "guiaid", 20); IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); DataSet ds = new DataSet(); ds = guiastransfarmaco.GetGuiasFechaRealEntregaALL(int.Parse(Session["AgenciaConectadaID"].ToString())); this.Session["DsGridView"] = ds; this.Session["NroGuia"] = 0; this.Session["FechaDesde"] = "1900-01-01 00:00:00.000"; this.Session["FechaHasta"] = "1900-01-01 00:00:00.000"; Session.Remove("Index"); this.dtgTransfarmacoFechaRealEntrega.DataSource = ds.Tables[0]; this.dtgTransfarmacoFechaRealEntrega.CurrentPageIndex = currentPage; this.dtgTransfarmacoFechaRealEntrega.DataBind(); } catch (Exception ex) { throw ex; } }
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 btnBuscarDesdeHasta_Click(object sender, EventArgs e) { try { if (txtBuscarRendicionGuia.Text != "") { txtFiltroDesde.Text = ""; txtFiltroHasta.Text = ""; lblError.Visible = false; lblError.Text = string.Empty; } 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.dtgTransfarmacoCierreOperativoReporte, "GuiasTransfarmacoCierreOperativoID", 400); 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; if (this.ddlRendicionGuia.SelectedValue == "rendicion") { guiastransfarmaco.GuiasTransfarmacoCierreOperativoID = this.txtBuscarRendicionGuia.Text == "" ? 0 : Convert.ToInt32(this.txtBuscarRendicionGuia.Text); guiastransfarmaco.NroGuia = 0; } else if (this.ddlRendicionGuia.SelectedValue == "guia") { guiastransfarmaco.GuiasTransfarmacoCierreOperativoID = 0; guiastransfarmaco.NroGuia = this.txtBuscarRendicionGuia.Text == "" ? 0 : Convert.ToInt32(this.txtBuscarRendicionGuia.Text); } ds = guiastransfarmaco.GetRendicionesEmitidas(); this.Session["DsGridView"] = ds; this.dtgTransfarmacoCierreOperativoReporte.DataSource = ds.Tables[0]; this.dtgTransfarmacoCierreOperativoReporte.CurrentPageIndex = 0; this.dtgTransfarmacoCierreOperativoReporte.DataBind(); } catch (Exception ex) { throw ex; } }
protected void btnGuardar_Click(object sender, EventArgs e) { try { DataSet ds = new DataSet(); decimal total = 0; ds = Session["dtgPagos"] as DataSet; if (ds.Tables[0].Rows.Count > 0) { if ((ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1][3]).ToString() == "TOTAL:" || (ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1][2]).ToString() == "TOTAL:") { ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1].Delete(); //--Borramos la fila del Total } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) //Sumamos el Nuevo Total { total += Convert.ToDecimal(ds.Tables[0].Rows[i]["importe"].ToString()); } if (Convert.ToDecimal(this.txtImporteTotal.Text) == total) //--Comparamos los Totales { //--///////BOTON GUARDAR, GUARDAR DETALLE PAGOS NUEVOS////////////////////// if (btnGuardar.Text == "Guardar") //--Chequea si estamos guardando por primera vez pagos detalle { IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); IUsuarios usuario = (IUsuarios)Session["Usuario"]; guiastransfarmaco.UsuarioID = usuario.UsuarioID; guiastransfarmaco.DsPagos = ds; guiastransfarmaco.NroGuia = Convert.ToInt32(this.txtGuiaID.Text); guiastransfarmaco.GuiasTransfarmacoPagosID = 0; if (guiastransfarmaco.GuardarDetallesPagos()) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "redirect", "alert('Detalles de Pagos Guardados Correctamente');window.location='" + Request.ApplicationPath + "/GuiasTransfarmacoPagos.aspx?numeroguia=" + this.txtGuiaID.Text + "';", true); btnGuardar.Enabled = true; } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Error al Guardar. Vuelva a intentarlo');", true); btnGuardar.Enabled = true; } } //--///////BOTON GUARDAR, MODIFICAR PAGOS YA GUARDADOS////////////////////// else if (btnGuardar.Text == "Modificar")//---Si estamos guardando modificaciones de detalles pagos ya guardados. { IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); IUsuarios usuario = (IUsuarios)Session["Usuario"]; guiastransfarmaco.UsuarioID = usuario.UsuarioID; guiastransfarmaco.DsPagos = ds; guiastransfarmaco.NroGuia = Convert.ToInt32(this.txtGuiaID.Text); guiastransfarmaco.GuiasTransfarmacoPagosID = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["guiastransfarmacopagosid"].ToString() != "") { guiastransfarmaco.GuiasTransfarmacoPagosID = Convert.ToInt32(ds.Tables[0].Rows[i]["guiastransfarmacopagosid"]); } } if (guiastransfarmaco.GuiasTransfarmacoPagosID == 0) { DataSet dset = new DataSet(); dset = guiastransfarmaco.GetGuiasTransfarmacoPagosALL(); for (int i = 0; i < dset.Tables[0].Rows.Count; i++) { if (dset.Tables[0].Rows[i]["guiastransfarmacopagosid"].ToString() != "") { guiastransfarmaco.GuiasTransfarmacoPagosID = Convert.ToInt32(dset.Tables[0].Rows[i]["guiastransfarmacopagosid"]); } } } if (guiastransfarmaco.GuardarDetallesPagos()) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "redirect", "alert('Detalles de Pagos Modificados Correctamente');window.location='" + Request.ApplicationPath + "/GuiasTransfarmacoPagos.aspx?numeroguia=" + this.txtGuiaID.Text + "';", true); btnGuardar.Enabled = true; } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Error al Modificar. Vuelva a intentarlo');", true); btnGuardar.Enabled = true; } } } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('El Total de los Detalles debe ser igual al Total de la Guía.');", true); btnGuardar.Enabled = true; } } else { btnGuardar.Enabled = true; return; } } catch (Exception ex) { throw ex; } }
private bool Eliminar(object sender, CommandEventArgs e) { DataSet ds = new DataSet(); IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); decimal total = 0; int count = 0; try { ds = Session["dtgPagos"] as DataSet; //--Borro fila de TOTAL en caso de que la tenga. if (ds.Tables[0].Rows.Count > 0) { if ((ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1][3]).ToString() == "TOTAL:" || (ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1][2]).ToString() == "TOTAL:") { ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1].Delete(); } } //--Borro la fila seleccionada y me guardo la cantidad de filas que quedan int ID = Convert.ToInt32(e.CommandArgument) - 1; count = ds.Tables[0].Rows.Count - 1; DataRow drID = ds.Tables[0].Rows[ID]; ds.Tables[0].Rows.Remove(drID); //--Asigno los nuevos # del dataset en caso de que hayan filas if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ds.Tables[0].Rows[i]["detallenro"] = i + 1; } this.Session["dtgPagos"] = ds; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { total += Convert.ToDecimal(ds.Tables[0].Rows[i]["importe"].ToString()); } //--Agrego fila nuevo Total DataRow dr1 = null; dr1 = ds.Tables[0].NewRow(); dr1["tipo"] = "TOTAL:"; dr1["importe"] = total.ToString(); ds.Tables[0].Rows.Add(dr1); } else { this.btnGuardar.Visible = false; } //--Lleno datagrid this.dtgPagos.DataSource = ds; this.dtgPagos.CurrentPageIndex = 0; this.dtgPagos.DataBind(); //--Si al momento de eliminar una fila, el boton Agregar tiene de texto Modificar, se debe borrar todo asi evitamos problemas if (btnAgregar.Text == "Modificar") { this.txtImporteDetalle.Text = string.Empty; this.txtNroCheque.ReadOnly = true; this.txtNroCheque.BackColor = System.Drawing.ColorTranslator.FromHtml("#c0c0c0"); this.txtNroCheque.Text = string.Empty; this.txtBanco.ReadOnly = true; this.txtBanco.BackColor = System.Drawing.ColorTranslator.FromHtml("#c0c0c0"); this.txtBanco.Text = string.Empty; this.txtNroClienteBanco.ReadOnly = true; this.txtNroClienteBanco.BackColor = System.Drawing.ColorTranslator.FromHtml("#c0c0c0"); this.txtNroClienteBanco.Text = string.Empty; this.hidDetalleNro.Value = string.Empty; this.btnAgregar.Text = "Agregar"; } return(true); } catch (Exception ex) { throw ex; } }
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; } } }
protected void lbEliminar_Command(object sender, CommandEventArgs e) { DataSet ds = new DataSet(); try { ds = Session["DsGridView"] as DataSet; int ID = Convert.ToInt32(e.CommandArgument); //--Nos traemos el valor de "GuiaID" de la fila seleccionada del datagrid IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); IUsuarios usuario = (IUsuarios)Session["Usuario"]; guiastransfarmaco.UsuarioID = usuario.UsuarioID; guiastransfarmaco.NroGuia = ID; guiastransfarmaco.FechaRealEntrega = ""; guiastransfarmaco.Observaciones = ""; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["numeroguia"].ToString() == ID.ToString()) { guiastransfarmaco.GuiasTransfarmacoFechaRealEntregaID = Convert.ToInt32(ds.Tables[0].Rows[i]["guiasTransfarmacoFechaRealEntregaID"]); } } guiastransfarmaco.Baja = 1; if (guiastransfarmaco.GuardarFechaRealEntrega()) { this.txtNroGuia.Text = string.Empty; this.txtObservaciones.ReadOnly = true; this.txtObservaciones.Text = string.Empty; this.txtFechaRealEntrega.ReadOnly = true; this.txtFechaRealEntrega.Text = string.Empty; this.btnGuardarFechaRealEntrega.Text = "Guardar"; this.btnGuardarFechaRealEntrega.Visible = false; guiastransfarmaco.NroGuia = Convert.ToInt32(Session["NroGuia"]); guiastransfarmaco.FechaDesde = Convert.ToDateTime(Session["FechaDesde"]); guiastransfarmaco.FechaHasta = Convert.ToDateTime(Session["FechaHasta"]); ds = guiastransfarmaco.GetGuiasFechaRealEntregaALL(int.Parse(Session["AgenciaConectadaID"].ToString())); this.dtgTransfarmacoFechaRealEntrega.DataSource = ds.Tables[0]; //Verificamos si algun numero de pagina guardado if (Session["Index"] != null) { //Verificamos si el datagrid tiene ese numero de paginas if (this.dtgTransfarmacoFechaRealEntrega.PageCount >= Convert.ToInt32(Session["Index"])) { this.dtgTransfarmacoFechaRealEntrega.CurrentPageIndex = Convert.ToInt32(Session["Index"]); } else { this.dtgTransfarmacoFechaRealEntrega.CurrentPageIndex = 0; } } else { this.dtgTransfarmacoFechaRealEntrega.CurrentPageIndex = 0; } this.dtgTransfarmacoFechaRealEntrega.DataBind(); ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Datos eliminados correctamente.');", true); this.Session["DsGridView"] = ds; } } catch (Exception ex) { throw ex; } }
protected void btnGuardarFechaRealEntrega_Click(object sender, EventArgs e) { this.btnGuardarFechaRealEntrega.Enabled = false; if (this.txtFechaRealEntrega.Text == "") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Debe Ingresar un valor en Fecha Real Entrega:');", true); this.btnGuardarFechaRealEntrega.Enabled = true; return; } IGuiasTransfarmaco guiastransfarmaco = GuiasTransfarmacoFactory.GetGuiasTransfarmaco(); IUsuarios usuario = (IUsuarios)Session["Usuario"]; guiastransfarmaco.UsuarioID = usuario.UsuarioID; guiastransfarmaco.NroGuia = Convert.ToInt32(this.txtNroGuia.Text); guiastransfarmaco.FechaRealEntrega = this.txtFechaRealEntrega.Text; guiastransfarmaco.Observaciones = this.txtObservaciones.Text; guiastransfarmaco.GuiasTransfarmacoFechaRealEntregaID = Convert.ToInt32(this.hidGuiasTransfarmacoFechaRealEntregaID.Value); guiastransfarmaco.Baja = 0; if (guiastransfarmaco.GuardarFechaRealEntrega()) { this.txtNroGuia.Text = string.Empty; this.txtObservaciones.ReadOnly = true; this.txtObservaciones.Text = string.Empty; this.txtFechaRealEntrega.ReadOnly = true; this.txtFechaRealEntrega.Text = string.Empty; this.btnGuardarFechaRealEntrega.Enabled = true; if (this.btnGuardarFechaRealEntrega.Text == "Guardar") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Datos guardados correctamente.');", true); } else if (this.btnGuardarFechaRealEntrega.Text == "Modificar") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Datos modificados correctamente.');", true); this.btnGuardarFechaRealEntrega.Text = "Guardar"; } DataSet ds = new DataSet(); this.btnGuardarFechaRealEntrega.Visible = false; guiastransfarmaco.NroGuia = Convert.ToInt32(Session["NroGuia"]); guiastransfarmaco.FechaDesde = Convert.ToDateTime(Session["FechaDesde"]); guiastransfarmaco.FechaHasta = Convert.ToDateTime(Session["FechaHasta"]); ds = guiastransfarmaco.GetGuiasFechaRealEntregaALL(int.Parse(Session["AgenciaConectadaID"].ToString())); this.Session["DsGridView"] = ds; this.dtgTransfarmacoFechaRealEntrega.DataSource = ds.Tables[0]; if (Session["Index"] != null) { //Verificamos si el datagrid tiene ese numero de paginas if (this.dtgTransfarmacoFechaRealEntrega.PageCount >= Convert.ToInt32(Session["Index"])) { this.dtgTransfarmacoFechaRealEntrega.CurrentPageIndex = Convert.ToInt32(Session["Index"]); } else { this.dtgTransfarmacoFechaRealEntrega.CurrentPageIndex = 0; } } else { this.dtgTransfarmacoFechaRealEntrega.CurrentPageIndex = 0; } this.dtgTransfarmacoFechaRealEntrega.DataBind(); } }