protected void dgvBANCOS_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EDITAR") { GridViewRow raw = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); TXTFECHAEMISION.Text = Convert.ToDateTime(HttpUtility.HtmlDecode(raw.Cells[7].Text.Trim())).ToString("yyyy-MM-dd"); TXTFECHAVCTO.Text = Convert.ToDateTime(HttpUtility.HtmlDecode(raw.Cells[8].Text.Trim())).ToString("yyyy-MM-dd"); TXTXNUMINI.Text = HttpUtility.HtmlDecode(raw.Cells[4].Text.Trim()); TXTNUMFIN.Text = HttpUtility.HtmlDecode(raw.Cells[5].Text.Trim()); CBOTIPO.SelectedValue = HttpUtility.HtmlDecode(raw.Cells[9].Text.Trim()); TXTOBS.Text = HttpUtility.HtmlDecode(raw.Cells[10].Text.Trim()); Session["EDITAR"] = "EDITAR"; Session["ID_CHEQUERA"] = HttpUtility.HtmlDecode(raw.Cells[0].Text.Trim()); } else if (e.CommandName == "ELIMINAR") { try { GridViewRow raw = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); OBJCHEQUE.id_cuentasbancarias = "2018"; OBJCHEQUE.f_emision = Convert.ToDateTime("01-01-2017").ToShortDateString(); OBJCHEQUE.f_vcto = Convert.ToDateTime("01-01-2017").ToShortDateString(); OBJCHEQUE.n_inicial = Convert.ToInt32("1"); OBJCHEQUE.n_final = Convert.ToInt32("2"); OBJCHEQUE.n_correlativo = Convert.ToInt32("5"); OBJCHEQUE.tipo = CBOTIPO.SelectedValue; OBJCHEQUE.estado = "ACTIVO"; OBJCHEQUE.obs = TXTOBS.Text; OBJCHEQUE.usuario = ""; String cond = "3"; string id_empresa = Session["ID_EMPRESA"].ToString(); string id_chequera = HttpUtility.HtmlDecode(raw.Cells[0].Text.Trim()); string res = OBJVENTA.NREGISTRARCHEQUE(OBJCHEQUE, cond, id_chequera); if (res == "ok") { //Response.Write("<script>alert('CHEQUE REGISTRADO CORRECTAMENTE..')</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); llenar_datos(); TXTFECHAEMISION.Text = DateTime.Now.ToString("yyyy-MM-dd"); TXTFECHAVCTO.Text = DateTime.Now.ToString("yyyy-MM-dd"); limpiarcampos(); TXTFECHAEMISION.Focus(); } else { //Response.Write("<script>alert('ERROR CHEQUE NO REGISTRADO')</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal1();", true); } } catch { ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal4();", true); } } }
protected void btnRegistrar_Click(object sender, EventArgs e) { if (Page.IsValid) { if (Convert.ToInt32(TXTXNUMINI.Text) < Convert.ToInt32(TXTNUMFIN.Text) && Convert.ToDateTime(TXTFECHAEMISION.Text) < Convert.ToDateTime(TXTFECHAVCTO.Text)) { //CARGAMOS LA TABLA QUE VALIDA EL NUMERO D EINICIO DE LAS CHEQUERAS DataTable dtr = OBJDATOS.DNUMERO_DEINICIO_CHEQUERA(CBOTIPO.SelectedValue, txtCUENTACH.Text, "ACTIVO"); if (Session["EDITAR"].ToString() == "") { if (Convert.ToInt32(TXTXNUMINI.Text) > Convert.ToInt32(dtr.Rows[0][0].ToString())) { try { OBJCHEQUE.id_cuentasbancarias = txtCUENTACH.Text; OBJCHEQUE.f_emision = Convert.ToDateTime(TXTFECHAEMISION.Text).ToShortDateString(); OBJCHEQUE.f_vcto = Convert.ToDateTime(TXTFECHAVCTO.Text).ToShortDateString(); OBJCHEQUE.n_inicial = Convert.ToInt32(TXTXNUMINI.Text); OBJCHEQUE.n_final = Convert.ToInt32(TXTNUMFIN.Text); OBJCHEQUE.n_correlativo = Convert.ToInt32(TXTXNUMINI.Text); OBJCHEQUE.tipo = CBOTIPO.SelectedValue; OBJCHEQUE.estado = "ACTIVO"; OBJCHEQUE.obs = TXTOBS.Text; OBJCHEQUE.usuario = ""; String cond = "2"; string id_empresa = Session["ID_EMPRESA"].ToString(); string id_chequera = ""; string res = OBJVENTA.NREGISTRARCHEQUE(OBJCHEQUE, cond, id_chequera); if (res == "ok") { //Response.Write("<script>alert('CHEQUE REGISTRADO CORRECTAMENTE..')</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); llenar_datos(); TXTFECHAEMISION.Text = DateTime.Now.ToString("yyyy-MM-dd"); TXTFECHAVCTO.Text = DateTime.Now.ToString("yyyy-MM-dd"); limpiarcampos(); TXTFECHAEMISION.Focus(); } else { //Response.Write("<script>alert('ERROR CHEQUE NO REGISTRADO')</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal1();", true); } } catch { ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal4();", true); } } else { Response.Write("<script>alert('EL NUMERO INICIAL DEBE SER CORRELATIVO Y MAYOR, QUE EL NUMERO FINAL DE LA ANTERIOR CHEQUERA')</script>"); } } else if (Session["EDITAR"].ToString() == "EDITAR") { try { OBJCHEQUE.id_cuentasbancarias = txtCUENTACH.Text; OBJCHEQUE.f_emision = Convert.ToDateTime(TXTFECHAEMISION.Text).ToShortDateString(); OBJCHEQUE.f_vcto = Convert.ToDateTime(TXTFECHAVCTO.Text).ToShortDateString(); OBJCHEQUE.n_inicial = Convert.ToInt32(TXTXNUMINI.Text); OBJCHEQUE.n_final = Convert.ToInt32(TXTNUMFIN.Text); OBJCHEQUE.n_correlativo = Convert.ToInt32(TXTXNUMINI.Text); OBJCHEQUE.tipo = CBOTIPO.SelectedValue; OBJCHEQUE.estado = "ACTIVO"; OBJCHEQUE.obs = TXTOBS.Text; OBJCHEQUE.usuario = ""; String cond = "4"; string id_empresa = Session["ID_EMPRESA"].ToString(); string id_chequera = Session["ID_CHEQUERA"].ToString(); string res = OBJVENTA.NREGISTRARCHEQUE(OBJCHEQUE, cond, id_chequera); if (res == "ok") { //Response.Write("<script>alert('CHEQUE REGISTRADO CORRECTAMENTE..')</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); llenar_datos(); TXTFECHAEMISION.Text = DateTime.Now.ToString("yyyy-MM-dd"); TXTFECHAVCTO.Text = DateTime.Now.ToString("yyyy-MM-dd"); limpiarcampos(); TXTFECHAEMISION.Focus(); Session["EDITAR"] = ""; } else { //Response.Write("<script>alert('ERROR CHEQUE NO REGISTRADO')</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal1();", true); } } catch { ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal4();", true); } } } else { if (Convert.ToInt32(TXTXNUMINI.Text) >= Convert.ToInt32(TXTNUMFIN.Text)) { ScriptManager.RegisterStartupScript(UPCUERPO, UPCUERPO.GetType(), "Pop", "openModal1();", true); } if (Convert.ToDateTime(TXTFECHAEMISION.Text) >= Convert.ToDateTime(TXTFECHAVCTO.Text)) { ScriptManager.RegisterStartupScript(UPCUERPO, UPCUERPO.GetType(), "Pop", "openModal1();", true); } } } }