private void Save() { try { prod_orderTableAdapter daOrder = new prod_orderTableAdapter(); daOrder.Update(dsOrder.prod_order); // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD) dsOrder.AcceptChanges(); // Call accept method on the dataset so it update the chanmges to the database lblStatus.Text = "Record Successfully Updated"; } catch { dsOrder.RejectChanges(); lblStatus.Text = "Unable to Update Record"; } }
private void Save() { prod_orderTableAdapter daOrder = new prod_orderTableAdapter(); try { daOrder.Update(dsOrder.prod_order); dsOrder.AcceptChanges(); this.lblStatus.Text = "Order Created"; Clear(); } catch { dsOrder.RejectChanges(); this.lblStatus.Text = "Failed"; } }
protected void btnDeleteConfirm_Click(object sender, EventArgs e) { if (id != -1) { try { prod_orderTableAdapter daOrder = new prod_orderTableAdapter(); daOrder.Fill(dsOrder.prod_order); DataRow record = dsOrder.prod_order.FindByid(id); // Find and add the record to tbe record variable record.Delete(); // Deletes the record in memory // table adapter to service table (Service adapter) daOrder.Update(record); // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD) dsOrder.AcceptChanges(); // Call accept method on the dataset so it update the chanmges to the database //Refresh the page to show the record being deleted Response.Redirect("Default.aspx"); } catch { lblStatus.Text = "Delete failed. Probably this Order assigned to some arrived Order in Database."; } } }