Exemplo n.º 1
0
/******************************Maintain Rooms Events**********************************************/

        public void Room_Cell_Click(object sender, DataGridViewCellEventArgs e)
        {
            if ((e.ColumnIndex == 3) && (e.RowIndex > -1))// ------------------------------Extinguisher
            {
                _roomForm.ShowServiceItemView("extinguisher", e.RowIndex);
            }
            if ((e.ColumnIndex == 4) && (e.RowIndex > -1))// ------------------------------Hose
            {
                _roomForm.ShowServiceItemView("hose", e.RowIndex);
            }
            if ((e.ColumnIndex == 5) && (e.RowIndex > -1))// ------------------------------Light
            {
                _roomForm.ShowServiceItemView("light", e.RowIndex);
            }
            if ((e.ColumnIndex == 6) && (e.RowIndex > -1))// ------------------------------Remove
            {
                var dgv = sender as DataGridView;
                _roomForm.ShowServiceItemView("none", e.RowIndex);
                string roomID = dgv.Rows[e.RowIndex].Cells["idCol"].Value.ToString();
                MRoom.Delete(roomID);
                dgv.Rows.RemoveAt(e.RowIndex);
                _roomForm.noChanges = false;
            }
            // Hide datepicker
            _roomForm.ShowPicker(false, 0, 0, 'n');
        }
Exemplo n.º 2
0
/**************************************** Constructor *************************************/
        public AddEditRoomForm(MaintainClientController parent, String id, int AddrIndex)
        {
            InitializeComponent();
            my_controller    = parent;
            AddressID        = id;
            AddrRow          = AddrIndex;
            noChanges        = true;
            DatePicker.Value = DateTime.Today;

            this.Ok_Button.Click               += new EventHandler(my_controller.Room_Ok_Button_Click);
            this.Cancel_Button.Click           += new EventHandler(my_controller.Room_Cancel_Button_Click);
            this.RoomGridView.CellContentClick += new DataGridViewCellEventHandler(my_controller.Room_Cell_Click);

            PopulateRoomGridView(MRoom.GetRoomsForAddr(id));
        }
Exemplo n.º 3
0
 public void Room_Cancel_Button_Click(object sender, EventArgs e)
 {
     if (_roomForm.noChanges)
     {
         _roomForm.Close();
         return;
     }
     else
     {
         if (MessageBox.Show("Are you sure you want to discard?", "Confirm Cancel", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             MRoom.RemoveBlanks();
             _roomForm.Close();
         }
     }
 }
Exemplo n.º 4
0
        public void PopulateRoomGridView(DataTable rooms)
        {
            int    nRows = rooms.Rows.Count;
            String roomID;

            for (int i = 0; i < nRows; i++)
            {
                roomID = rooms.Rows[i][0].ToString();
                AddRoom();
                RoomGridView.Rows[i].Cells["idCol"].Value   = rooms.Rows[i][0];
                RoomGridView.Rows[i].Cells["roomNum"].Value = rooms.Rows[i][1];
                RoomGridView.Rows[i].Cells["floor"].Value   = rooms.Rows[i][2];
                PopulateExtinguisherView(i, MRoom.GetExtinguishers(roomID));
                PopulateHoseView(i, MRoom.GetHoses(roomID));
                PopulateLightView(i, MRoom.GetLights(roomID));
            }
            noChanges = true;
        }
Exemplo n.º 5
0
        public static String AddBlank()
        {
            MRoom r = new MRoom();
            String newID = r.FindID();

            String connString = Properties.Settings.Default.FAFOS;
            DataTable dt = new DataTable();
            SqlConnection con = new SqlConnection(connString);
            con.Open();
            SqlCommand command = new SqlCommand("INSERT INTO Room VALUES (" + newID + ", '"
                                                                                + "<empty>" + "', '"
                                                                                + "<empty>" + "', "
                                                                                + "0" + ")", con);
            command.ExecuteNonQuery();
            con.Close();

            return newID;
        }
Exemplo n.º 6
0
 public void HoseView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if ((e.ColumnIndex == 6) && (e.RowIndex > -1))
     {
         var dgv = sender as DataGridView;
         try
         {
             string hoseID = dgv.Rows[e.RowIndex].Cells[0].Value.ToString();
             MRoom.DeleteHose(hoseID);
         }
         catch (Exception) { }
         dgv.Rows.RemoveAt(e.RowIndex);
         _roomForm.noChanges = false;
     }
     else
     {
         _roomForm.noChanges = false;
     }
 }
