Ejemplo n.º 1
0
        //Dynamic Update of datafield for update and delete (selecting row from DataGridView)
        private void dataGridViewFacilities_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            FacilityInformation SelectedRow = (FacilityInformation)dataGridViewFacilities.CurrentRow.DataBoundItem;

            textBoxActivityFacilities.Text         = SelectedRow.Activity;
            textBoxFacilityIDFacilities.Text       = SelectedRow.FacilityID;
            textBoxLocationTagFacilities.Text      = SelectedRow.LocationTag;
            textBoxLocationFacilities.Text         = SelectedRow.Location;
            textBoxRemarksFacilities.Text          = SelectedRow.Remarks;
            buttonConfirmChangesFacilities.Enabled = true;
            buttonDeleteFacilities.Enabled         = true;
        }
Ejemplo n.º 2
0
 // Facility Creation  - actual Entity action
 private void createFacility(FacilityInformation NewFacility)
 {
     try
     {
         using (SA46Team09BEntities context = new SA46Team09BEntities())
         {
             context.FacilityInformations.Add(NewFacility);
             context.SaveChanges();
             ((MAIN)MdiParent).UpdateStatusLabel("Facilities record successfully added");
         }
     }
     catch
     {
         MessageBox.Show("Creation Error. FacilityID probably existed. Please check again.");
         ((MAIN)MdiParent).UpdateStatusLabel("Error encounter in last transaction...");
     }
 }
Ejemplo n.º 3
0
        // Updates to facility information - currently programmed as a create and delete operation
        private void buttonConfirmChangesFacilities_Click(object sender, EventArgs e)
        {
            string Activity    = this.textBoxActivityFacilities.Text.Trim();
            string FacilityID  = this.textBoxFacilityIDFacilities.Text.Trim().ToUpper();
            string LocationTag = this.textBoxLocationTagFacilities.Text.Trim();
            string Location    = this.textBoxLocationFacilities.Text.Trim();
            string Remarks     = this.textBoxRemarksFacilities.Text.Trim();
            FacilityInformation NewFacility = new FacilityInformation()
            {
                Activity = Activity, FacilityID = FacilityID, LocationTag = LocationTag, Location = Location, Remarks = Remarks
            };
            bool flag = DeleteFacility(FacilityID);

            if (flag == true)
            {
                createFacility(NewFacility);
            }
        }
Ejemplo n.º 4
0
 // delete facility - actual Entity action
 private bool DeleteFacility(string FacilityID)
 {
     try
     {
         using (SA46Team09BEntities context = new SA46Team09BEntities())
         {
             FacilityInformation DeleteFacility = (FacilityInformation)context.FacilityInformations.Where(F => F.FacilityID == FacilityID).First();
             context.FacilityInformations.Remove(DeleteFacility);
             context.SaveChanges();
             ((MAIN)MdiParent).UpdateStatusLabel("Facilities successfully deleted");
         }
     }
     catch
     {
         MessageBox.Show("Deletion Error. FacilityID probably did not existed. Please check again.");
         ((MAIN)MdiParent).UpdateStatusLabel("Error encounter in last transaction...");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 5
0
        // Add Button code - preparation of FacilityInformation obj before calling for facility creation

        private void buttonAddFacilities_Click(object sender, EventArgs e)
        {
            string Activity    = this.textBoxActivityFacilities.Text.Trim();
            string FacilityID  = this.textBoxFacilityIDFacilities.Text.Trim().ToUpper();
            string LocationTag = this.textBoxLocationTagFacilities.Text.Trim();
            string Location    = this.textBoxLocationFacilities.Text.Trim();
            string Remarks     = this.textBoxRemarksFacilities.Text.Trim();

            if (Activity == "" || FacilityID == "" || LocationTag == "" || Location == "")
            {
                MessageBox.Show("Please enter data into required fields.");
                return;
            }

            FacilityInformation NewFacility = new FacilityInformation()
            {
                Activity = Activity, FacilityID = FacilityID, LocationTag = LocationTag, Location = Location, Remarks = Remarks
            };

            createFacility(NewFacility);
        }