Exemple #1
0
        private void BtnAddCustomers_Click(object sender, EventArgs e)
        {
            AdminAddCustomer cust = new AdminAddCustomer(this);

            cust.PopulateRouteCombobox();
            cust.BtnSave.Visible   = true;
            cust.BtnSave.Location  = new System.Drawing.Point(118, 641);
            cust.BtnUpdate.Visible = false;
            cust.Show();
        }
Exemple #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName = dataGridView1.Columns[e.ColumnIndex].Name;

            if (colName == "Edit")
            {
                AdminAddCustomer c = new AdminAddCustomer(this);

                c.lblID.Text           = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                c.txtCustomerName.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
                c.txtOwnerName.Text    = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
                c.txtAddress.Text      = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
                c.txtRoute.Text        = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
                c.txtPhone.Text        = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
                c.txtTelephone.Text    = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
                c.txtEmail.Text        = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
                c.cbxActive.Text       = dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString();

                //Hide the Save Button
                c.BtnSave.Visible = false;

                //Show Only the Update Button
                c.BtnUpdate.Visible = true;
                c.lbl1.Text         = "Update Customer Information";
                c.PopulateRouteCombobox();
                c.Show();
            }
            else if (colName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to delete the Customer Information?", "Delete Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("DELETE FROM tblCustomer WHERE id like '" + dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString() + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Customer Information has been successfully Deleted", "Customer Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ShowCustomersInformation();
                }
            }
        }
Exemple #3
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            //File a switch case statement
            switch (e.ClickedItem.Name.ToString())
            {
            case "edi":

                // Update the customer information, Opens the Update customer form

                contextMenuStrip1.Hide();
                AdminAddCustomer c = new AdminAddCustomer(this);

                c.lblID.Text           = ID.Text;
                c.txtCustomerName.Text = label2.Text;
                c.txtOwnerName.Text    = label3.Text;
                c.txtAddress.Text      = label4.Text;
                c.txtRoute.Text        = label5.Text;
                c.txtPhone.Text        = label6.Text;
                c.txtTelephone.Text    = label7.Text;
                c.txtEmail.Text        = label8.Text;
                c.cbxActive.Text       = label9.Text;

                //Hide the Save Button
                c.BtnSave.Visible = false;

                //Show Only the Update Button
                c.BtnUpdate.Visible = true;
                c.lbl1.Text         = "Update Customer Information";
                c.Show();

                break;

            case "del":

                // Delete the customer, Show a prompt first

                contextMenuStrip1.Hide();
                if (MessageBox.Show("Are you sure you want to Delete the Customer Information?", "Delete Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("DELETE FROM tblCustomer WHERE id like '" + ID.Text + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Customer Information has been successfully Deleted", "Customer Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ShowCustomersInformation();
                }

                break;

            case "invo":

                // See the Customers ordered invoice

                contextMenuStrip1.Hide();

                if (!AdminAdministrator.Instance.PnlContainer.Controls.ContainsKey("AdminCustomerInvoices"))
                {
                    AdminCustomerInvoices customer = new AdminCustomerInvoices(this);
                    customer.Dock = DockStyle.Fill;
                    AdminAdministrator.Instance.PnlContainer.Controls.Add(customer);

                    customer.ShowInvoiceByCustomer();
                }
                AdminAdministrator.Instance.PnlContainer.Controls["AdminCustomerInvoices"].BringToFront();
                AdminAdministrator.Instance.BackButton.Visible = true;

                break;

            case "deta":

                // See the Customer details/information in a card form

                contextMenuStrip1.Hide();

                AdminCustomerDetails cd = new AdminCustomerDetails();

                cd.lblID.Text        = ID.Text;
                cd.lblCustomer.Text  = label2.Text;
                cd.lblAddress.Text   = label4.Text;
                cd.lblRoute.Text     = label5.Text;
                cd.lblPhone.Text     = label6.Text;
                cd.lblTelephone.Text = label7.Text;
                cd.lblEmail.Text     = label8.Text;
                cd.lblStatus.Text    = label9.Text;
                cd.Show();

                break;
            }
        }