Пример #1
0
        private void Save()
        {
            IBuildingService buildingService = new BuildingService();
            Boolean ret = false;
            string message = String.Empty;
            Building building = new Building()
            {
                BuildingCode = txtBuildingCode.Text.ToString(),
                Description = txtDescription.Text.ToString(),
                BuildingName = txtName.Text.ToString(),
                Rooms = rooms

            };
            if (Op.Equals("edit"))
            {
                ret = buildingService.UpdateBuilding(ref building, ref message);
              
                building.Rooms = null;
                Log("U", "Buildings", building);
                if (rooms.Count > 0)
                {
                    foreach (Room r in rooms)
                        Log("C", "Rooms", r);
                }
                
                if (ret)
                    MessageBox.Show("Saved Successfully");
                else
                    MessageBox.Show("Error Saving");
                Close();

            }
            else
            {
                String la = txtBuildingCode.Text.ToString();
                if (la.Equals(String.Empty))
                {
                    MessageBox.Show("Provide Building Code");
                }
                else
                {
                    ret = buildingService.CreateBuilding(ref building, ref message);
                    building.Rooms = null;
                    Log("C", "Buildings", building);
                    if (rooms.Count > 0)
                    {
                        foreach (Room r in rooms)
                            Log("C", "Rooms", r);
                    }
                    if (ret)
                        MessageBox.Show("Saved Successfully");
                    else
                        MessageBox.Show("Error Saving");
                    Close();
                }
            }

            
        }
Пример #2
0
        public void LoadBuildings()
        {
            IBuildingService buildingService = new BuildingService();
            string message = String.Empty;
            try
            {
                var buildings = buildingService.GetAllBuildings();
                buildingList = new List<Building>(buildings);
                gvBuilding.DataSource = buildings;
                gvBuilding.Refresh();

                if (gvBuilding.RowCount != 0)
                    gvBuilding.Rows[0].IsSelected = true;
            }
            catch (Exception ex)
            {
                message = "Error Loading Building List";
                MessageBox.Show(ex.ToString());
            }

        }
Пример #3
0
        private void frmBuildingDetails_Load(object sender, EventArgs e)
        {
            if (Op.Equals("edit"))
            {
                SetFields();
                SetRoomGrid();
            }

            if (Op.Equals("new"))
            {
                IBuildingService buildingService = new BuildingService();
                BindRoomGrid();
            }
        }
Пример #4
0
        private void txtBuildingCode_Leave(object sender, EventArgs e)
        {
            Building bldg = new Building();
            string msg = string.Empty;
            IBuildingService bldgService = new BuildingService();

           
            bldg = bldgService.GetBuilding(txtBuildingCode.Text, ref msg);
            if (bldg.BuildingCode != null)
            {
                MessageBox.Show("Building Code already exist!");
                txtBuildingCode.Text = string.Empty;
                txtBuildingCode.Focus();
                return;
            }
        }