示例#1
0
        public bool Save()
        {
            bool fielddataOk = ValidateFields();

            if (fielddataOk)
            {
                if (CurrentEstateAgent == null)
                {
                    CurrentEstateAgent = EstateAgentController.Instance.MakeNewEstateAgent(stbName.Text, stbPhone.Text,
                                                                                           stbEmail.Text, (DateTime)dafStartDate.GetDateTime(), dafTerminationDate.GetDateTime(), stbUsername.Text, stbPassword.Text);
                    EstateAgentController.Instance.SaveActiveEstateAgent();

                    if (CurrentEstateAgent.Id == -1)
                    {
                        MessageBox.Show("Tilykke, du fandt en fejl!");
                        fielddataOk = false;
                    }
                }
                else
                {
                    EstateAgentController.Instance.SetActiveEstateAgent(CurrentEstateAgent);
                    EstateAgentController.Instance.SetName(stbName.Text);
                    EstateAgentController.Instance.SetTelephone(stbPhone.Text);
                    EstateAgentController.Instance.SetEmail(stbEmail.Text);
                    EstateAgentController.Instance.SetStartingDate((DateTime)dafStartDate.GetDateTime());
                    EstateAgentController.Instance.SetTerminationDate(dafTerminationDate.GetDateTime());
                    EstateAgentController.Instance.SaveActiveEstateAgent();
                }
            }
            return(fielddataOk);
        }
示例#2
0
 internal void AddToCatalog(EstateAgent estateAgent)
 {
     if (!estateAgents.ContainsKey(estateAgent.Id))
     {
         estateAgents.Add(estateAgent.Id, estateAgent);
     }
 }
示例#3
0
 internal void RemoveFromCatalog(EstateAgent estateAgent)
 {
     if (estateAgents.ContainsKey(estateAgent.Id))
     {
         estateAgents.Remove(estateAgent.Id);
     }
 }
示例#4
0
        public static void ShowBaseForm(EstateAgent estateAgent)
        {
            Thread loginThread = new Thread(RunBaseForm);      //Kalder metoden RunLogin i en ny tråd

            loginThread.SetApartmentState(ApartmentState.STA); //Indstiller tråden til at køre med en enkelt tråd
            loginThread.Start(estateAgent);                    //Starter tråden med en parameter
        }
示例#5
0
 /// <summary>
 /// Sætter mægler
 /// </summary>
 /// <param name="estateAgent"></param>
 /// <author>Mathias Poulsen</author>
 public void SetEstateAgent(EstateAgent estateAgent)
 {
     if (activeCase.EstateAgent != estateAgent)
     {
         activeCase.EstateAgent = estateAgent;
     }
 }
