Ejemplo n.º 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();
                }
            }

            
        }
Ejemplo n.º 2
0
 public void TranslateBuildingBDOToBuildingDTO(BuildingBDO bBDO, Building bldg)
 {
     bldg.BuildingCode = bBDO.BuildingCode;
     bldg.BuildingName = bBDO.BuildingName;
     bldg.Deactivated = bBDO.Deactivated;
     bldg.Description = bBDO.Description;
     bldg.Rooms = ToRoomDTO(bBDO.Rooms);
 }
Ejemplo n.º 3
0
        public void TranslateBuildingToBuildingBDO(Building b, BuildingBDO bbdo)
        {
            bbdo.BuildingCode = b.BuildingCode;
            bbdo.BuildingName = b.BuildingName;
            bbdo.Deactivated = b.Deactivated;
            bbdo.Description = b.Description;
            bbdo.Rooms = ToRoomBDOList(b.Rooms);


        }
Ejemplo n.º 4
0
 public List<Building> GetAllBuildings()
 {
     List<Building> blist = new List<Building>();
     foreach (BuildingBDO bbdo in blogic.GetAllBuildings())
     {
         Building b = new Building();
         TranslateBuildingBDOToBuilding(bbdo, b);
         blist.Add(b);
     }
     return blist;
 }
Ejemplo n.º 5
0
        public Building GetBuilding(string buildingCode, ref string message)
        {
            Building bldg = new Building();
            BuildingBDO bbdo = blogic.GetBuilding(buildingCode);
            if (bbdo != null)
            {
                TranslateBuildingBDOToBuildingDTO(bbdo, bldg);
            }
            else message = "Building Does Not Exists";

            return bldg;
        }
Ejemplo n.º 6
0
        private void gvBuilding_SelectionChanged(object sender, EventArgs e)
        {
            int selectedIndex = gvBuilding.CurrentRow.Index;


            if (selectedIndex >= 0)
            {
                string bID = gvBuilding.Rows[selectedIndex].Cells["BuildingCode"].Value.ToString();
                List<Building> item = new List<Building>();
                item = buildingList.FindAll(x => x.BuildingCode.ToString() == bID);

                buildingSelected = new Building();
                buildingSelected = (Building)item[0];
            }
        }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
0
 public bool UpdateBuilding(ref Building building, ref string message)
 {
     BuildingBDO bbdo = new BuildingBDO();
     TranslateBuildingToBuildingBDO(building, bbdo);
     return blogic.UpdateBuilding(ref bbdo, ref message);
 }