public static int AgregarProCC(entProCC obj) { int Indicador = 0; SqlCommand cmd = null; try { Conexion cn = new Conexion(); SqlConnection cnx = cn.Conectar(); cmd = new SqlCommand("ProxCCInsert", cnx); cmd.Parameters.AddWithValue("@ID_Propiedad", obj.ID_Propiedad); cmd.Parameters.AddWithValue("@ID_CC", obj.ID_CC); cmd.CommandType = CommandType.StoredProcedure; cnx.Open(); cmd.ExecuteNonQuery(); Indicador = 1; } catch (Exception e) { Indicador = 0; } finally { cmd.Connection.Close(); } return(Indicador); }
public static entProCC BuscarProCC(int id, int id2) { entProCC obj = null; SqlCommand cmd = null; SqlDataReader dr = null; try { Conexion cn = new Conexion(); SqlConnection cnx = cn.Conectar(); cmd = new SqlCommand("Pro_x_CCRead", cnx); cmd.Parameters.AddWithValue("@ID_Propiedad", id); cmd.Parameters.AddWithValue("@ID_CC", id2); cmd.CommandType = CommandType.StoredProcedure; cnx.Open(); dr = cmd.ExecuteReader(); obj = new entProCC(); dr.Read(); obj.ID_PxC = Convert.ToInt32(dr["ID_PxC"].ToString()); obj.ID_CC = Convert.ToInt32(dr["ID_CC"].ToString()); obj.ID_Propiedad = Convert.ToInt32(dr["ID_Propiedad"].ToString()); } catch { obj = null; } finally { cmd.Connection.Close(); } return(obj); }
protected void btnGuardar_Click(object sender, EventArgs e) { if (TextBox1.Text != "" && NumPropiedad.Text != "") { entPropiedad obj = negPropiedad.BuscarPropiedad(Convert.ToInt32(NumPropiedad.Text)); entConceptoCobro obj1 = negConceptoCobro.BuscarConcepto(Convert.ToInt32(TextBox1.Text)); if (obj != null && obj1 != null) { int concepto = obj1.ID_CC; int prop = obj.ID_Propiedad; entProCC obj2 = new entProCC(); obj2.ID_Propiedad = prop; obj2.ID_CC = concepto; if (negProCC.AgregarProCC(obj2) == 1) { Response.Redirect("frmPrincipal.aspx"); } else { lblError.Text = "No se unieron correctamente,error del sistema"; lblError.Visible = true; } } else { lblError.Text = "Datos incorrectos"; lblError.Visible = true; } } else { lblError.Text = "Faltan datos por ingresar"; lblError.Visible = true; } }
protected void btnBuscar_Click(object sender, EventArgs e) { if (txtPropiedad.Text != "" && txtId.Text != "") { entPropiedad obj = negPropiedad.BuscarPropiedad(Convert.ToInt32(txtPropiedad.Text)); entConceptoCobro obj1 = negConceptoCobro.BuscarConcepto(Convert.ToInt32(txtId.Text)); if (obj != null && obj1 != null) { entProCC obj2 = negProCC.BuscarProCC(obj.ID_Propiedad, obj1.ID_CC); if (obj2 != null) { Numero.Text = Convert.ToString(obj.NumPropiedad); Direccion.Text = obj.Direccion; Tipo.Text = Convert.ToString(obj1.TipoCC); Concepto.Text = obj1.Concepto; FechaVencimiento.Text = Convert.ToString(obj1.DiaVencimiento); Fecha.Text = Convert.ToString(obj1.DiaCobro); } else { lblerror.Text = "No se logró encontrar esta union "; //Sino tira error lblerror.Visible = true; } } else { lblerror.Text = "No se encontraron los datos ingresados "; //Sino tira error lblerror.Visible = true; } } else { lblerror.Text = "Debe ingresar todos los datos solicitados "; //Sino tira error lblerror.Visible = true; } }
protected void btnModificar_Click(object sender, EventArgs e) { if (txtID.Text != "" && txtPropiedad.Text != "") { entPropiedad obj = negPropiedad.BuscarPropiedad(Convert.ToInt32(txtPropiedad.Text)); entConceptoCobro obj1 = negConceptoCobro.BuscarConcepto(Convert.ToInt32(txtID.Text)); if (obj != null && obj1 != null) { entProCC obj2 = negProCC.BuscarProCC(obj.ID_Propiedad, obj1.ID_CC); if (obj2 != null) { entProCC obj3 = new entProCC(); obj3.ID_PxC = obj2.ID_PxC; if (txtConcepto.Text != "") { entConceptoCobro obj4 = negConceptoCobro.BuscarConcepto(Convert.ToInt32(txtConcepto.Text)); if (obj4 != null) { obj3.ID_CC = obj4.ID_CC; if (txtNumeroProp.Text != "") { entPropiedad obj5 = negPropiedad.BuscarPropiedad(Convert.ToInt32(txtPropiedad.Text)); if (obj5 != null) { obj3.ID_Propiedad = obj5.ID_Propiedad; if (negProCC.ModificarProCC(obj3) == 1) { Response.Redirect("frmPrincipal.aspx"); } else { lblerror.Text = "No se pudo modificar la union"; lblerror.Visible = true; } } else { lblerror.Text = "No se encontro la propiedad"; lblerror.Visible = true; } } else { obj3.ID_Propiedad = obj.ID_Propiedad; if (negProCC.ModificarProCC(obj3) == 1) { Response.Redirect("frmPrincipal.aspx"); } else { lblerror.Text = "No se pudo modificar la union"; lblerror.Visible = true; } } } else { lblerror.Text = "No se encontro el propietario"; lblerror.Visible = true; } } else { obj3.ID_CC = obj1.ID_CC; if (txtNumeroProp.Text != "") { entPropiedad obj5 = negPropiedad.BuscarPropiedad(Convert.ToInt32(txtPropiedad.Text)); if (obj5 != null) { obj3.ID_Propiedad = obj5.ID_Propiedad; if (negProCC.ModificarProCC(obj3) == 1) { Response.Redirect("frmPrincipal.aspx"); } else { lblerror.Text = "No se pudo modificar la union"; lblerror.Visible = true; } } else { lblerror.Text = "No se pudo enocontrar la propiedad"; lblerror.Visible = true; } } else { obj3.ID_Propiedad = obj.ID_Propiedad; if (negProCC.ModificarProCC(obj3) == 1) { Response.Redirect("frmPrincipal.aspx"); } else { lblerror.Text = "No se pudo modificar la union"; lblerror.Visible = true; } } } } else { lblerror.Text = "No se encuentra una union entre ellos"; lblerror.Visible = true; } } else { lblerror.Text = "Datos incorrectos"; lblerror.Visible = true; } } else { lblerror.Text = "Ingrese un numero de propiedad y un propietario"; lblerror.Visible = true; } }
public static int ModificarProCC(entProCC obj) { return(daoProCC.ModificarProCC(obj)); }
public static int AgregarProCC(entProCC obj) { return(daoProCC.AgregarProCC(obj)); }