Exemple #1
0
        private void StallForm_Load(object sender, EventArgs e)
        {
            switch (state)
            {
            case 0:
                textBoxName.Enabled        = true;
                textBoxDescription.Enabled = true;
                buttonStall.Text           = "Add Stall";
                break;

            case 1:
                SL = SQLServerConnection.GetStallList();
                foreach (StallList tempList in SL)
                {
                    comboBoxID.Items.Add(tempList.StallID);
                }
                comboBoxID.Enabled = true;
                buttonStall.Text   = "Update Stall";
                break;

            case 2:
                SL = SQLServerConnection.GetStallList();
                foreach (StallList tempList in SL)
                {
                    comboBoxID.Items.Add(tempList.StallID);
                }
                comboBoxID.Enabled = true;
                buttonStall.Text   = "Delete Stall";
                break;

            default:
                Error("Unkown Error");
                break;
            }
        }
Exemple #2
0
        private void FoodTypeForm_Load(object sender, EventArgs e)
        {
            switch (state)
            {
            case 0:
                textBoxName.Enabled        = true;
                textBoxDescription.Enabled = true;
                buttonType.Text            = "Add Food Type";
                break;

            case 1:
                TL = SQLServerConnection.GetFoodTypeList();
                foreach (TypeList tempList in TL)
                {
                    comboBoxID.Items.Add(tempList.FoodTypeID);
                }
                comboBoxID.Enabled = true;
                buttonType.Text    = "Update Food Type";
                break;

            case 2:
                TL = SQLServerConnection.GetFoodTypeList();
                foreach (TypeList tempList in TL)
                {
                    comboBoxID.Items.Add(tempList.FoodTypeID);
                }
                comboBoxID.Enabled = true;
                buttonType.Text    = "Delete Food Type";
                break;

            default:
                Error("Unkown Error");
                break;
            }
        }
 public static void DeleteStall(SqlConnection SQLconn, int StallID)
 {
     using (SqlCommand command = new SqlCommand("dbo.DeleteStall", SQLconn))
     {
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.Add("@IDStall", SqlDbType.Int).Value = StallID;
         SQLconn.Open();
         command.ExecuteNonQuery();
     }
     SQLServerConnection.CloseSQLConnection(SQLconn);
 }
 public static void AddType(SqlConnection SQLconn, string FoodType, string TypeDescription)
 {
     using (SqlCommand command = new SqlCommand("dbo.AddNewFoodType", SQLconn))
     {
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.Add("@TypeFood", SqlDbType.VarChar, 100).Value = FoodType;
         command.Parameters.Add("@DescType", SqlDbType.VarChar, 200).Value = TypeDescription;
         SQLconn.Open();
         command.ExecuteNonQuery();
     }
     SQLServerConnection.CloseSQLConnection(SQLconn);
 }
 public static void UpdateStall(SqlConnection SQLconn, int StallID, string StallTypeName, string StallDescription)
 {
     using (SqlCommand command = new SqlCommand("dbo.UpdateStall", SQLconn))
     {
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.Add("@IDStall", SqlDbType.Int).Value            = StallID;
         command.Parameters.Add("@NameStall", SqlDbType.VarChar, 100).Value = StallTypeName;
         command.Parameters.Add("@DescStall", SqlDbType.VarChar, 200).Value = StallDescription;
         SQLconn.Open();
         command.ExecuteNonQuery();
     }
     SQLServerConnection.CloseSQLConnection(SQLconn);
 }
        private void buttonView_Click(object sender, EventArgs e)
        {
            SqlConnection SQLconn = SQLServerConnection.SQLConnection();

            using (SqlDataAdapter dataAdapter = new SqlDataAdapter("dbo.ViewMenu", SQLconn))
            {
                var command = new SqlCommandBuilder(dataAdapter);
                var ds      = new DataSet();
                dataAdapter.Fill(ds);
                dataGridView.DataSource = ds.Tables[0];
            }
            SQLServerConnection.CloseSQLConnection(SQLconn);
        }