示例#6
0
        private void PerformLogin()
        {
            //Hvis input er gyldig, prøv at logge ind
            if (stbUsername.Validate() && stbPassword.Validate())
            {
                string username = stbUsername.Text;
                string password = stbPassword.Text;

                EstateAgent estateAgent = EstateAgentController.Instance.LoginEstateAgent(username, password);

                //Hvis estateAgent ikke er null, var login'et korrekt
                if (estateAgent != null)
                {
                    if (chbAutoLogin.Checked)
                    {
                        SaveAutomaticLogin(username, password);
                    }

                    OpenMainForm(estateAgent);
                }
                else
                {
                    MessageBox.Show("Forkerte log ind oplysninger", "Living Smart", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#7
0
        /// <summary>
        /// Distributes Cases to EstateAgents based on the Key in given in the constructor.
        /// The key could be the price of the house
        /// </summary>
        /// <returns>Returns a dictionary containing Broker as key and a list of Cases as value.</returns>
        /// <author>René Sørensen</author>>
        public Dictionary <EstateAgent, List <Case> > ReturnOpenHouseShuffle()
        {
            LoadPriorityQueue();

            if (brokers.Count > 0)
            {
                int brokerIndex = 0;

                while (pq.Count > 0)
                {
                    if (brokerIndex == 0)
                    {
                        Shuffle(brokers);
                    }

                    EstateAgent b = brokers[brokerIndex];
                    Case        c = pq.RemoveMax();

                    if (!openHouse.ContainsKey(b))
                    {
                        openHouse.Add(b, new List <Case>());
                    }
                    openHouse[b].Add(c);

                    brokerIndex = (brokerIndex + 1) % brokers.Count;
                }
            }
            return(openHouse);
        }
        public async Task <EstateAgent> AddEstateAgent(EstateAgent estateAgent)
        {
            var result = await _directoryContext.EstateAgent.AddAsync(estateAgent);

            await _directoryContext.SaveChangesAsync();

            return(result.Entity);
        }
示例#9
0
        public EstateAgentLine(BaseForm baseForm, EstateAgent estateAgent)
        {
            this.estateAgent = estateAgent;
            this.baseForm    = baseForm;

            InitializeComponent();
            UpdateFields();
        }
示例#10
0
 private void FinishCreating(EstateAgent estateAgent)
 {
     EstateAgentController.Instance.CancelActiveEstateAgent();
     if (callback != null)
     {
         callback(estateAgent);
     }
     Close();
 }
示例#11
0
        public OpenHousePair(EstateAgent agent, List <Case> cases)
        {
            EstateAgent = agent;
            Properties  = cases;
            InitializeComponent();

            UpdateFields();
            UpdateList();
        }
示例#12
0
        private void UpdateEstateAgent(EstateAgent estateAgent)
        {
            if (estateAgent != null)
            {
                CaseController.Instance.SetEstateAgent(estateAgent);

                lblEstateAgentName.Text = estateAgent.Name;
            }
        }
示例#13
0
        public EstateAgentLineSelect(SelectEstateAgentDropIn dropIn, EstateAgent estateAgent)
        {
            EstateAgent = estateAgent;
            this.dropIn = dropIn;
            InitializeComponent();

            UpdateFields();

            BindEvent(this);
        }
示例#14
0
        public EstateAgentLineSearch(EstateAgentSearchDropIn dropIn, EstateAgent estateAgent)
        {
            this.dropIn = dropIn;
            EstateAgent = estateAgent;

            InitializeComponent();

            UpdateFields();

            BindEvent(this);
        }
示例#15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="estateAgent"></param>
 /// <author>Mathias Petersen</author>
 internal void Save(EstateAgent estateAgent)
 {
     if (estateAgent.Id == -1)
     {
         estateAgent.Id = db.CreateEstateAgent(estateAgent);
     }
     else
     {
         db.UpdateEstateAgent(estateAgent);
     }
 }
示例#16
0
 private void NewEstateAgentAdded(EstateAgent estateAgent)
 {
     if (estateAgent != null)
     {
         var control = new EstateAgentLine(baseForm, estateAgent)
         {
             Margin = Padding.Empty
         };
         clsEstateAgents.AddControl(control);
         sblActiveCases.Text = clsEstateAgents.Controls.Count.ToString();
     }
 }
示例#17
0
        public async Task <IActionResult> AddEstateAgent([FromBody] EstateAgentForAddDto estateAgent)
        {
            var estateAgentToCreate = new EstateAgent
            {
                Name       = estateAgent.Name,
                Gender     = estateAgent.Gender,
                Age        = estateAgent.Age,
                Login      = estateAgent.Login,
                LastActive = estateAgent.LastActive,
                City       = estateAgent.City
            };

            var creatEstateAgent = await _repo.AddEstateAgent(estateAgentToCreate);

            return(StatusCode(201));
        }
示例#18
0
        /// <summary>
        /// Creates a new EstateAgent in the database.
        /// </summary>
        /// <param name="estateAgent">EstateAgent to be created.</param>
        /// <returns>Returns the Id of the EstateAgent created.</returns>
        /// <author>René Sørensen</author>
        public int CreateEstateAgent(EstateAgent estateAgent)
        {
            SqlCommand cmd = new SqlCommand
            {
                CommandText = "INSERT INTO EstateAgent OUTPUT INSERTED.EstateAgentId VALUES (@Name, @Telephone, @Email, @StartingDate, @TerminationDate, @Username, @Password); "
            };

            cmd.Parameters.Add("@Name", SqlDbType.NVarChar, 50, "Name").Value                  = estateAgent.Name;
            cmd.Parameters.Add("@Telephone", SqlDbType.NVarChar, 20, "Telephone").Value        = estateAgent.Telephone;
            cmd.Parameters.Add("@Email", SqlDbType.NVarChar, 50, "Email").Value                = estateAgent.Email;
            cmd.Parameters.Add("@StartingDate", SqlDbType.Date, 8, "StartingDate").Value       = estateAgent.StartingDate;
            cmd.Parameters.Add("@TerminationDate", SqlDbType.Date, 8, "TerminationDate").Value = (object)estateAgent.TerminationDate ?? DBNull.Value;
            cmd.Parameters.Add("@Username", SqlDbType.NVarChar, 15, "Username").Value          = estateAgent.Username;
            cmd.Parameters.Add("@Password", SqlDbType.NVarChar, 25, "Password").Value          = estateAgent.Password;

            return((int)DBConnectionMSSQL.Instance.ExecuteScalar(cmd, -1));
        }
示例#19
0
        private void PerformAutoLogin()
        {
            string username = Convert.ToString(RegistryWrapper.RegKey.GetValue("AutomaticLoginEstateAgentId", null));
            string password = Convert.ToString(RegistryWrapper.RegKey.GetValue("AutomaticLoginPassword", null));

            EstateAgent estateAgent = EstateAgentController.Instance.LoginEstateAgent(username, password);

            if (estateAgent != null)
            {
                OpenMainForm(estateAgent);
            }
            else
            {
                ClearAutomaticLogin();
                MessageBox.Show("Forkerte log ind oplysninger", "Living Smart", MessageBoxButtons.OK, MessageBoxIcon.Error);
                stbUsername.Text = username;
            }
        }
示例#20
0
        /// <summary>
        /// Returns an EstateAgent having the specified username and password.
        /// </summary>
        /// <param name="username">username of the estate agent.</param>
        /// <param name="password">password of the estate agent.</param>
        /// <returns>The estate agent having the given username and password, null otherwise</returns>
        /// <author>René Sørensen</author>
        public EstateAgent LoginEstateAgent(string username, string password)
        {
            EstateAgent estateAgent = null;
            SqlCommand  cmd         = new SqlCommand
            {
                CommandText = "SELECT * FROM EstateAgent WHERE Username = (@Username) AND Password = (@Password);",
            };

            cmd.Parameters.Add("@Username", SqlDbType.NVarChar, 15, "Username").Value = username;
            cmd.Parameters.Add("@Password", SqlDbType.NVarChar, 25, "Password").Value = password;

            SqlDataReader reader = null;

            try
            {
                reader = DBConnectionMSSQL.Instance.ExecuteReader(cmd);
                while (reader.Read())
                {
                    int      readEstateAgentId = (int)reader["EstateAgentId"];
                    string   name            = (string)reader["Name"];
                    string   telephone       = (string)reader["Telephone"];
                    string   email           = (string)reader["Email"];
                    DateTime startingDate    = (DateTime)reader["StartingDate"];
                    DateTime?terminationDate = (reader["TerminationDate"].GetType() == typeof(DBNull)) ? null : (DateTime?)reader["TerminationDate"];
                    string   usernameData    = (string)reader["Username"];
                    string   passwordData    = (string)reader["Password"];

                    estateAgent = new EstateAgent(readEstateAgentId, name, telephone, email, startingDate, terminationDate, usernameData, passwordData);
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return(estateAgent);
        }
示例#21
0
        /// <summary>
        /// Updates the information from an EstateAgent, in the database.
        /// </summary>
        /// <param name="estateAgent">EstateAgent to be updated.</param>
        /// <author>René Sørensen</author>
        public void UpdateEstateAgent(EstateAgent estateAgent)
        {
            int estateagentId = estateAgent.Id;

            SqlCommand cmd = new SqlCommand
            {
                CommandText = "UPDATE EstateAgent SET Name = (@Name), Telephone = (@Telephone), Email = (@Email), StartingDate = (@StartingDate), TerminationDate = (@TerminationDate) WHERE EstateAgentId = (@EstateAgentId)"
            };

            cmd.Parameters.Add("@EstateAgentId", SqlDbType.Int, 4, "EstateAgentId").Value = estateagentId;

            cmd.Parameters.Add("@Name", SqlDbType.NVarChar, 50, "Name").Value                  = estateAgent.Name;
            cmd.Parameters.Add("@Telephone", SqlDbType.NVarChar, 20, "Telephone").Value        = estateAgent.Telephone;
            cmd.Parameters.Add("@Email", SqlDbType.NVarChar, 50, "Email").Value                = estateAgent.Email;
            cmd.Parameters.Add("@StartingDate", SqlDbType.Date, 8, "StartingDate").Value       = estateAgent.StartingDate;
            cmd.Parameters.Add("@TerminationDate", SqlDbType.Date, 8, "TerminationDate").Value = (object)estateAgent.TerminationDate ?? DBNull.Value;

            DBConnectionMSSQL.Instance.ExecuteNonQuery(cmd);
        }
示例#22
0
        public NewEstateAgentDropIn(BaseForm baseForm, EstateAgent estateAgent, NewEstateAgentFinish callback)
            : base(baseForm)
        {
            InitializeComponent();

            this.currentEstateAgent = estateAgent;
            this.callback           = callback;

            if (currentEstateAgent != null)
            {
                btnSave.Text           = @"Gem";
                lblNewEstateAgent.Text = @"Redigér ejendomsmægler";
            }

            newEstateAgentForm          = new NewEstateAgent(baseForm, estateAgent);
            newEstateAgentForm.Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            newEstateAgentForm.Location = new Point(10, 10);
            pnlContentHolder.Controls.Add(newEstateAgentForm);
        }
示例#23
0
        /// <summary>
        /// Returns all the EstateAgents from the database.
        /// </summary>
        /// <returns>Returns a List of all the EstateAgents from the database.</returns>
        /// <author>René Sørensen</author>
        public List <EstateAgent> ReadEstateAgents()
        {
            List <EstateAgent> estateAgentList = new List <EstateAgent>();
            SqlCommand         cmd             = new SqlCommand
            {
                CommandText = "SELECT * FROM EstateAgent;",
            };

            SqlDataReader reader = null;

            try
            {
                reader = DBConnectionMSSQL.Instance.ExecuteReader(cmd);
                while (reader.Read())
                {
                    int      estateAgentId   = (int)reader["EstateAgentId"];
                    string   name            = (string)reader["Name"];
                    string   telephone       = (string)reader["Telephone"];
                    string   email           = (string)reader["Email"];
                    DateTime startingDate    = (DateTime)reader["StartingDate"];
                    DateTime?terminationDate = reader["TerminationDate"] is DBNull ? null : (DateTime?)reader["TerminationDate"];
                    string   username        = (string)reader["Username"];
                    string   password        = (string)reader["Password"];

                    EstateAgent estateAgent = new EstateAgent(estateAgentId, name, telephone, email, startingDate, terminationDate, username, password);
                    estateAgentList.Add(estateAgent);
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return(estateAgentList);
        }
示例#24
0
        public BaseForm(EstateAgent estateAgent)
        {
            AutoScaleMode = AutoScaleMode.None;

            DefaultEstateAgent = estateAgent;

            InitializeComponent();

            InitializeSystem();

            pages = new Page[Enum.GetNames(typeof(PagesIndex)).Length];

            pages[GetPageIndex(PagesIndex.Overview)] = new Page(
                typeof(Overview), "Oversigt",
                Classes.Menu.MenuAnchor.Left
                );
            pages[GetPageIndex(PagesIndex.Cases)] = new Page(
                typeof(Cases), "Sager",
                Classes.Menu.MenuAnchor.Left
                );
            pages[GetPageIndex(PagesIndex.Customers)] = new Page(
                typeof(Customers), "Kunder",
                Classes.Menu.MenuAnchor.Left
                );
            pages[GetPageIndex(PagesIndex.EstateAgents)] = new Page(
                typeof(EstateAgents), "Mæglere",
                Classes.Menu.MenuAnchor.Left
                );
            pages[GetPageIndex(PagesIndex.Partners)] = new Page(
                typeof(Partners), "Partnere",
                Classes.Menu.MenuAnchor.Left
                );
            pages[GetPageIndex(PagesIndex.OpenHouse)] = new Page(
                typeof(OpenHousePage), "Åbent hus",
                Classes.Menu.MenuAnchor.Left
                );

            InitializePages();

            InitializeMenu();
        }
示例#25
0
        /// <summary>
        /// Laver udskriftfil med statistik for solgte ejendomme for en bestemt mægler og et bestemt år
        /// </summary>
        /// <param name="fileStream"></param>
        public static string CreatePrintEstateAgent(int estateAgentId, int year)
        {
            var         list  = StatisticsController.Instance.ReadEstateAgentStatistics(estateAgentId, year);
            EstateAgent agent = EstateAgentController.Instance.GetEstateAgent(estateAgentId);

            string page = "";

            string[] headerText = { "Statistik på mægler: " + agent.Name,
                                    " ",
                                    " ",
                                    "Statistik af solgte ejendomme i databasen for en udvalgt mægler og",
                                    "et valgt år vist som summen af salgspriser og antal solgte ejendomme" };

            page += CreateHeader(headerText);

            page += docGen.FixedMultiColumnstext(new[]
            {
                new docGen.Column("Årstal", 15),
                new docGen.Column("Måned", 20),
                new docGen.Column("Salgspris total", 25),
                new docGen.Column("Antal ejendomme", 40)
            });
            page += docGen.FilledLine();

            foreach (Statistics statLine in list)
            {
                page += CreateStatisticsLineEstateAgent(statLine);
            }

            page += docGen.FilledLine();

            //Hvis vi vil udregne total for alle mæglere så skriv det ind her

            page += docGen.EmptyLine();

            page += docGen.CreateFooterLine();

            return(page);
        }
示例#26
0
        public NewEstateAgent(BaseForm baseForm, EstateAgent estateAgent)
        {
            CurrentEstateAgent = estateAgent;

            InitializeComponent();

            if (estateAgent != null)
            {
                stbName.Text  = estateAgent.Name;
                stbPhone.Text = estateAgent.Telephone;
                stbEmail.Text = estateAgent.Email;
                dafStartDate.SetDate(estateAgent.StartingDate);
                if (estateAgent.TerminationDate != null)
                {
                    dafTerminationDate.SetDate((DateTime)estateAgent.TerminationDate);
                }
                stbUsername.Text = estateAgent.Username;
                stbPassword.Text = estateAgent.Password;

                stbUsername.Enabled = false;
                stbPassword.Enabled = false;
            }
        }
 private void FinishSearch(EstateAgent estateAgent)
 {
     baseForm.CloseDropIn(this);
     callback(estateAgent);
 }
示例#28
0
 /// <summary>
 /// Tilføjer en mægler til kataloget
 /// </summary>
 /// <param name="estateAgent"></param>
 private void AddEstateAgent(EstateAgent estateAgent)
 {
     estateAgentCatalog.AddToCatalog(estateAgent);
 }
示例#29
0
 private void OpenMainForm(EstateAgent estateAgent)
 {
     formShift = true;
     FormHandler.ShowBaseForm(estateAgent);
     Close();            //Lukker Login formen
 }
示例#30
0
 private void Callback(EstateAgent estateAgent)
 {
     UpdateFields();
 }