Exemplo n.º 7
0
        public static String AddBlank()
        {
            MRoom  r     = new MRoom();
            String newID = r.FindID();

            String        connString = Properties.Settings.Default.FAFOS;
            DataTable     dt         = new DataTable();
            SqlConnection con        = new SqlConnection(connString);

            con.Open();
            SqlCommand command = new SqlCommand("INSERT INTO Room VALUES (" + newID + ", '"
                                                + "<empty>" + "', '"
                                                + "<empty>" + "', "
                                                + "0" + ")", con);

            command.ExecuteNonQuery();
            con.Close();

            return(newID);
        }
Exemplo n.º 8
0
 public void LightView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     Console.WriteLine("Click " + e.ColumnIndex);
     if ((e.ColumnIndex == 12) && (e.RowIndex > -1))
     {
         var dgv = sender as DataGridView;
         try
         {
             string lightID = dgv.Rows[e.RowIndex].Cells[0].Value.ToString();
             MRoom.DeleteLight(lightID);
         }
         catch (Exception) { }
         dgv.Rows.RemoveAt(e.RowIndex);
         _roomForm.noChanges = false;
     }
     else
     {
         _roomForm.noChanges = false;
     }
 }
Exemplo n.º 9
0
/**************************************** AddTos *****************************************/
        private void AddRoom()
        {
            int i = RoomGridView.Rows.Add();

            MRoom.AddBlank();
            RoomGridView.Rows[i].Cells["floor"].Value    = "";
            RoomGridView.Rows[i].Cells["idCol"].Value    = MRoom.AddBlank();
            RoomGridView.Rows[i].Cells["extCol"].Value   = "0";
            RoomGridView.Rows[i].Cells["hoseCol"].Value  = "0";
            RoomGridView.Rows[i].Cells["lightCol"].Value = "0";

            extViews.Add(NewExtinguisherView());
            this.Controls.Add(extViews[extViews.Count - 1]);

            hoseViews.Add(NewHoseView());
            this.Controls.Add(hoseViews[hoseViews.Count - 1]);

            lightViews.Add(NewLightView());
            this.Controls.Add(lightViews[lightViews.Count - 1]);

            noChanges = false;
        }
Exemplo n.º 10
0
        public static int SetExtinguishers(String[,] values)
        {
            String        connString = Properties.Settings.Default.FAFOS;
            SqlConnection con        = new SqlConnection(connString);
            SqlCommand    command;

            int temp = 1;
            int nExt = (values.Length / 9);

            con.Open();
            for (int i = 0; i < nExt; i++)
            {
                MRoom r;
                if (values[i, 0] == null)
                {
                    r            = new MRoom();
                    values[i, 0] = r.getNewID("extinguisher_id", "Extinguisher");

                    if (values[i, 0] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 1] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 2] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 3] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 4] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 5] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 6] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 7] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 8] == null)
                    {
                        temp = 0;
                    }
                    if (temp == 0)
                    {
                        MessageBox.Show("please fill in all fields");
                    }
                    else if (temp == 1)
                    {
                        command = new SqlCommand("INSERT INTO Extinguisher VALUES (" + values[i, 0] +
                                                 ",'" + values[i, 1] +
                                                 "','" + values[i, 2] +
                                                 "','" + values[i, 3] +
                                                 "','" + values[i, 4] +
                                                 "'," + values[i, 5] +
                                                 "," + values[i, 6] +
                                                 "," + values[i, 7] +
                                                 ",'" + values[i, 8] + "')", con);
                        command.ExecuteNonQuery();
                    }
                }
                else
                {
                    if (values[i, 0] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 1] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 2] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 3] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 4] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 5] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 6] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 7] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 8] == null)
                    {
                        temp = 0;
                    }
                    if (temp == 0)
                    {
                        MessageBox.Show("please fill in all fields");
                    }
                    else if (temp == 1)
                    {
                        command = new SqlCommand("UPDATE Extinguisher SET location = '" + values[i, 1] +
                                                 "', size = '" + values[i, 2] +
                                                 "', type = '" + values[i, 3] +
                                                 "', model = '" + values[i, 4] +
                                                 "', serial = " + values[i, 5] +
                                                 ", room_id = " + values[i, 6] +
                                                 ", bar_code = " + values[i, 7] +
                                                 ", manufacture_date = '" + values[i, 8] +
                                                 "' WHERE extinguisher_id = " + values[i, 0], con);
                        command.ExecuteNonQuery();
                    }
                }
            }
            con.Close();
            return(temp);
        }
