示例#1
0
        //changement d'onglet
        private async void TabMenu_Selecting(object sender, TabControlCancelEventArgs e)
        {
            var selectedTab = this.TabMenu.SelectedTab.Controls;

            switch (selectedTab.Owner.Name)
            {
            case "tabPage1":

                this.B_ClientGridSource.DataSource = await Communication.GetClients();

                break;

            case "tabPage2":

                this.B_ProductGridSource.DataSource = await Communication.GetProducts();

                break;

            case "tabPage3":

                this.B_EmployeeGridSource.DataSource = await Communication.GetEmployees();

                break;

            default:
                MessageBox.Show("Invalid tab name: selectedTab.Owner.Name");
                break;
            }
            //MessageBox.Show("Index selected: " + e.TabPage.Name);
        }
示例#2
0
        private async void buttonEdit_Click(object sender, EventArgs e)
        {
            //check if row exists
            if (this.selectedRow != null && this.selectedRow.Cells[0].Value != null && (Int32)this.selectedRow.Cells[0].Value != -1)
            {
                try
                {
                    var response = await Communication.UpdateClients(new Mapping.Client()
                    {
                        id        = (Int32)this.selectedRow.Cells[0].Value,
                        lastName  = this.textBoxFamilyName.Text.ToString(),
                        firstName = this.textBoxName.Text.ToString(),
                        company   = this.textBoxCompany.Text.ToString(),
                    });

                    if (response != null && response.id != -1)
                    {
                        this.B_ClientGridSource.DataSource = await Communication.GetClients();

                        this.dataGridViewClient.Rows[this.selectedRowIndex].Selected = true;
                        this.textBoxCompany.Clear(); this.textBoxFamilyName.Clear(); this.textBoxName.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Could not update client");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("FATAL ERROR: Could not update client: " + ex.Message, "ERROR: update client", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please select a row before trying to edit.", "Cell Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }