Example #1
0
        private void frmSales_Load(object sender, EventArgs e)
        {
            admin = new clsAdmin();
            DataTable temp = new DataTable();

            // fill cboHouse
            cboHouse.DisplayMember = "Address";
            cboHouse.ValueMember   = "RefHouse";
            cboHouse.DataSource    = admin.HouseListToDataTable(admin.Search_All_Houses());

            // fill cboClient
            cboClient.DisplayMember = "ClientName";
            cboClient.ValueMember   = "RefClient";
            cboClient.DataSource    = admin.ClientListToDataTable(admin.All_Client());

            // fill cboAgent
            cboAgent.DisplayMember = "AgentName";
            cboAgent.ValueMember   = "RefAgent";
            cboAgent.DataSource    = admin.AgentListToDataTable(admin.Search_All_Agents());

            if (permission != 2)
            {
                gridAll.DataSource = admin.All_Sales();
            }
            else
            {
                gridAll.DataSource = admin.Search_Sales_Belong_To_RefAgent(RefAgent);
            }
            gridAll.ReadOnly = true;
            ButtonControl(true, false, false, false, true, false);
        }
 private void frmAdminAgent_Load(object sender, EventArgs e)
 {
     admin = new clsAdmin();
     gridAll.DataSource = admin.Search_All_Agents();
     gridAll.ReadOnly   = true;
     ButtonControl(true, false, false, false, true, false);
 }
 private void frmSearchAgent_Load(object sender, EventArgs e)
 {
     admin = new clsAdmin();
     admin.Refresh_Database();
     agent_list         = new List <clsAgent>();
     agent_list         = admin.Search_All_Agents();
     gridAll.DataSource = agent_list;
     // fill cboRefClient
     cboRefClient.DisplayMember = "RefClient";
     cboRefClient.DataSource    = admin.All_Client();
 }
        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);
        }