Exemplo n.º 11
0
        public static int SetLights(String[,] values)
        {
            String        connString = Properties.Settings.Default.FAFOS;
            SqlConnection con        = new SqlConnection(connString);
            SqlCommand    command;
            int           temp = 1;

            int   nLight = (values.Length / 12);
            MRoom r;

            con.Open();
            for (int i = 0; i < nLight; i++)
            {
                if (values[i, 0] == null)
                {
                    r            = new MRoom();
                    values[i, 0] = r.getNewID("light_id", "Light");

                    if (values[i, 0] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 1] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 2] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 3] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 4] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 5] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 6] == null)
                    {
                        temp = 0;
                    }

                    if (values[i, 8] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 9] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 10] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 11] == null)
                    {
                        temp = 0;
                    }
                    if (temp == 0)
                    {
                        MessageBox.Show("please fill in all fields");
                    }
                    else if (temp == 1)
                    {
                        if (values[i, 7] == null)
                        {
                            values[i, 7] = "F";
                        }

                        command = new SqlCommand("INSERT INTO Light VALUES (" + values[i, 0] +
                                                 ",'" + values[i, 1] +
                                                 "','" + values[i, 2] +
                                                 "','" + values[i, 3] +
                                                 "','" + values[i, 4] +
                                                 "','" + values[i, 5] +
                                                 "','" + values[i, 6] +
                                                 "','" + values[i, 7][0] +
                                                 "'," + values[i, 8] +
                                                 "," + values[i, 9] +
                                                 "," + values[i, 10] +
                                                 ",'" + values[i, 11] + "')", con);
                        command.ExecuteNonQuery();
                    }
                }
                else
                {
                    if (values[i, 0] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 1] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 2] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 3] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 4] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 5] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 6] == null)
                    {
                        temp = 0;
                    }

                    if (values[i, 8] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 9] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 10] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 11] == null)
                    {
                        temp = 0;
                    }
                    if (temp == 0)
                    {
                        MessageBox.Show("please fill in all fields");
                    }
                    else if (temp == 1)
                    {
                        if (values[i, 7] == null)
                        {
                            values[i, 7] = "F";
                        }
                        command = new SqlCommand("UPDATE Light SET location = '" + values[i, 1] +
                                                 "', model = '" + values[i, 2] +
                                                 "', make = '" + values[i, 3] +
                                                 "', heads = '" + values[i, 4] +
                                                 "', power = '" + values[i, 5] +
                                                 "', voltage = '" + values[i, 6] +
                                                 "', require_service = '" + values[i, 7][0] +
                                                 "', serial = " + values[i, 8] +
                                                 ", room_id = " + values[i, 9] +
                                                 ", bar_code = " + values[i, 10] +
                                                 ", manufacture_date = '" + values[i, 11] +
                                                 "' WHERE light_id = " + values[i, 0], con);
                        command.ExecuteNonQuery();
                    }
                }
            }
            con.Close();
            return(temp);
        }
Exemplo n.º 12
0
        public static int SetExtinguishers(String[,] values)
        {
            String connString = Properties.Settings.Default.FAFOS;
            SqlConnection con = new SqlConnection(connString);
            SqlCommand command;

            int temp = 1;
            int nExt = (values.Length / 9);
            con.Open();
            for (int i = 0; i < nExt; i++)
            {
                MRoom r;
                if (values[i, 0] == null)
                {
                    r = new MRoom();
                    values[i, 0] = r.getNewID("extinguisher_id", "Extinguisher");

                    if (values[i, 0] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 1] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 2] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 3] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 4] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 5] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 6] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 7] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 8] == null)
                    {
                        temp = 0;
                    }
                    if (temp == 0)
                    {
                        MessageBox.Show("please fill in all fields");
                    }
                    else if (temp == 1)
                    {

                        command = new SqlCommand("INSERT INTO Extinguisher VALUES (" + values[i, 0] +
                                                                                ",'" + values[i, 1] +
                                                                               "','" + values[i, 2] +
                                                                               "','" + values[i, 3] +
                                                                               "','" + values[i, 4] +
                                                                                "'," + values[i, 5] +
                                                                                 "," + values[i, 6] +
                                                                                 "," + values[i, 7] +
                                                                                 ",'" + values[i, 8] + "')", con);
                        command.ExecuteNonQuery();
                    }
                }
                else
                {

                    if (values[i, 0] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 1] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 2] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 3] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 4] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 5] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 6] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 7] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 8] == null)
                    {
                        temp = 0;
                    }
                    if (temp == 0)
                    {
                        MessageBox.Show("please fill in all fields");
                    }
                    else if (temp == 1)
                    {
                        command = new SqlCommand("UPDATE Extinguisher SET location = '" + values[i, 1] +
                                                              "', size = '" + values[i, 2] +
                                                              "', type = '" + values[i, 3] +
                                                              "', model = '" + values[i, 4] +
                                                              "', serial = " + values[i, 5] +
                                                               ", room_id = " + values[i, 6] +
                                                               ", bar_code = " + values[i, 7] +
                                                               ", manufacture_date = '" + values[i, 8] +
                                                          "' WHERE extinguisher_id = " + values[i, 0], con);
                        command.ExecuteNonQuery();
                    }
                }

            }
            con.Close();
            return temp;
        }
