CREACIÓN DE CRUD CON LLAMADOS JQUERY & JSON
CREACIÓN DE CRUD CON LLAMADOS JQUERY & JSON
- Agregamos una nueva página de contenido al Site.Master llamado Bodegas2 y lo movemos a la carpeta correspondiente.
- Colocamos un título y arrastramos la tabla bodegas para que nos cree el GridView, luego cambiamos los nombres tal y como muestra este código:
<h1>Bodegas</h1>
<asp:GridView ID=”bodegasGridView” runat=”server” AllowPaging=”True” AllowSorting=”True” AutoGenerateColumns=”False” CellPadding=”4″ DataKeyNames=”IDBodega” DataSourceID=”bodegasSqlDataSource” EmptyDataText=”No hay registros de datos para mostrar.” ForeColor=”#333333″ GridLines=”None”>
<AlternatingRowStyle BackColor=”White” />
<Columns>
<asp:CommandField ShowDeleteButton=”True” ShowEditButton=”True” />
<asp:BoundField DataField=”IDBodega” HeaderText=”ID Bodega” ReadOnly=”True” SortExpression=”IDBodega” />
<asp:BoundField DataField=”Descripcion” HeaderText=”Descripción” SortExpression=”Descripcion” />
</Columns>
<EditRowStyle BackColor=”#2461BF” />
<FooterStyle BackColor=”#507CD1″ Font-Bold=”True” ForeColor=”White” />
<HeaderStyle BackColor=”#507CD1″ Font-Bold=”True” ForeColor=”White” />
<PagerStyle BackColor=”#2461BF” ForeColor=”White” HorizontalAlign=”Center” />
<RowStyle BackColor=”#EFF3FB” />
<SelectedRowStyle BackColor=”#D1DDF1″ Font-Bold=”True” ForeColor=”#333333″ />
<SortedAscendingCellStyle BackColor=”#F5F7FB” />
<SortedAscendingHeaderStyle BackColor=”#6D95E1″ />
<SortedDescendingCellStyle BackColor=”#E9EBEF” />
<SortedDescendingHeaderStyle BackColor=”#4870BE” />
</asp:GridView>
<asp:SqlDataSource ID=”bodegasSqlDataSource” runat=”server” ConnectionString=”<%$ ConnectionStrings:DefaultConnection %>” DeleteCommand=”DELETE FROM [Bodega] WHERE [IDBodega] = @IDBodega” InsertCommand=”INSERT INTO [Bodega] ([Descripcion]) VALUES (@Descripcion)” ProviderName=”<%$ ConnectionStrings:DefaultConnection.ProviderName %>” SelectCommand=”SELECT [IDBodega], [Descripcion] FROM [Bodega]” UpdateCommand=”UPDATE [Bodega] SET [Descripcion] = @Descripcion WHERE [IDBodega] = @IDBodega”>
<DeleteParameters>
<asp:Parameter Name=”IDBodega” Type=”Int32″ />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name=”Descripcion” Type=”String” />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name=”Descripcion” Type=”String” />
<asp:Parameter Name=”IDBodega” Type=”Int32″ />
</UpdateParameters>
</asp:SqlDataSource>
- Descargamos unos íconos para editar, borrar, guardar y cancelar, pequeños, puede ser de 16 x 16. Y colocamos los respectivos íconos al GridView, luego colocamos las operaciones como un template field.
- Probemos lo que hemos hecho hasta el momento:
- Cambiar:
<asp:TemplateField ShowHeader=”False”>
<EditItemTemplate>
<asp:ImageButton ID=”ImageButton1″ runat=”server” CausesValidation=”True” CommandName=”Update” ImageUrl=”~/Images/Icons/save.png” Text=”Actualizar” />
<asp:ImageButton ID=”ImageButton2″ runat=”server” CausesValidation=”False” CommandName=”Cancel” ImageUrl=”~/Images/Icons/cancel.png” Text=”Cancelar” />
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButton ID=”ImageButton1″ runat=”server” CausesValidation=”False” CommandName=”Edit” ImageUrl=”~/Images/Icons/edit.png” Text=”Editar” />
<asp:ImageButton ID=”ImageButton2″ runat=”server” CausesValidation=”False” CommandName=”Delete” ImageUrl=”~/Images/Icons/delete.png” Text=”Eliminar” />
</ItemTemplate>
</asp:TemplateField>
Por:
<asp:TemplateField ShowHeader=”False”>
<EditItemTemplate>
<asp:ImageButton
ID=”ImageButton1″
runat=”server”
CausesValidation=”True”
CommandName=”Update”
ImageUrl=”~/Images/Icons/save.png”
ToolTip=”Guarda los cambios”
Text=”Actualizar” />
<asp:ImageButton ID=”ImageButton2″
runat=”server”
CausesValidation=”False”
CommandName=”Cancel”
ImageUrl=”~/Images/Icons/cancel.png”
ToolTip=”Cancela los cambios”
Text=”Cancelar” />
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButton
ID=”ImageButton1″
runat=”server”
CausesValidation=”False”
CommandName=”Edit”
ImageUrl=”~/Images/Icons/edit.png”
ToolTip=”Edita el registro”
Text=”Editar” />
<asp:ImageButton
ID=”ImageButton2″
runat=”server”
ToolTip=”Borrar registro”
CausesValidation=”False”
AlternateText='<%# Eval(“IDBodega”) %>’
OnClientClick=”javascript:return confirmarBorrado(this.alt);”
CommandName=”Delete”
ImageUrl=”~/Images/Icons/delete.png”
Text=”Eliminar” />
</ItemTemplate>
</asp:TemplateField>
- Agregue el siguiente Script:
<script>
function confirmarBorrado(ID) {
alert(ID);
$(“<div></div>”).html(“¿Realmente desea borrar el registro?”).
dialog({
title: “Mensaje”, modal: true, buttons: [
{
text: “Si”,
click: function () {
alert(“Yes”);
$(this).dialog(“close”);
}
},
{
text: “No”,
click: function () {
alert(“No”);
$(this).dialog(“close”);
}
}
]
}
);
return false;
}
</script>
- Probemos lo que llevamos hasta el momento:
- Reemplacemos los alert por el verdadero llamado a la función que valida y borra la bodega. Reemplace el script por:
function confirmarBorrado(ID) {
$(“<div></div>”).html(“¿Realmente desea borrar el registro?”).
dialog({
title: “Mensaje”, modal: true, buttons: [
{
text: “Si”,
click: function () {
BorrarRegistro(ID);
$(this).dialog(“close”);
}
},
{
text: “No”,
click: function () {
$(this).dialog(“close”);
}
}
]
}
);
return false;
}
- Agreguemos la función BorrarRegistro:
function BorrarRegistro(ID) {
var pageUrl = ‘<%= ResolveUrl(“~/Mantenimientos/Bodegas2.aspx/BorrarRegistro”) %>’;
var parameter = { “ID”: ID }
$.ajax({
type: ‘POST’,
url: pageUrl,
data: JSON.stringify(parameter),
contentType: ‘application/json; charset=utf-8’,
dataType: ‘json’,
success: function (data) {
$(“<div></div>”).html(data.d).
dialog({
title: “Confirmación”, modal: true, buttons: [
{
text: “Ok”,
click: function () {
$(this).dialog(“close”);
}
}
]
}
);
},
error: function (data, success, error) {
$(“<div></div>”).html(“No se puede borrar bodega, tiene registros relacionados”).
dialog({
title: “Error”, modal: true, buttons: [
{
text: “Ok”,
click: function () {
$(this).dialog(“close”);
}
}
]
}
);
}
});
}
- Creamos el método DeleteBodega en el CADBodega
- Agreguemos el Web Method BorrarRegistro:
[WebMethod]
public static string BorrarRegistro(int ID)
{
CADBodega.DeleteBodega(ID);
return “Bodega borrada”;
}
- Probemos lo que llevamos hasta el momento:
- Ahora agreguemos un botón de nuevo, después del título de bodegas:
<asp:Button ID=”nuevoButton” runat=”server” Text=”Nuevo Registro” CssClass=”nuevoButton” />
- Y creemos el div con el contenido de nueva bodega:
<div id=”dialog-nuevo” title=”Nuevo registro”>
<p>
Descripción:
<asp:TextBox ID=”descripcionTextBox” runat=”server”></asp:TextBox>
</p>
</div>
- Adicionemos este código al script para que llame el dialogo (antes de </script>):
$(document).ready(function () {
$(“#dialog-nuevo”).hide();
$(“.nuevoButton”).click(function () {
<% descripcionTextBox.Text = string.Empty; %>
$(“#dialog-nuevo”).dialog({
resizable: false,
height: 200,
width: 350,
modal: true,
buttons: {
“Agregar”: function () {
alert(“Yes”);
$(this).dialog(“close”);
},
“Cancelar”: function () {
$(this).dialog(“close”);
}
}
});
return false;
});
});
- Probemos lo que llevamos hasta el momento:
- Cambien el alert(“Yes”) por el verdadero llamado la función que agrega la bodega:
Cambie:
alert(“Yes”);
Por:
InsertBodega();
- Y agreguemos la función InsertBodega(), antes del $(document):
function InsertBodega() {
var pageUrl = ‘<%= ResolveUrl(“~/Mantenimientos/Bodegas2.aspx/InsertBodega”) %>’;
var descripcion = $(“#<%= descripcionTextBox.ClientID %>”).val();
var parameter = { “descripcion”: descripcion, }
$.ajax({
type: ‘POST’,
url: pageUrl,
data: JSON.stringify(parameter),
contentType: ‘application/json; charset=utf-8’,
dataType: ‘json’,
success: function (data) {
$(“<div></div>”).html(data.d).
dialog({
title: “Confirmación”, modal: true, buttons: [
{
text: “Ok”,
click: function () {
$(this).dialog(“close”);
}
}
]
}
);
},
error: function (data, success, error) {
$(“<div></div>”).html(“Error: ” + error).
dialog({
title: “Error”, modal: true, buttons: [
{
text: “Ok”,
click: function () {
$(this).dialog(“close”);
}
}
]
}
);
}
});
}
- Y creemos el Web Method InsertBodega():
[WebMethod]
public static string InsertBodega(string descripcion)
{
if (descripcion == string.Empty)
{
return “Bebe ingresar una descripción”;
}
CADBodega.InsertBodega(descripcion);
return “Bodega agregada correctamente”;
}
- Probemos lo que hemos logrado!!!
- Para que la página haga una recarga automática, agregue estas líneas antes del último asp:content
<div id=”hide”>
<asp:Button ID=”fakeButton” CssClass=”fakeButton” runat=”server” Text=”Fake” OnClick=”fakeButton_Click”/>
</div>
- Y en el evento fakeButton_Click coloque está línea:
protected void fakeButton_Click(object sender, EventArgs e)
{
Response.Redirect(“~/Mantenimientos/Bodegas2.aspx”);
}
- Ocultemos esta división, justo después donde ocultamos del dialog-nuevo:
$(“#dialog-nuevo”).hide();
$(“#hide”).hide();
- Agreguemos un llamando al fakeButton justo antes de cerrar los dialofos de confirmación de agregar y eliminar bodega:
title: “Confirmación”, modal: true, buttons: [
{
text: “Ok”,
click: function () {
$(“.fakeButton”).click();
$(this).dialog(“close”);
}
}
]
- De esta manera ya no tenemos el problema de refrescado de pantalla!!!
ציפוי אמבטיה ציפוי אמבטיות הינה האפשרות הזולה ביותר מבין האפשרויות הקימות לחדש אמבטיה יזיז אולי פגומה תוך כדי הקצר במידה מרובה ובעלות באופן יחסי נמוכה אם נשווה אותה לעקירת האמבטיה הישנה והחלפתה באמבטיה נוכחית או בהלבשת אמבטיה אקרילית נוכחית על האמבטיה הישנה.. לא בכל אמבטיה ניתן לציפוי, אמבטיות פח מחלידות שנוצרו בהן חורי חלודה אין יכולת לצפות שאותן בעיקר בגלל העובי הדק של אמבטיה מפח שהוא לא עולה על לא פחות משמונה ממ ומרגע שהחלודה פורצת, קשה מאד לעצור אותה והפתרון היחיד למי שאינו מעוניין בשיפוץ חדר האמבטיה הוא מוכר בשם הלבשת אמבטיה מחדש על האמבטיה הישנה. פעולת הציפוי אורכת בצורה כלל לא יותר מ שעות וכוללת כמות שלבים החופפים זוהי את הזה ומאפשרים סיום מהיר עם העבודה סדר פעולות הציפוי בציפוי אמבטיה האמבטיה עוברת ליטוש שמוריד מתוכה את כל הצבעים או הציפויים שנעשו לפני זמן מה ולאחר מכן ליטוש מכני רך להחלקה ולאחריו ליטוש כימי בחומרים מסירי אבנית ושומנים. בגמר ממילא כל פעולות הליטוש, האמבטיה עוברת תהליך ייבוש בלחץ אוויר ולאחר מכן הדבקת נייר וניילון לכיסוי שום אזור האמבטיה למניעת אבק ולכלוך בחדר האמבטיה. בשלב של הבא מתיזים כ 4 שכבות ובתוכה חומרי מבוא על שום משטח האמבטיה ואחרי מכן מותז חומר הציפוי שמורכב מממספר חומרים כאלה ואחרים משולבים זה בזה ב20 עד 25 שכבות (בין התזות מסלול הציפוי יש להמתין זמן קצר ולאחר מכן שוב להתיז את מסלול הציפוי ). בגמר מקומות עבודה הציפוי מסירים את כל ההגנות ( ניילונים, סרטים דביקים וכדומה) מנקים את האזור והאמבטיה מוכנה. אחרי גמר הציפוי קיים להמתין זמן מה עד לייבוש סופי טרם השימוש נוספת באמבטיה.בגמר כל פעולות הציפוי מתקבלת אמבטיה מחודשת ונקייה. ציפוי לאמבטיה מחזיק בדרך סיכום כל לתקופות של פחות או יותר 4 ארבעה שנים ארוכות בשימוש נכון והוא גם חיוני ביחוד לשוכרי דירות שמעדיפים אמבטיה מחודשת ונקייה במחירים נמוכים מהלבשת אמבטיה או חילוף אמבטיה. ישנן דבר אפשרי לנקות את האמבטיה בכל חומרי הניקוי המתאימים לאמבטיות והציפוי אינו נפגע אפילו משימוש בחומצות המיועדות לניקוי. רצוי אינן להשתמש בשטיח נגד החלקה עם שאריות ואקום שעלולות להביא לציפוי לנזק.ציפוי ציפוי אמבטיה מעטפת אמבטיה https://goldbath.online/הלבשת-אמבטיה-2/ תיקון אמבטיה
Good way of explaining, and pleasant piece of writing to take data concerning my presentation subject
matter, which i am going to convey in university.
I was recommended this blog via my cousin. I am now not positive whether this publish is written through him as no one else understand such specified approximately my trouble.
You are incredible! Thank you!
Hi! Hi! viagra pills how much is viagra [url=http://viagraveikd.com/]viagra generic[/url] OK’
online loans payday loans no teletrack check loans online loans online
Thankfulness to my father who stated to me on the topic of this blog, this website is really remarkable.
Desenvolvendo um WebSite profissional do zero. http://fce.unse.edu.ar/sevyt/es/node/357825
I do trust all of the ideas you’ve introduced for your post.
They are very convincing and can certainly work.
Still, the posts are very short for beginners. May just you please
prolong them a bit from next time? Thanks for the post.
Hi All! [url=http://onlineviaqer.com/]generic viagra[/url] herbal viagra viagra price OK’
buy cheap viagra online
150 mg viagra
http://viagrachnln.com
viagra sex video
buy cheap viagra online
payday loans el cajon
payday cash loan
loans in utah
payday cash loan
You’re absolutely correct, I’d really enjoy to know more information on this particular subject! I’m as well interested in house plans as I think it truly is quite cool currently. Keep doing this!
generic viagra online
viagra online cheap
http://viagrachnln.com
viagra where to get
cheap viagra
loans online direct web loans loans online best personal loan
viagra online
where can i get viagra over the counter
http://viagrachnln.com
cheap viagra pills
generic viagra online
I am regular visitor, how are you everybody? This piece of writing
posted at this web page is really nice.
loans online loans online online loans no credit loans online
buy cheap viagra online
bob dole viagra commercial
http://viagrachnln.com
viagra e seus efeitos
online viagra
online viagra
viagra pills online
http://viagrachnln.com
viagra 80 year old man
viagra cheap
cheap viagra online
viagra every day
http://viagrachnln.com
viagra canada
buy viagra online
payday loans california
payday cash loan
christmas loans for bad credit
payday cash advance online
fast cash loans online
online cash advance loan
payday loans up to 5000
loans for bad credit
viagra cheap
viagra buy online
http://viagrachnln.com
viagra in walmart
buy cheap viagra online
http://www.foodspotting.com/4391992
This is very interesting, You’re a very skilled blogger.
I have joined your rss feed and look forward to seeking more of
your excellent post. Also, I’ve shared your site in my
social networks!
My brother suggested I might like this web site.
He was entirely right. This post truly made my day. You can not imagine
simply how much time I had spent for this info!
Thanks!
Este blog é perfeito para quem quer aprender sobre esse
tópico. Saiba que é praticamente impossível discutir com você (não que eu queira…
Haha). Você com certeza colocou um novo olhar sobre este
assunto que tem sido discutido por muito tempo .
Parabéns, muito bem ! http://www.alz.wiki/User:Alberto02J
Ela acha que aquilo é a linguagem de programação. http://Richterlures.Com.au/component/k2/itemlist/user/20051.html
when viagra goes generic
cheap viagra
viagra dosage
viagra generic
loans online online installment loans loans online unsecured debt consolidation loans
installment loans online quality loan service online personal loans loans in illinois
Curso é todo desenvolvido fundamentado em projetos reais. http://Erevistas.Uacj.mx/ojs/index.php/NovaRua/comment/view/2139/0/1264907
Hi there colleagues, how is all, and what you want to say concerning this post,
in my view its genuinely remarkable in favor of me.
I do consider all of the ideas you’ve introduced on your
post. They’re really convincing and can certainly work. Nonetheless, the posts are very quick for novices.
May you please extend them a bit from subsequent time? Thanks for the post.
Sweet blog! I found it while surfing around
on Yahoo News. Do you have any suggestions on how to
get listed in Yahoo News? I’ve been trying for a while but
I never seem to get there! Cheers
Fantastic beat ! I wish to apprentice while you amend your website, how can i subscribe for
a blog web site? The account aided me a acceptable deal.
I had been tiny bit acquainted of this your broadcast offered bright clear concept