예제 #1
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            //File a switch case statement
            switch (e.ClickedItem.Name.ToString())
            {
            case "edi":

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

                c.lblID.Text    = lblID.Text;
                c.txtRoute.Text = lblRoute.Text;

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

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

                break;

            case "del":

                contextMenuStrip1.Hide();
                if (MessageBox.Show("Are you sure you want to Delete this Route?", "Delete Route", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("DELETE FROM tblRoutes WHERE rid like '" + lblID.Text + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Route has been Successfully Deleted", "Delete Route", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ShowRoutes();
                }

                break;

            case "deta":

                contextMenuStrip1.Hide();

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

                    group.ShowCustomerGroup();
                    group.BtnGoupedBy.Text = "Grouped by " + lblRoute.Text + " Route";
                }
                AdminAdministrator.Instance.PnlContainer.Controls["AdminGroupByRoute"].BringToFront();
                AdminAdministrator.Instance.BackButton.Visible = true;


                break;
            }
        }
예제 #2
0
        private void BtnAddRoutes_Click(object sender, EventArgs e)
        {
            AdminAddRoutes route = new AdminAddRoutes(this);

            //Show the Save button
            route.BtnSave.Visible   = true;
            route.BtnUpdate.Visible = false;

            //Relocate the Save button
            route.BtnSave.Location = new System.Drawing.Point(116, 181);

            //Show the Add new Route Form
            route.Show();
        }
예제 #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName = dataGridView1.Columns[e.ColumnIndex].Name;

            if (colName == "Group")
            {
                this.lblRoute.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                if (!AdminAdministrator.Instance.PnlContainer.Controls.ContainsKey("AdminGroupByRoute"))
                {
                    AdminGroupByRoute group = new AdminGroupByRoute(this);
                    group.Dock = DockStyle.Fill;
                    AdminAdministrator.Instance.PnlContainer.Controls.Add(group);

                    group.ShowCustomerGroup();
                    group.BtnGoupedBy.Text = "Group by " + lblRoute.Text + " Route";
                }
                AdminAdministrator.Instance.PnlContainer.Controls["AdminGroupByRoute"].BringToFront();
                AdminAdministrator.Instance.BackButton.Visible = true;
            }
            if (colName == "Edit")
            {
                AdminAddRoutes frm = new AdminAddRoutes(this);
                frm.lblID.Text        = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                frm.txtRoute.Text     = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                frm.BtnSave.Visible   = false;
                frm.BtnUpdate.Visible = true;
                frm.lbl1.Text         = "Update Route";
                frm.ShowDialog();
            }
            else if (colName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to Delete this Route?", "Delete Route", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("DELETE FROM tblRoutes WHERE rid like '" + dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString() + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Route has been Successfully Deleted", "Delete Route", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ShowRoutes();
                }
            }
        }