Exemple #7
0
        private void buttonSearchStall_Click(object sender, System.EventArgs e)
        {
            string        Stall   = "%" + textBoxStallName.Text + "%";
            SqlConnection SQLconn = SQLServerConnection.SQLConnection();

            using (SqlCommand command = new SqlCommand("dbo.SearchStall", SQLconn))
            {
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@NameStall", SqlDbType.VarChar, 100).Value = Stall;
                var            ds = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter();
                SQLconn.Open();
                da.SelectCommand = command;
                da.Fill(ds);
                MMF.dataGridView.DataSource = ds.Tables[0];
            }
            SQLServerConnection.CloseSQLConnection(SQLconn);
        }
        public static List <StallList> GetStallList(SqlConnection SQLconn)
        {
            List <StallList> SL = new List <StallList>();

            using (SqlCommand command = new SqlCommand("dbo.GetStallList", SQLconn))
            {
                command.CommandType = CommandType.StoredProcedure;
                SQLconn.Open();
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        StallList tempSL = new StallList();
                        tempSL.StallID          = reader.GetInt32(0);
                        tempSL.StallName        = reader.GetString(1);
                        tempSL.StallDescription = reader.GetString(2);
                        SL.Add(tempSL);
                    }
                }
            }
            SQLServerConnection.CloseSQLConnection(SQLconn);
            return(SL);
        }
        public static List <TypeList> GetTypeList(SqlConnection SQLconn)
        {
            List <TypeList> TL = new List <TypeList>();

            using (SqlCommand command = new SqlCommand("dbo.GetFoodTypeList", SQLconn))
            {
                command.CommandType = CommandType.StoredProcedure;
                SQLconn.Open();
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        TypeList tempTL = new TypeList();
                        tempTL.FoodTypeID      = reader.GetInt32(0);
                        tempTL.FoodType        = reader.GetString(1);
                        tempTL.TypeDescription = reader.GetString(2);
                        TL.Add(tempTL);
                    }
                }
            }
            SQLServerConnection.CloseSQLConnection(SQLconn);
            return(TL);
        }
