private void frmClient_Load(object sender, EventArgs e)
        {
            agent = new clsAgent();
            admin = new clsAdmin();

            if (permission == 2)
            {
                List <clsClient> temp = new List <clsClient>();
                temp.Add(agent.Searched_Cleint_For_This_Agent(refagent));
                gridAll.DataSource = temp;
            }
            else
            {
                gridAll.DataSource = admin.All_Client();
            }
            gridAll.ReadOnly = true;
            ButtonControl(true, false, false, false, true, false);
            string[]      status    = { "Seller", "Buyer", "Inactive(Buyer)", "Inactive(Seller)" };
            List <string> refhouses = new List <string>();

            refhouses.Add("0");
            foreach (clsHouse i in admin.Search_All_Houses())
            {
                refhouses.Add(i.RefHouse.ToString());
            }
            cboRefHouse.DataSource = refhouses;
            cboStatus.DataSource   = status;
        }
Exemple #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (validateData.isNameValid(txtName) && validateData.isEmailValid(txtEmail) && validateData.isPhoneNumberValid(txtPhone))
     {
         clsAgent newAgent = new clsAgent(txtId.Text, txtName.Text, txtEmail.Text, txtPhone.Text, txtPassword.Text, txtAdminId.Text);
         if (updatemode)
         {
             if (clsAgentData.updateAgent(newAgent))
             {
                 MessageBox.Show("successfully updated Agent : " + txtName.Text + " in the system!");
                 ReloadForm();
             }
         }
         else
         {
             if (clsAgentData.AddAgent(newAgent))
             {
                 MessageBox.Show("successfully added Agent : " + txtName.Text + " in the system!");
                 latestAgentId += 1;
                 ReloadForm();
             }
             else
             {
                 MessageBox.Show("the Agent with the email: " + txtEmail.Text + " exist in the system!");
                 txtEmail.Focus();
             }
         }
     }
 }
        static public clsClient Search_Client_Belong_to_Agent(int refagent)
        {
            clsAgent  tmp             = new clsAgent();
            clsClient cl              = new clsClient();
            int       refclient_agent = tmp.Searched_Agent_by_RefAgent(refagent).RefClient;

            cl = cl.Searched_Client_by_RefClient(refclient_agent);
            return(cl);
        }
 public static bool updateAgent(clsAgent newAgentData)
 {
     if (Exist(newAgentData.Email))
     {
         agentData[newAgentData.Email] = newAgentData;
         return(true);
     }
     return(false);
 }
 public static bool AddAgent(clsAgent newAgentData)
 {
     if (!Exist(newAgentData.Email))
     {
         agentData.Add(newAgentData.Email, newAgentData);
         return(true);
     }
     return(false);
 }
        static public clsHouse SearchHouse_Agent_Management(int refagent)
        {
            clsAgent  tmp             = new clsAgent();
            clsClient cl              = new clsClient();
            int       refclient_agent = tmp.Searched_Agent_by_RefAgent(refagent).RefClient;
            int       refhouse_client = cl.Searched_Client_by_RefClient(refclient_agent).RefHouse;
            clsHouse  tmphouse        = tmp.Searched_by_RefHouse(refhouse_client);

            return(tmphouse);
        }
        public clsAgentData()
        {
            agentData = new Dictionary <string, clsAgent>();
            clsAgent agent1 = new clsAgent("ag01", "agent1", "*****@*****.**", "123456789", "password1", "ad01");
            clsAgent agent2 = new clsAgent("ag02", "agent2", "*****@*****.**", "9876543210", "password2", "ad02");
            clsAgent agent3 = new clsAgent("ag03", "agent3", "agent", "9876543210", "agent", "ad03");

            agentData.Add("*****@*****.**", agent1);
            agentData.Add("*****@*****.**", agent2);
            agentData.Add("agent", agent3);
        }
