예제 #1
0
        public void LoadAreaAndDeviceControls()
        {
            //Fill Combobox of Area.
            HouseAreaService.HouseAreaClient _has = new HouseAreaClient();
            DevicesService.DevicesClient     _dc  = new DevicesClient();

            string[] _houseAreaIDs = _has.GetAllHouseAreasID();

            for (int i = 0; i < _houseAreaIDs.Length; i++)
            {
                string[] _houseAreaData = _has.GetHouseAreaData(_houseAreaIDs[i]);
                comboBoxAreaName.Items.Add(_houseAreaData[1]);
                _dictionaryHouseAreaIDsAndNames.Add(_houseAreaData[1], _houseAreaData[0]);
            }

            //Fill Combo Box of Device.
            string[] _deviceIDs = _dc.GetAllDevicesID();

            for (int i = 0; i < _deviceIDs.Length; i++)
            {
                string[] _deviceData = _dc.GetDeviceData(_deviceIDs[i]);
                comboBoxDeviceName.Items.Add(_deviceData[1]);
                _dictionaryDeviceIDsAndNames.Add(_deviceData[1], _deviceData[0]);
            }
        }
예제 #2
0
        public void LoadAreaControls()
        {
            //Fill Combobox of Area.
            HouseAreaService.HouseAreaClient _has = new HouseAreaClient();

            string[] _houseAreaIDs = _has.GetAllHouseAreasID();

            for (int i = 0; i < _houseAreaIDs.Length; i++)
            {
                string[] _houseAreaData = _has.GetHouseAreaData(_houseAreaIDs[i]);
                comboBoxAreaName.Items.Add(_houseAreaData[1]);
                _dictionaryHouseAreaIDsAndNames.Add(_houseAreaData[1], _houseAreaData[0]);
            }
        }
예제 #3
0
        public void ShowAllHouseAreas()
        {
            dataGridViewHouseArea.Rows.Clear();

            HouseAreaService.HouseAreaClient _has = new HouseAreaClient();

            string[] _houseAreasID = _has.GetAllHouseAreasID();


            for (int i = 0; i < _houseAreasID.Length; i++)
            {
                string[] _houseAreasData = _has.GetHouseAreaData(_houseAreasID[i]);

                dataGridViewHouseArea.Rows.Add();
                dataGridViewHouseArea[_colAreaAlreadyInDB.Name, i].Value = "1";
                dataGridViewHouseArea[_colAreaID.Name, i].Value          = _houseAreasData[0];
                dataGridViewHouseArea[_colAreaName.Name, i].Value        = _houseAreasData[1];
                dataGridViewHouseArea[_colAreaStatus.Name, i].Value      = _houseAreasData[2];
            }
        }
예제 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            HouseAreaService.HouseAreaClient _has = new HouseAreaClient();

            for (int i = 0; i < dataGridViewHouseArea.Rows.Count; i++)
            {
                if (dataGridViewHouseArea.Rows[i].Cells[_colAreaAlreadyInDB.Name].Value != null)
                {
                    //Update
                    string[] _houseAreaData = new string[3];
                    _houseAreaData[0] = dataGridViewHouseArea.Rows[i].Cells[_colAreaID.Name].Value.ToString().Trim();
                    _houseAreaData[1] = dataGridViewHouseArea.Rows[i].Cells[_colAreaName.Name].Value.ToString().Trim();
                    _houseAreaData[2] = dataGridViewHouseArea.Rows[i].Cells[_colAreaStatus.Name].Value.ToString().Trim();

                    _has.UpdateHouseArea(_houseAreaData);
                }

                else
                {
                    //Add New
                    string[] _houseAreaData = new string[3];
                    _houseAreaData[0] = dataGridViewHouseArea.Rows[i].Cells[_colAreaID.Name].Value.ToString().Trim();
                    _houseAreaData[1] = dataGridViewHouseArea.Rows[i].Cells[_colAreaName.Name].Value.ToString().Trim();
                    _houseAreaData[2] = dataGridViewHouseArea.Rows[i].Cells[_colAreaStatus.Name].Value.ToString().Trim();

                    _has.AddHouseArea(_houseAreaData);
                }
            }

            //Delete

            for (int i = 0; i < _houseAreaList.Count; i++)
            {
                _has.DeleteHouseArea(_houseAreaList[i].ToString().Trim());
            }

            MessageBox.Show("Data is saved successfully");

            ShowAllHouseAreas();
        }