Exemple #10
0
        private void buttonType_Click(object sender, EventArgs e)
        {
            SQLServerConnection.FTF = this;
            switch (state)
            {
            case 0:
                if (textBoxName.Text == "")
                {
                    MessageBox.Show("Error: Empty Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    try
                    {
                        SQLServerConnection.AddFoodType(textBoxName.Text, textBoxDescription.Text);
                    }
                    catch (Exception ex)
                    {
                        Error(ex.ToString());
                    }
                    MessageBox.Show("Food Type with name: " + textBoxName.Text + " has been successfully added to the database.", "New Food Type Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case 1:
                try
                {
                    if (textBoxName.Text != "")
                    {
                        SQLServerConnection.UpdateFoodType(Convert.ToInt32(comboBoxID.Text), textBoxName.Text, textBoxDescription.Text);
                    }
                    else
                    {
                        Error("No selected item to update");
                    }
                    MessageBox.Show("Food Type with ID: " + comboBoxID.Text + " has been successfully updated.", "Food Type Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    Error(ex.ToString());
                }
                break;

            case 2:
                try
                {
                    if (textBoxName.Text != "")
                    {
                        SQLServerConnection.DeleteFoodType(Convert.ToInt32(comboBoxID.Text));
                    }
                    else
                    {
                        Error("No selected item to update");
                    }
                }
                catch (Exception ex)
                {
                    Error(ex.ToString());
                }
                MessageBox.Show("Food Type with ID: " + comboBoxID.Text + " has been successfully deleted.", "Food Type Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            default:
                Error("Unkown Error");
                break;
            }
            this.Close();
        }
Exemple #11
0
        private void buttonItem_Click(object sender, EventArgs e)
        {
            SQLServerConnection.IF = this;
            switch (state)
            {
            case 0:
                if (comboBoxStallName.Text == "" || textBoxFoodName.Text == "" || comboBoxFoodType.Text == "" || textBoxPrice.Text == "")
                {
                    MessageBox.Show("Error: Empty items", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    try
                    {
                        SQLServerConnection.AddItem(Convert.ToInt32(textBoxStallID.Text), Convert.ToInt32(textBoxFoodTypeID.Text), textBoxFoodName.Text, textBoxFoodDescription.Text, Convert.ToDecimal(textBoxPrice.Text));
                    }
                    catch (Exception ex)
                    {
                        Error(ex.ToString());
                    }
                    MessageBox.Show("Item with name: " + textBoxFoodName.Text + " has been successfully added to the database.", "New Item Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case 1:
                try
                {
                    if (comboBoxFoodID.Text != "")
                    {
                        SQLServerConnection.UpdateItem(Convert.ToInt32(comboBoxFoodID.Text), Convert.ToInt32(textBoxStallID.Text), Convert.ToInt32(textBoxFoodTypeID.Text), textBoxFoodName.Text, textBoxFoodDescription.Text, Convert.ToDecimal(textBoxPrice.Text));
                    }
                    else
                    {
                        Error("No selected item to update");
                    }
                    MessageBox.Show("Item with ID: " + comboBoxFoodID.Text + " has been successfully updated.", "Item Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    Error(ex.ToString());
                }
                break;

            case 2:
                try
                {
                    if (comboBoxFoodID.Text != "")
                    {
                        SQLServerConnection.DeleteItem(Convert.ToInt32(comboBoxFoodID.Text));
                    }
                    else
                    {
                        Error("No selected item to update");
                    }
                }
                catch (Exception ex)
                {
                    Error(ex.ToString());
                }
                MessageBox.Show("Item with ID: " + comboBoxFoodID.Text + " has been successfully deleted.", "Item Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            default:
                Error("Unkown Error");
                break;
            }
            this.Close();
        }
Exemple #12
0
        private void ItemForm_Load(object sender, EventArgs e)
        {
            switch (state)
            {
            case 0:
                comboBoxStallName.Enabled      = true;
                textBoxFoodName.Enabled        = true;
                comboBoxFoodType.Enabled       = true;
                textBoxFoodDescription.Enabled = true;
                textBoxPrice.Enabled           = true;
                SL = SQLServerConnection.GetStallList();
                TL = SQLServerConnection.GetFoodTypeList();
                foreach (TypeList tempList in TL)
                {
                    comboBoxFoodType.Items.Add(tempList.FoodType);
                }
                foreach (StallList tempList in SL)
                {
                    comboBoxStallName.Items.Add(tempList.StallName);
                }
                buttonItem.Text = "Add Item";
                break;

            case 1:
                SL = SQLServerConnection.GetStallList();
                TL = SQLServerConnection.GetFoodTypeList();
                IL = SQLServerConnection.GetItemList();
                foreach (TypeList tempList in TL)
                {
                    comboBoxFoodType.Items.Add(tempList.FoodType);
                }
                foreach (StallList tempList in SL)
                {
                    comboBoxStallName.Items.Add(tempList.StallName);
                }
                foreach (ItemList tempList in IL)
                {
                    comboBoxFoodID.Items.Add(tempList.FoodID);
                }
                comboBoxFoodID.Enabled = true;
                buttonItem.Text        = "Update Item";
                break;

            case 2:
                SL = SQLServerConnection.GetStallList();
                TL = SQLServerConnection.GetFoodTypeList();
                IL = SQLServerConnection.GetItemList();
                foreach (TypeList tempList in TL)
                {
                    comboBoxFoodType.Items.Add(tempList.FoodType);
                }
                foreach (StallList tempList in SL)
                {
                    comboBoxStallName.Items.Add(tempList.StallName);
                }
                foreach (ItemList tempList in IL)
                {
                    comboBoxFoodID.Items.Add(tempList.FoodID);
                }
                comboBoxFoodID.Enabled = true;
                buttonItem.Text        = "Delete Item";
                break;

            default:
                Error("Unkown Error");
                break;
            }
        }
Exemple #13
0
        private void comboBoxFoodID_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (state)
            {
            case 1:
                comboBoxStallName.Enabled      = true;
                textBoxFoodName.Enabled        = true;
                comboBoxFoodType.Enabled       = true;
                textBoxFoodDescription.Enabled = true;
                textBoxPrice.Enabled           = true;
                textBoxStallID.Text            = IL[comboBoxFoodID.SelectedIndex].StallID.ToString();
                textBoxFoodTypeID.Text         = IL[comboBoxFoodID.SelectedIndex].FoodTypeID.ToString();
                SL.Clear();
                TL.Clear();
                SL = SQLServerConnection.GetStallList();
                TL = SQLServerConnection.GetFoodTypeList();
                int x = 0;
                foreach (StallList tempList in SL)
                {
                    if (tempList.StallID == Convert.ToInt32(textBoxStallID.Text))
                    {
                        comboBoxStallName.SelectedIndex = x;
                    }
                    x++;
                }
                textBoxFoodName.Text = IL[comboBoxFoodID.SelectedIndex].FoodName;
                x = 0;
                foreach (TypeList tempList in TL)
                {
                    if (tempList.FoodTypeID == Convert.ToInt32(textBoxFoodTypeID.Text))
                    {
                        comboBoxFoodType.SelectedIndex = x;
                    }
                    x++;
                }
                textBoxFoodDescription.Text = IL[comboBoxFoodID.SelectedIndex].FoodDescription;
                textBoxPrice.Text           = IL[comboBoxFoodID.SelectedIndex].FoodPrice.ToString("0.00");
                break;

            case 2:
                textBoxStallID.Text    = IL[comboBoxFoodID.SelectedIndex].StallID.ToString();
                textBoxFoodTypeID.Text = IL[comboBoxFoodID.SelectedIndex].FoodTypeID.ToString();
                SL.Clear();
                TL.Clear();
                SL = SQLServerConnection.GetStallList();
                TL = SQLServerConnection.GetFoodTypeList();
                int y = 0;
                foreach (StallList tempList in SL)
                {
                    if (tempList.StallID == Convert.ToInt32(textBoxStallID.Text))
                    {
                        comboBoxStallName.SelectedIndex = y;
                    }
                    y++;
                }
                textBoxFoodName.Text = IL[comboBoxFoodID.SelectedIndex].FoodName;
                y = 0;
                foreach (TypeList tempList in TL)
                {
                    if (tempList.FoodTypeID == Convert.ToInt32(textBoxFoodTypeID.Text))
                    {
                        comboBoxFoodType.SelectedIndex = y;
                    }
                    y++;
                }
                textBoxFoodDescription.Text = IL[comboBoxFoodID.SelectedIndex].FoodDescription;
                textBoxPrice.Text           = IL[comboBoxFoodID.SelectedIndex].FoodPrice.ToString("0.00");
                break;

            default:
                Error("Unkown Error");
                break;
            }
        }