Exemple #8
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Etes vous sur de vouloir supprimer cet administrateur", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         clsAgent agent = new clsAgent();
         agent.Id = Convert.ToInt32(clsGlobal.tbAgents.Rows[courant]["AgentID"]);
         clsAdministrator admin = new clsAdministrator();
         admin.DeleteAgent(agent);
         clsDataAdmin.UpdateAgents();
     }
     courant = 0;
     Row2Txt();
 }
 public static bool updateAgent(clsAgent newAgentData)
 {
     if (Exist(newAgentData.Email))
     {
         int index = getIndexByEmail(newAgentData.Email);
         tabAgent.Rows[index]["name"]     = newAgentData.Name;
         tabAgent.Rows[index]["email"]    = newAgentData.Email;
         tabAgent.Rows[index]["phone"]    = newAgentData.Phone;
         tabAgent.Rows[index]["password"] = newAgentData.Password;
         tabAgent.Rows[index]["refAdmin"] = newAgentData.AdminId;
         return(true);
     }
     return(false);
 }
 private void gridAll_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (!txtID.Enabled)
     {
         ButtonControl(true, true, false, false, true, false);
         string   selecteduserid = gridAll.Rows[e.RowIndex].Cells[1].Value.ToString();
         clsAgent selecteduser   = new clsAgent();
         selecteduser       = selecteduser.Current_User(selecteduserid);
         txtID.Text         = selecteduser.UserID;
         txtName.Text       = selecteduser.Name;
         txtPhone.Text      = selecteduser.PhoneNumber;
         txtSalesPoint.Text = selecteduser.SalesPoint.ToString();
         txtClient.Text     = selecteduser.RefClient.ToString();
     }
 }
 public static bool AddAgent(clsAgent newAgentData)
 {
     if (!Exist(newAgentData.Email))
     {
         DataRow myRow = tabAgent.NewRow();
         myRow["name"]     = newAgentData.Name;
         myRow["email"]    = newAgentData.Email;
         myRow["phone"]    = newAgentData.Phone;
         myRow["password"] = newAgentData.Password;
         myRow["refAdmin"] = newAgentData.AdminId;
         tabAgent.Rows.Add(myRow);
         return(true);
     }
     return(false);
 }
        static public clsAgent SearchAgent_by_RefAgent(int refagent)
        {
            clsAgent temp = new clsAgent();

            DataRow[] find = mySet.Tables["Agents"].Select("RefAgent = " + refagent);
            if (find.Count() != 0)
            {
                temp.RefAgent    = refagent;
                temp.Name        = find[0]["AgentName"].ToString();
                temp.UserID      = find[0]["UserID"].ToString();
                temp.PhoneNumber = find[0]["PhoneNumber"].ToString();
                temp.SalesPoint  = (int)find[0]["SalesPoint"];
                temp.RefClient   = (int)find[0]["RefClient"];
            }
            return(temp);
        }
        static public clsAgent CurrentAgentUser(string userid)// returning current user(agent)
        {
            clsAgent temp = new clsAgent();

            DataRow[] cagent = mySet.Tables["Agents"].Select("UserID = '" + userid + "'");
            if (cagent.Count() != 0)
            {
                temp.RefAgent    = (int)(cagent[0]["RefAgent"]);
                temp.Name        = cagent[0]["AgentName"].ToString();
                temp.UserID      = cagent[0]["UserID"].ToString();
                temp.PhoneNumber = cagent[0]["PhoneNumber"].ToString();
                temp.SalesPoint  = (int)(cagent[0]["SalesPoint"]);
                temp.RefClient   = (int)(cagent[0]["RefClient"]);
            }
            return(temp);
        }
        private void btnClient_Click(object sender, EventArgs e)
        {
            int      refclient = Convert.ToInt32(cboRefClient.Text);
            clsAgent agent     = new clsAgent();

            agent      = admin.Searched_Agent_with_RefClient(refclient);
            agent_list = new List <clsAgent>();
            agent_list.Add(agent);
            if (agent.RefAgent != 0)
            {
                gridAll.DataSource = agent_list;
            }
            else
            {
                MessageBox.Show("There is no result for given condition.", "NO RESULT");
            }
        }
        static public List <clsAgent> All_Agent()
        {
            List <clsAgent> templist = new List <clsAgent>();
            clsAgent        temp;

            foreach (DataRow i in mySet.Tables["Agents"].Rows)
            {
                temp             = new clsAgent();
                temp.RefAgent    = Convert.ToInt32(i["RefAgent"]);
                temp.UserID      = i["UserID"].ToString();
                temp.Name        = i["AgentName"].ToString();
                temp.PhoneNumber = i["PhoneNumber"].ToString();
                temp.SalesPoint  = (int)i["SalesPoint"];
                temp.RefClient   = (int)i["RefClient"];
                templist.Add(temp);
            }
            return(templist);
        }
        static public bool Add_Agent(clsAgent agent)
        {
            bool job_done = false;

            {
                DataRow myRow = mySet.Tables["Agents"].NewRow();
                myRow["UserID"]      = agent.UserID;
                myRow["AgentName"]   = agent.Name;
                myRow["PhoneNumber"] = agent.PhoneNumber;
                myRow["SalesPoint"]  = agent.SalesPoint;
                myRow["RefClient"]   = agent.RefClient;
                mySet.Tables["Agents"].Rows.Add(myRow);
                OleDbCommandBuilder myBuild = new OleDbCommandBuilder(adpAgent);
                adpAgent.Update(mySet.Tables["Agents"]);
                job_done = true;
            }

            return(job_done);
        }
        static public clsAgent Search_Agent_with_RefClient(int refclient)
        {
            clsAgent temp = new clsAgent();

            foreach (DataRow i in mySet.Tables["Agents"].Rows)
            {
                if (i["RefClient"].ToString() == refclient.ToString())
                {
                    temp.RefAgent    = (int)i["RefAgent"];
                    temp.Name        = i["AgentName"].ToString();
                    temp.UserID      = i["UserID"].ToString();
                    temp.PhoneNumber = i["PhoneNumber"].ToString();
                    temp.SalesPoint  = (int)i["SalesPoint"];
                    temp.RefClient   = (int)i["RefClient"];
                    break;
                }
            }
            return(temp);
        }
 private void frmAdminHouse_Load(object sender, EventArgs e)
 {
     if (permission == 2)
     {
         current            = new clsAgent();
         gridAll.DataSource = current.Searched_House_Belong_to_Current_Agent(RefAgent);
         gridAll.Focus();
     }
     else
     {
         admin = new clsAdmin();
         gridAll.DataSource = admin.Search_All_Houses();
     }
     gridAll.ReadOnly = true;
     ButtonControl(true, false, false, false, true, false);
     string[] access = { "Yes", "No" };
     string[] status = { "Sold", "Onsale" };
     cboAccess.DataSource = access;
     cboStatus.DataSource = status;
 }
        static public List <clsAgent> Search_Agents_with_Name(string name)
        {
            List <clsAgent> temp_list = new List <clsAgent>();

            foreach (DataRow i in mySet.Tables["Agents"].Rows)
            {
                if (i["AgentName"].ToString().Contains(name))
                {
                    clsAgent temp = new clsAgent();
                    temp.RefAgent    = (int)i["RefAgent"];
                    temp.Name        = i["AgentName"].ToString();
                    temp.UserID      = i["UserID"].ToString();
                    temp.PhoneNumber = i["PhoneNumber"].ToString();
                    temp.SalesPoint  = (int)i["SalesPoint"];
                    temp.RefClient   = (int)i["RefClient"];
                    temp_list.Add(temp);
                }
            }
            return(temp_list);
        }
        static public bool Edit_Agent(clsAgent agent)
        {
            bool job_done = false;

            clsAdmin edit = new clsAdmin();

            foreach (DataRow i in mySet.Tables["Agents"].Rows)
            {
                if ((int)i["RefAgent"] == agent.RefAgent)
                {
                    i["UserID"]      = agent.UserID;
                    i["AgentName"]   = agent.Name;
                    i["PhoneNumber"] = agent.PhoneNumber;
                    i["SalesPoint"]  = agent.SalesPoint;
                    i["RefClient"]   = agent.RefClient;
                    OleDbCommandBuilder myBuild = new OleDbCommandBuilder(adpAgent);
                    adpAgent.Update(mySet.Tables["Agents"]);
                    job_done = true;
                    break;
                }
            }
            return(job_done);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            clsAdmin adminagent = new clsAdmin();
            clsAgent temp       = new clsAgent();

            temp.UserID      = txtID.Text.Trim();
            temp.Name        = txtName.Text.Trim();
            temp.PhoneNumber = txtPhone.Text.Trim();
            temp.SalesPoint  = Convert.ToInt32(txtSalesPoint.Text);
            temp.RefClient   = Convert.ToInt32(txtClient.Text);
            if (Addmode)
            {
                if (adminagent.Add_New_Agent(temp))
                {
                    MessageBox.Show("New Agent " + temp.Name + " is successfully added", "New Agent");
                }
                else
                {
                    MessageBox.Show("Agent " + temp.Name + " is not added.", "Try Again");
                }
                admin.Refresh_Database();
            }
            else
            {
                temp.RefAgent = (int)gridAll.Rows[gridAll.CurrentRow.Index].Cells[0].Value;
                if (adminagent.Edit_Agent(temp))
                {
                    MessageBox.Show("Agent " + temp.Name + " is successfully modified", "Agent Modified");
                }
                else
                {
                    MessageBox.Show("Agent " + temp.Name + " is not edited.", "Try Again");
                }
            }
            gridAll.DataSource = admin.Search_All_Agents();
            ButtonControl(true, true, false, false, true, false);
        }
Exemple #22
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            clsAdministrator admin = new clsAdministrator();
            clsAgent         agent = new clsAgent();

            agent.Name      = txtNom.Text;
            agent.Email     = txtEmail.Text;
            agent.Phone     = txtPhone.Text;
            agent.Ssn       = txtNAS.Text;
            agent.Password  = txtPassword.Text;
            agent.Hire_date = dateTimeEmbauche.Value;
            agent.Id        = clsGlobal.tbAgents.Rows.Count + 1;
            clsAgent agent2 = new clsAgent(clsGlobal.tbAgents.Rows.Count + 1, txtNom.Text, txtEmail.Text, txtPhone.Text, dateTimeEmbauche.Value, txtNAS.Text, txtPassword.Text);

            if (mode == "Ajout")
            {
                DataRow myRow = clsGlobal.tbAgents.NewRow();
                myRow["AgentID"]      = 50;
                myRow["Nom"]          = agent.Name;
                myRow["Email"]        = agent.Email;
                myRow["Cellulaire"]   = agent.Phone;
                myRow["NAS"]          = agent.Ssn;
                myRow["DateEmbauche"] = agent.Hire_date;
                myRow["Password"]     = agent.Password;
                clsGlobal.tbAgents.Rows.Add(myRow);

                //admin.AddAgent(agent2);
            }
            else if (mode == "Modifier")
            {
                admin.EditAgent(agent);
            }
            clsDataAdmin.UpdateAgents();
            mode = "";
            Row2Txt();
        }
 private void frmMain_Load(object sender, EventArgs e)
 {
     if (permission == 1)
     {
         MenuControl(true, true, true, true, true);
         admin = new clsAdmin();
         admin = admin.Current_User(userID);
         MessageBox.Show("Hello, " + admin.Name);
     }
     if (permission == 2)
     {
         MenuControl(false, false, true, true, true);
         agent = new clsAgent();
         agent = agent.Current_User(userID);
         MessageBox.Show("Hello, " + agent.Name);
     }
     if (permission == 3)
     {
         MenuControl(false, false, false, false, false);
         user = new clsGeneralUser();
         user = user.Current_User(userID);
         MessageBox.Show("Hello, " + user.Name);
     }
 }