Exemplo n.º 13
0
        public static int SetLights(String[,] values)
        {
            String connString = Properties.Settings.Default.FAFOS;
            SqlConnection con = new SqlConnection(connString);
            SqlCommand command;
            int temp = 1;

            int nLight = (values.Length / 12);
            MRoom r;
            con.Open();
            for (int i = 0; i < nLight; i++)
            {
                if (values[i, 0] == null)
                {
                    r = new MRoom();
                    values[i, 0] = r.getNewID("light_id", "Light");

                    if (values[i, 0] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 1] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 2] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 3] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 4] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 5] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 6] == null)
                    {
                        temp = 0;
                    }

                    if (values[i, 8] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 9] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 10] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 11] == null)
                    {
                        temp = 0;
                    }
                    if (temp == 0)
                    {
                        MessageBox.Show("please fill in all fields");
                    }
                    else if (temp == 1)
                    {
                        if (values[i, 7] == null)
                            values[i, 7] = "F";

                        command = new SqlCommand("INSERT INTO Light VALUES (" + values[i, 0] +
                                                               ",'" + values[i, 1] +
                                                              "','" + values[i, 2] +
                                                              "','" + values[i, 3] +
                                                              "','" + values[i, 4] +
                                                              "','" + values[i, 5] +
                                                              "','" + values[i, 6] +
                                                              "','" + values[i, 7][0] +
                                                               "'," + values[i, 8] +
                                                                "," + values[i, 9] +
                                                                "," + values[i, 10] +
                                                                ",'" + values[i, 11] + "')", con);
                        command.ExecuteNonQuery();
                    }
                }
                else
                {

                    if (values[i, 0] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 1] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 2] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 3] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 4] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 5] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 6] == null)
                    {
                        temp = 0;
                    }

                    if (values[i, 8] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 9] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 10] == null)
                    {
                        temp = 0;
                    }
                    if (values[i, 11] == null)
                    {
                        temp = 0;
                    }
                    if (temp == 0)
                    {
                        MessageBox.Show("please fill in all fields");
                    }
                    else if (temp == 1)
                    {
                        if (values[i, 7] == null)
                            values[i, 7] = "F";
                        command = new SqlCommand("UPDATE Light SET location = '" + values[i, 1] +
                                                              "', model = '" + values[i, 2] +
                                                              "', make = '" + values[i, 3] +
                                                              "', heads = '" + values[i, 4] +
                                                              "', power = '" + values[i, 5] +
                                                              "', voltage = '" + values[i, 6] +
                                                              "', require_service = '" + values[i, 7][0] +
                                                              "', serial = " + values[i, 8] +
                                                               ", room_id = " + values[i, 9] +
                                                               ", bar_code = " + values[i, 10] +
                                                               ", manufacture_date = '" + values[i, 11] +
                                                          "' WHERE light_id = " + values[i, 0], con);
                        command.ExecuteNonQuery();
                    }

                }

            }
            con.Close();
            return temp;
        }
Exemplo n.º 14
0
        public void Room_Ok_Button_Click(object sender, EventArgs e)
        {
            int test1 = 0;
            int test2 = 0;
            int test3 = 0;

            if (_roomForm.noChanges)
            {
                _roomForm.Close();
                return;
            }
            else
            {
                // String[,] rooms = _roomForm.GetRooms();
                // int nRooms = rooms.Length/4;
                int nRooms = _roomForm.GetRoomIndex();

                bool okToSubmit = true;

                /*
                 * Validate....okToSubmit = False;
                 */
                if (okToSubmit)
                {
                    if (MessageBox.Show("Are you sure you want to submit these changes?", "Confirm Submission", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {// if we are good, submit changes to dataBase
                        String[,] ext, hoses, lights;
                        for (int i = 0; i < nRooms; i++)
                        {
                            ext    = _roomForm.GetExtinguishers(i);
                            hoses  = _roomForm.GetHoses(i);
                            lights = _roomForm.GetLights(i);

                            /*
                             * Validate....okToSubmit = False;
                             */
                            if (okToSubmit)
                            {
                                test1 = MRoom.SetExtinguishers(ext);
                                test2 = MRoom.SetHoses(hoses);
                                test3 = MRoom.SetLights(lights);
                            }
                            else
                            {
                                return;
                            }
                        }

                        if (okToSubmit)
                        {
                            String[,] rooms = _roomForm.GetRooms();
                            int test4 = MRoom.SetMany(rooms);
                            _contractForm.noChanges = false;
                            if (test1 == 1 && test2 == 1 && test3 == 1 && test4 == 1)
                            {
                                _roomForm.Close();
                            }
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }