Exemple #1
0
        private void Save()
        {
            equipmentCRUDTableAdapter daEquipment = new equipmentCRUDTableAdapter();

            try
            {
                daEquipment.Update(dsEquipment.equipmentCRUD); // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD)
                dsEquipment.AcceptChanges();                   // Call accept method on the dataset so it update the chanmges to the database

                lblStatus.Text = "Record Successfully Updated";
            }
            catch
            {
                dsEquipment.RejectChanges();
                lblStatus.Text = "Unable to Update Record";
            }
        }
Exemple #2
0
        private void Save()
        {
            equipmentCRUDTableAdapter daEquipment = new equipmentCRUDTableAdapter();

            try
            {
                daEquipment.Update(dsEquipment.equipmentCRUD);
                dsEquipment.AcceptChanges();
                this.lblStatus.Text = "Equipment Created";
                Clear();
            }
            catch
            {
                dsEquipment.RejectChanges();
                this.lblStatus.Text = "Failed";
            }
        }
Exemple #3
0
        protected void btnDeleteConfirm_Click(object sender, EventArgs e)
        {
            if (id != -1)
            {
                try
                {
                    DataRow equipment = dsEquipment.equipmentCRUD.FindByID(id);              // Find and add the record to tbe record variable
                    equipment.Delete();                                                      // Deletes the record in memory

                    equipmentCRUDTableAdapter daEquipment = new equipmentCRUDTableAdapter(); // table adapter to service table (Service adapter)
                    daEquipment.Update(equipment);                                           // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD)
                    dsEquipment.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("Equipments.aspx");
                }
                catch
                {
                    lblStatus.Text = "Delete failed. The equipment has a repair asigned.";
                }
            }
        }