Beispiel #1
0
        private void diagAddRecipe_Load(object sender, EventArgs e)
        {
            RecBL = new RecipeBL();
            RecBO = new RecipeBO();

            if (SelectedAction == "New")
            {
                getRecipeID();
            }
            else
            {
                backToolStripMenuItem.Text = "Close";
                RecBO.recipeid             = Convert.ToString(RecipeID);
                DataTable dt = RecBL.searchRecipeByID(RecBO);
                foreach (DataRow row in dt.Rows)
                {
                    oldStatus                = row.ItemArray[3].ToString();
                    textBox1.Text            = row.ItemArray[1].ToString();
                    origDesc                 = row.ItemArray[1].ToString();
                    comboBox1.Text           = row.ItemArray[2].ToString();
                    RecBO.recipeid           = row.ItemArray[0].ToString();
                    dataGridView1.DataSource = RecBL.getIngByRecID(RecBO);
                }
                RecBO.recipeid = Convert.ToString(RecipeID);
                origIng        = RecBL.getIngByRecIdOrig(RecBO);
            }
        }
Beispiel #2
0
        private void removeIngredientToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RecBO = new RecipeBO();
            RecBL = new RecipeBL();
            int counter = ingmeass.Count();
            int index   = 0;

            if (MessageBox.Show("Are you sure?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                int indicator = 0;
                RecBO.recipeid = Convert.ToString(RecipeID);
                RecBO.ingdesc  = ingdesc;
                RecBL.removeRecipeIng(RecBO);
                countremovedIng = countremovedIng + 1;
                foreach (DataRow row in RecBL.searchIngByID(RecBO).Rows)
                {
                    tempRemoveIng.Add(row.ItemArray[0].ToString());
                }
                RecBO.recipeid           = Convert.ToString(RecipeID);
                dataGridView1.DataSource = RecBL.getIngByRecID(RecBO);
                time = 0;
                notifier("Ingredient successfully remove to the dish!");
                lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                this.panel3.BackColor = System.Drawing.Color.DodgerBlue;
            }
        }
Beispiel #3
0
        private void textBox5_TextChanged(object sender, EventArgs e)
        {
            RecipeBL RecipeBL = new RecipeBL();
            RecipeBO RecipeBO = new RecipeBO();

            Cursor = Cursors.WaitCursor;
            try
            {
                if (textBox5.Text != "Search box")
                {
                    if (comboBox1.Text != "")
                    {
                        RecipeBO.recipe          = textBox5.Text.Trim();
                        RecipeBO.cat             = comboBox1.Text;
                        dataGridView1.DataSource = RecipeBL.searchRecipeTwoColumns(RecipeBO);
                    }
                    else
                    {
                        RecipeBO.recipe          = textBox5.Text.Trim();
                        RecipeBO.cat             = " ";
                        dataGridView1.DataSource = RecipeBL.searchRecipeTwoColumns(RecipeBO);
                    }
                }
            }
            catch (Exception)
            {
                Cursor = Cursors.Arrow;
                throw;
            }
            Cursor = Cursors.Arrow;
        }
Beispiel #4
0
 private void textBox6_TextChanged(object sender, EventArgs e)
 {
     RecipeBL = new RecipeBL();
     RecipeBO = new RecipeBO();
     Cursor   = Cursors.WaitCursor;
     try
     {
         if (textBox6.Text != "Search box")
         {
             if (radioButton1.Checked == true)
             {
                 RecipeBO.recipe          = textBox6.Text.Trim();
                 RecipeBO.cat             = cat;
                 dataGridView1.DataSource = RecipeBL.searchRecipe(RecipeBO);
             }
             else
             {
                 RecipeBO.recipe          = textBox6.Text.Trim();
                 RecipeBO.cat             = cat;
                 dataGridView1.DataSource = RecipeBL.searchRecipeUn(RecipeBO);
             }
         }
     }
     catch (Exception)
     {
         Cursor = Cursors.Arrow;
         throw;
     }
     Cursor = Cursors.Arrow;
 }
Beispiel #5
0
        private void getRecipeID()
        {
            IngBO = new IngredientBO();
            IngBL = new IngredientBL();
            RecBL = new RecipeBL();
            RecBO = new RecipeBO();

            foreach (DataRow row in RecBL.SearchRecipeCanBeUse().Rows)
            {
                RecipeID       = Convert.ToInt32(row[0].ToString());
                RecBO.status   = "1";
                RecBO.recipeid = Convert.ToString(RecipeID);
                RecBL.ChangeRecipeInuse(RecBO);
            }
            if (RecipeID == 1)
            {
                RecBL.addRecipeSlot(RecBO);
                foreach (DataRow row in RecBL.SearchRecipeCanBeUse().Rows)
                {
                    RecipeID = Convert.ToInt32(row[0].ToString());
                }
                RecBO.status   = "1";
                RecBO.recipeid = Convert.ToString(RecipeID);
                RecBL.ChangeRecipeInuse(RecBO);
            }
        }
Beispiel #6
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            recBO = new RecipeBO();
            recBL = new RecipeBL();
            IngredientBL IngBL = new IngredientBL();
            IngredientBO ingBO = new IngredientBO();

            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                RecipeID       = row.Cells[0].Value.ToString();
                Recipe         = row.Cells[1].Value.ToString();
                groupBox2.Text = Recipe;
            }
            recBO.recipeid = Convert.ToString(RecipeID);
            DataTable dt        = recBL.getIngByRecID(recBO);
            double    dishprice = 0;

            foreach (DataRow row in dt.Rows)
            {
                ingBO.ing = row[0].ToString();
                DataTable ings = IngBL.searchIngredientReturnPrice(ingBO);
                foreach (DataRow ing in ings.Rows)
                {
                    dishprice = dishprice + (getPrice(row[1].ToString(), "1") * Convert.ToDouble(ing[4].ToString()));
                }
            }
            dt.Rows.Add("TOTAL ", "P " + dishprice.ToString("F"));
            dataGridView2.DataSource = dt;
        }
Beispiel #7
0
 private void diagAddRecipe_FormClosing(object sender, FormClosingEventArgs e)
 {
     RecBO = new RecipeBO();
     RecBL = new RecipeBL();
     try
     {
         if (acceptbutton != true && cancelButton == false)
         {
             if (MessageBox.Show("Dish/Changes will not be saved." + Environment.NewLine + "Are you sure you want to cancel?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
             {
                 RecBO.status   = "0";
                 RecBO.recipeid = Convert.ToString(RecipeID);
                 RecBL.ChangeRecipeInuse(RecBO);
                 while (numOfAddedIng >= 0)
                 {
                     RecBO.recipeid = Convert.ToString(RecipeID);
                     RecBO.ingid    = newlyaddeding[numOfAddedIng];
                     RecBL.removeNewlyAddedIngToRecipe(RecBO);
                     numOfAddedIng     = numOfAddedIng - 1;
                     this.DialogResult = DialogResult.Cancel;
                 }
                 if (SelectedAction == "Update")
                 {
                     RecBO.status   = oldStatus;
                     RecBO.recipeid = Convert.ToString(RecipeID);
                     RecBL.ChangeRecipeInuse(RecBO);
                     RecBO.recipeid = Convert.ToString(RecipeID);
                     RecBL.deleteAllRecIng(RecBO);
                     RecBO.recipeid = Convert.ToString(RecipeID);
                     foreach (DataRow row in origIng.Rows)
                     {
                         RecBO.recipeid = row.ItemArray[0].ToString();
                         RecBO.ingid    = row.ItemArray[1].ToString();
                         RecBO.meas     = row.ItemArray[2].ToString();
                         RecBL.addRecipeIng(RecBO);
                         this.DialogResult = DialogResult.Cancel;
                     }
                 }
             }
             else
             {
                 e.Cancel = true;
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #8
0
        public DataTable GetIngredientsListWithCost()
        {
            DataTable ingredients = new DataTable();

            ingredients.Columns.Add("1", typeof(String));
            ingredients.Columns.Add("2");
            ingredients.Columns.Add("3");
            ingredients.Columns.Add("4");
            ingredients.Columns.Add("5");
            ingredients.Columns.Add("6");
            ingredients.PrimaryKey = new DataColumn[] { ingredients.Columns["1"] };

            RecipeBL recipeBL = new RecipeBL();
            RecipeBO recipeBO = new RecipeBO();

            CateringBL CatBL = new CateringBL();
            CateringBO CatBO = new CateringBO();

            recipeBO.recipeid = this.RecipeID;
            var dishesrecipe = recipeBL.getRecipeNameAndFormulaAndPriceByDish(recipeBO);

            foreach (DataRow ing in dishesrecipe.Rows)
            {
                string  paxx        = this.Pax.ToString();
                string  ins         = ing[0].ToString();
                decimal actualPrice = getPrice(ing.ItemArray[1].ToString(), paxx);
                if (this.TypeOfService == "Plated" && this.Category == "Main dish")
                {
                    actualPrice = actualPrice * Properties.Settings.Default.Plated;
                }
                //decimal b = getPrice(ing.ItemArray[1].ToString(), paxx);
                if (ingredients.Rows.Contains(ins))
                {
                    for (int i = 0; i < ingredients.Rows.Count; i++)
                    {
                        string temp = ingredients.Rows[i][0].ToString();
                        if (ins == temp)
                        {
                            ingredients.Rows[i][2] = (Convert.ToDecimal(ingredients.Rows[i][2].ToString()) + Convert.ToDecimal(actualPrice));
                            i = ingredients.Rows.Count;
                        }
                    }
                }
                else
                {
                    ingredients.Rows.Add(ing[0].ToString(), ing[2].ToString(), actualPrice);
                }
            }
            return(ingredients);
        }
Beispiel #9
0
 private void frmRecipes_Load(object sender, EventArgs e)
 {
     RecipeBL = new Catering_Menu.RecipeBL();
     RecipeBO = new Catering_Menu.RecipeBO();
     cat      = "Appetizer";
     try
     {
         RecipeBO.recipe          = "";
         RecipeBO.cat             = cat;
         dataGridView1.DataSource = RecipeBL.searchRecipe(RecipeBO);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #10
0
 private void toolStripMenuItem3_Click(object sender, EventArgs e)
 {
     recBO = new RecipeBO();
     recBL = new RecipeBL();
     try
     {
         if (RecipeID != "" && RecipeID != null)
         {
             recBO.recipeid = RecipeID;
             recBO.recipe   = "";
             recBO.cat      = cat;
             if (status == "AVAILABLE")
             {
                 recBL.makeRecipeUnavail(recBO);
                 radioButton1.Checked = !radioButton1.Checked;
             }
             else
             {
                 recBL.makeRecipeAvail(recBO);
                 radioButton1.Checked = !radioButton1.Checked;
             }
             time     = 0;
             RecipeID = "";
             notifier("Dish successfully status changed.");
             lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
             this.panel3.BackColor = System.Drawing.Color.DodgerBlue;
             RecipeBO.recipe       = "";
             RecipeBO.cat          = cat;
         }
         else
         {
             time = 0;
             notifier("Please select a dish.");
             lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
             this.panel3.BackColor = System.Drawing.Color.Tomato;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #11
0
        private void dataGridView2_DoubleClick(object sender, EventArgs e)
        {
            RecBL = new RecipeBL();
            RecBO = new RecipeBO();
            foreach (DataGridViewRow row in dataGridView2.SelectedRows)
            {
                selectedIng = row.Cells[0].Value.ToString();
            }
            RecBO.recipeid = Convert.ToString(RecipeID);
            RecBO.ingid    = selectedIng;
            DataTable dt = RecBL.checkRecipeIng(RecBO);

            if (dt.Rows.Count == 0)
            {
                diagRecipeMeas diagMeas = new diagRecipeMeas(selectedIng);
                if (diagMeas.ShowDialog() == DialogResult.OK)
                {
                    newlyaddeding[numOfAddedIng] = selectedIng;
                    numOfAddedIng  = numOfAddedIng + 1;
                    RecBO.recipeid = Convert.ToString(RecipeID);
                    RecBO.ingid    = selectedIng;
                    RecBO.meas     = diagMeas.meas;
                    RecBL.addRecipeIng(RecBO);
                    RecBO.recipeid           = Convert.ToString(RecipeID);
                    dataGridView1.DataSource = RecBL.getIngByRecID(RecBO);
                    time = 0;
                    notifier("Ingredient Successfully added!");
                    lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                    this.panel3.BackColor = System.Drawing.Color.DodgerBlue;
                }
            }
            else
            {
                time = 0;
                notifier("Ingredient is already included!");
                lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                this.panel3.BackColor = System.Drawing.Color.Tomato;
            }
        }
Beispiel #12
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     RecipeBL = new RecipeBL();
     RecipeBO = new RecipeBO();
     try
     {
         if (textBox5.Text != "Search box")
         {
             RecipeBO.recipe = textBox5.Text.Trim();
         }
         else
         {
             RecipeBO.recipe = "";
         }
         RecipeBO.cat             = comboBox1.Text;
         dataGridView1.DataSource = RecipeBL.searchRecipeTwoColumns(RecipeBO);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #13
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            recBO = new RecipeBO();
            recBL = new RecipeBL();
            diagAddRecipe diagAdd = new diagAddRecipe("Update", RecipeID);

            if (diagAdd.ShowDialog() == DialogResult.OK)
            {
                time = 0;
                notifier("Dish successfully updated.");
                lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                this.panel3.BackColor = System.Drawing.Color.DodgerBlue;
                try
                {
                    RecipeBO.recipe          = diagAdd.recipename;
                    RecipeBO.cat             = cat;
                    dataGridView1.DataSource = RecipeBL.searchRecipe(RecipeBO);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Beispiel #14
0
        private void Button5_Click(object sender, EventArgs e)
        {
            SupplierBL BL = new SupplierBL();
            SupplierBO BO = new SupplierBO();

            RecBO = new RecipeBO();
            RecBL = new RecipeBL();
            IngBO = new IngredientBO();
            IngBL = new IngredientBL();
            catBO = new CateringBO();
            catBL = new CateringBL();
            DataTable eventdetail;
            DataTable eventDishes;
            DataTable dishesrecipe;
            DataTable Others = new DataTable();

            Others.Columns.Add("1");
            Others.Columns.Add("2");
            Others.Columns.Add("3");
            Others.Columns.Add("4");
            Others.Columns.Add("5");
            Others.Columns.Add("6");
            DataTable ingredients = new DataTable();

            ingredients.Columns.Add("1", typeof(String));
            ingredients.Columns.Add("2");
            ingredients.Columns.Add("3");
            ingredients.Columns.Add("4");
            ingredients.Columns.Add("5");
            ingredients.Columns.Add("6");
            ingredients.PrimaryKey = new DataColumn[] { ingredients.Columns["1"] };
            DataTable popoy = new DataTable();

            popoy.Columns.Add("name", typeof(String));
            popoy.Columns.Add("2");
            popoy.Columns.Add("3");
            popoy.Columns.Add("4");
            popoy.Columns.Add("5");
            popoy.Columns.Add("6");
            popoy.Columns.Add("7");
            DataTable cdad = new DataTable();

            cdad.Columns.Add("name", typeof(String));
            cdad.Columns.Add("2");
            cdad.Columns.Add("3");
            cdad.Columns.Add("4");
            cdad.Columns.Add("5");
            cdad.Columns.Add("6");
            cdad.Columns.Add("7");
            DataTable supps = new DataTable();

            supps.Columns.Add("name", typeof(String));
            supps.Columns.Add("2");
            supps.Columns.Add("3");
            supps.Columns.Add("4");
            supps.Columns.Add("5");
            supps.Columns.Add("6");
            supps.Columns.Add("7");
            List <string> Categories = new List <string>();
            DataTable     Excel      = new DataTable();

            Excel.Columns.Add("1");
            Excel.Columns.Add("2");
            Excel.Columns.Add("3");
            Excel.Columns.Add("4");
            Excel.Columns.Add("5");
            Excel.Columns.Add("6");
            Excel.Columns.Add("7");
            Excel.Columns.Add("8");
            string         pax             = "";
            int            categoryshower  = 0;
            int            categoryshowerO = 0;
            string         lastCat         = "";
            string         lastCatOther    = "";
            List <double>  popoyP          = new List <double>();
            List <double>  cdadP           = new List <double>();
            List <double>  suppP           = new List <double>();
            List <double>  popoyPO         = new List <double>();
            List <double>  cdadPO          = new List <double>();
            List <decimal> Total           = new List <decimal>();
            DataTable      suppliers       = new DataTable();

            suppliers.Columns.Add("Supp");
            string typeofservice = "";
            string category      = "";
            double popoyFP       = 0;
            double cdadFP        = 0;
            double suppFP        = 0;
            string guestType     = "";

            foreach (DataRow supp in BL.getSupplier().Rows)
            {
                suppliers.Rows.Add(supp.ItemArray[0].ToString());
            }
            if (selectedDishes.Count() > 0)
            {
                Excel.Rows.Add("P.O Of Ingredients", "", "", "", "");
                Excel.Rows.Add("", "", "", "", "");
                Excel.Rows.Add("Ingredient", "Quantity", " Budget");
                int rowcounter = 0;
                //categorysorter = Categories.Count();
                string recid = "";
                foreach (Dish dish in selectedDishes)
                {
                    ingredients.Merge(dish.GetIngredientsListWithCost());
                }
                decimal OverAll = 0;
                Excel.Rows.Add("", "", "", "", "", "");
                categoryshower = 0;
                counter        = counter + 1;
                DataView ingredientSorted = new DataView(ingredients);
                ingredientSorted.Sort = "[1] ASC";
                foreach (DataRow supplier in suppliers.Rows)
                {
                    Excel.Rows.Add(supplier.ItemArray[0].ToString().ToUpper(), "", "");
                    foreach (DataRowView ingredient in ingredientSorted)
                    {
                        IngBO.ing = ingredient[0].ToString();
                        DataTable dt         = IngBL.searchIngredientReturnPrice(IngBO);
                        string    suppliedby = ingredient[1].ToString();
                        if (supplier.ItemArray[0].ToString() == suppliedby)
                        {
                            foreach (DataRow price in dt.Rows)
                            {
                                Total.Add(Convert.ToDecimal(ingredient[2].ToString()) * Convert.ToDecimal(price.ItemArray[4].ToString()));
                                Excel.Rows.Add(" " + ingredient[0].ToString(), ingredient[2].ToString() + " " + price.ItemArray[2].ToString(), "P " + (Convert.ToDecimal(ingredient[2].ToString()) * Convert.ToDecimal(price.ItemArray[4].ToString())).ToString("0.##"));
                            }
                        }
                    }
                    Excel.Rows.Add("", "", "");
                    Excel.Rows.Add("Budget for " + supplier.ItemArray[0].ToString(), "", "P " + (Total.Sum()).ToString("0.##"));
                    Excel.Rows.Add("", "", "");
                    Excel.Rows.Add("", "", "");
                    OverAll = OverAll + Total.Sum();
                    Total.Clear();
                }
                Excel.Rows.Add("", "Grand Total", "P " + OverAll.ToString("0.##"));
                diagReport menu = new diagReport(Excel, "PO");
                menu.Show();
            }
            else
            {
                time = 0;
                notifier("Please select Dish");
                lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                this.panel3.BackColor = System.Drawing.Color.Tomato;
            }
        }
        private void generateReportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SupplierBL BL = new SupplierBL();
            SupplierBO BO = new SupplierBO();

            RecBO = new RecipeBO();
            RecBL = new RecipeBL();
            IngBO = new IngredientBO();
            IngBL = new IngredientBL();
            CatBO = new CateringBO();
            CatBL = new CateringBL();
            if (reportType == "PO")
            {
                DataTable eventdetail;
                DataTable eventDishes;
                DataTable dishesrecipe;
                DataTable Others = new DataTable();
                Others.Columns.Add("1");
                Others.Columns.Add("2");
                Others.Columns.Add("3");
                Others.Columns.Add("4");
                Others.Columns.Add("5");
                Others.Columns.Add("6");
                DataTable ingredients = new DataTable();
                ingredients.Columns.Add("1", typeof(String));
                ingredients.Columns.Add("2");
                ingredients.Columns.Add("3");
                ingredients.Columns.Add("4");
                ingredients.Columns.Add("5");
                ingredients.Columns.Add("6");
                ingredients.PrimaryKey = new DataColumn[] { ingredients.Columns["1"] };
                DataTable popoy = new DataTable();
                popoy.Columns.Add("name", typeof(String));
                popoy.Columns.Add("2");
                popoy.Columns.Add("3");
                popoy.Columns.Add("4");
                popoy.Columns.Add("5");
                popoy.Columns.Add("6");
                popoy.Columns.Add("7");
                DataTable cdad = new DataTable();
                cdad.Columns.Add("name", typeof(String));
                cdad.Columns.Add("2");
                cdad.Columns.Add("3");
                cdad.Columns.Add("4");
                cdad.Columns.Add("5");
                cdad.Columns.Add("6");
                cdad.Columns.Add("7");
                DataTable supps = new DataTable();
                supps.Columns.Add("name", typeof(String));
                supps.Columns.Add("2");
                supps.Columns.Add("3");
                supps.Columns.Add("4");
                supps.Columns.Add("5");
                supps.Columns.Add("6");
                supps.Columns.Add("7");
                List <string> Categories = new List <string>();
                DataTable     Excel      = new DataTable();
                Excel.Columns.Add("1");
                Excel.Columns.Add("2");
                Excel.Columns.Add("3");
                Excel.Columns.Add("4");
                Excel.Columns.Add("5");
                Excel.Columns.Add("6");
                Excel.Columns.Add("7");
                Excel.Columns.Add("8");
                string         pax             = "";
                int            categoryshower  = 0;
                int            categoryshowerO = 0;
                string         lastCat         = "";
                string         lastCatOther    = "";
                List <double>  popoyP          = new List <double>();
                List <double>  cdadP           = new List <double>();
                List <double>  suppP           = new List <double>();
                List <double>  popoyPO         = new List <double>();
                List <double>  cdadPO          = new List <double>();
                List <double>  suppPO          = new List <double>();
                List <decimal> Total           = new List <decimal>();
                List <string>  nameEvents      = new List <string>();
                string         typeofservice   = "";
                string         category        = "";
                int            eventcount      = 0;
                double         popoyFP         = 0;
                double         cdadFP          = 0;
                double         suppFP          = 0;
                string         guestType       = "";
                int            indicator       = 0;
                decimal        OverAll         = 0;
                int            categorysorter  = 0;
                int            counter         = 0;
                eventcount = passedDt.Rows.Count;
                int       foreachcutter = 0;
                string    sampleevent   = "";
                int       showfirst     = 1;
                DataTable suppliers     = new DataTable();
                suppliers.Columns.Add("Supp");
                foreach (DataRow supp in BL.getSupplier().Rows)
                {
                    suppliers.Rows.Add(supp.ItemArray[0].ToString());
                }
                foreach (DataRow events in passedDt.Rows)
                {
                    nameEvents.Add(events.ItemArray[1].ToString());
                }
                foreach (DataRow passed in passedDt.Rows)
                {
                    #region oldcode

                    #endregion
                    sampleevent = passed.ItemArray[1].ToString();
                    if (selectedcatID != "")
                    {
                        CatBO.catID = passed.ItemArray[0].ToString();
                        foreach (DataRow item in CatBL.getCategoryOfRecipes(CatBO).Rows)
                        {
                            Categories.Add(item.ItemArray[0].ToString());
                        }
                        eventdetail = CatBL.getCatDetail(CatBO);
                        foreach (DataRow row in eventdetail.Rows)
                        {
                            vip              = vip + Convert.ToInt32(row.ItemArray[3].ToString());
                            guest            = guest + Convert.ToInt32(row.ItemArray[4].ToString());
                            kids             = kids + Convert.ToInt32(row.ItemArray[5].ToString());
                            crew             = crew + Convert.ToInt32(row.ItemArray[6].ToString());
                            Other            = Other + Convert.ToInt32(row.ItemArray[7].ToString());
                            typeofservice    = row.ItemArray[12].ToString();
                            contractfilename = row.ItemArray[1].ToString();
                            if (showfirst == eventcount)
                            {
                                Excel.Rows.Add("P.O Of Ingredients", "", "", "", "");
                                Excel.Rows.Add("", "", "");
                                Excel.Rows.Add("No. Of event selected : " + eventcount, "", "", "", "", "", "", "");
                                Excel.Rows.Add("List of event selected : ", "", "", "", "", "", "", "");
                                foreach (string eventnames in nameEvents)
                                {
                                    Excel.Rows.Add("  " + eventnames, "(" + row.ItemArray[9].ToString() + ")", "", "", "", "", "", "");
                                }
                                Excel.Rows.Add("", "", "", "", "");
                                Excel.Rows.Add(guest + " Guest, " + vip + " Vip, " + kids + " Kids", "", "", "", "", "");
                                Excel.Rows.Add(crew + " Crew, " + Other + " Other", "", "", "", "", "");
                                Excel.Rows.Add("", "", "", "", "");
                                Excel.Rows.Add("Ingredient", "Quantity", " Budget");
                            }
                            showfirst++;
                        }
                        int rowcounter = 0;
                        categorysorter = Categories.Count();
                        string recid = "";
                        while (counter < categorysorter)
                        {
                            CatBO.catID    = passed.ItemArray[0].ToString();
                            CatBO.category = Categories[counter];
                            eventDishes    = CatBL.getCateringDish(CatBO);
                            foreach (DataRow row in eventDishes.Rows)
                            {
                                category     = row.ItemArray[2].ToString();
                                guestType    = row.ItemArray[0].ToString();
                                RecBO.recipe = row.ItemArray[1].ToString();
                                foreach (DataRow rec in RecBL.searchRecipeByName(RecBO).Rows)
                                {
                                    recid = rec.ItemArray[0].ToString();
                                }
                                CatBO.recipeid = recid;
                                CatBO.guest    = row.ItemArray[0].ToString();
                                dishesrecipe   = CatBL.getRecipeNameAndFormulaAndPrice(CatBO);
                                foreach (DataRow ing in dishesrecipe.Rows)
                                {
                                    string paxx = row.ItemArray[3].ToString();
                                    rowcounter++;
                                    string  ins = ing[0].ToString();
                                    decimal b   = getPrice(ing.ItemArray[1].ToString(), paxx);
                                    if (typeofservice == "Plated" && category == "Main dish")
                                    {
                                        b = b * Properties.Settings.Default.Plated;
                                    }
                                    //decimal b = getPrice(ing.ItemArray[1].ToString(), paxx);
                                    if (ingredients.Rows.Contains(ins))
                                    {
                                        for (int i = 0; i < ingredients.Rows.Count; i++)
                                        {
                                            string temp = ingredients.Rows[i][0].ToString();
                                            if (ins == temp)
                                            {
                                                ingredients.Rows[i][2] = Convert.ToDecimal(ingredients.Rows[i][2].ToString()) + b;
                                                i = ingredients.Rows.Count;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ingredients.Rows.Add(ing[0].ToString(), ing[2].ToString(), b);
                                    }
                                }
                            }
                            categoryshower = categoryshower + 1;
                            counter        = counter + 1;
                            indicator      = indicator + 1;
                        }
                    }
                }
                if (indicator != 0)
                {
                    Excel.Rows.Add("", "", "", "", "", "");
                    categoryshower = 0;
                    counter        = counter + 1;
                    DataView ingredientSorted = new DataView(ingredients);
                    ingredientSorted.Sort = "[1] ASC";
                    foreach (DataRow supplier in suppliers.Rows)
                    {
                        Excel.Rows.Add(supplier.ItemArray[0].ToString().ToUpper(), "", "");
                        foreach (DataRowView ingredient in ingredientSorted)
                        {
                            IngBO.ing = ingredient[0].ToString();
                            DataTable dt         = IngBL.searchIngredientReturnPrice(IngBO);
                            string    suppliedby = ingredient[1].ToString();
                            if (supplier.ItemArray[0].ToString() == suppliedby)
                            {
                                foreach (DataRow price in dt.Rows)
                                {
                                    Total.Add(Convert.ToDecimal(ingredient[2].ToString()) * Convert.ToDecimal(price.ItemArray[4].ToString()));
                                    Excel.Rows.Add(" " + ingredient[0].ToString(), ingredient[2].ToString() + " " + price.ItemArray[2].ToString(), "P " + (Convert.ToDecimal(ingredient[2].ToString()) * Convert.ToDecimal(price.ItemArray[4].ToString())).ToString("0.##"));
                                }
                            }
                        }
                        Excel.Rows.Add("", "", "");
                        Excel.Rows.Add("Budget for " + supplier.ItemArray[0].ToString(), "", "P " + (Total.Sum()).ToString("0.##"));
                        Excel.Rows.Add("", "", "");
                        Excel.Rows.Add("", "", "");
                        OverAll = OverAll + Total.Sum();
                        Total.Clear();
                    }
                    vip       = 0;
                    guest     = 0;
                    kids      = 0;
                    crew      = 0;
                    Other     = 0;
                    indicator = 0;
                    Excel.Rows.Add("", "Grand Total", "P " + OverAll.ToString("0.##"));
                    diagReport menu = new diagReport(Excel, "PO");
                    menu.Show();
                }
                else
                {
                    MessageBox.Show("Select a event first!");
                }
            }
            else if (reportType == "Summary")
            {
                DataTable     dt        = new DataTable();
                DataTable     amounts   = new DataTable();
                DataTable     suppliers = BL.getSupplier();
                List <string> supps     = new List <string>();
                dt.Columns.Add("1");
                dt.Columns.Add("2");
                dt.Columns.Add("3");
                dt.Columns.Add("4");
                dt.Columns.Add("5");
                dt.Columns.Add("6");
                dt.Columns.Add("7");
                dt.Columns.Add("8");
                dt.Columns.Add("9");
                dt.Columns.Add("10");
                dt.Columns.Add("11");
                dt.Columns.Add("12");
                dt.Columns.Add("13");
                dt.Columns.Add("14");
                dt.Columns.Add("15");
                dt.Columns.Add("16");
                dt.Columns.Add("17");
                dt.Columns.Add("18");
                dt.Columns.Add("19");
                dt.Columns.Add("20");
                dt.Columns.Add("21");
                dt.Columns.Add("22");
                List <decimal> totalExp = new List <decimal>();
                var            tExp     = new Dictionary <string, decimal>();
                int            count    = 0;
                for (int i = 0; i < 20; i++)
                {
                    supps.Add("");
                    totalExp.Add(0);
                }
                CatBL = new CateringBL();
                CatBO = new CateringBO();
                decimal exp         = 0;
                string  collectedid = "";
                int     countif1    = 0;
                foreach (DataRow eventids in passedDt.Rows)
                {
                    if (countif1 == 0)
                    {
                        collectedid = eventids.ItemArray[0].ToString();
                        countif1++;
                    }
                    else
                    {
                        collectedid = collectedid + "," + eventids.ItemArray[0].ToString();
                    }
                }
                CatBO.catID = collectedid;
                DataTable disec         = CatBL.showReportByEvent(CatBO);
                string    showonce      = "";
                int       numberofevent = disec.Rows.Count;
                foreach (DataRow nameOfSupplier in suppliers.Rows)
                {
                    tExp.Add(nameOfSupplier.ItemArray[0].ToString(), 0);
                    supps[count] = (nameOfSupplier.ItemArray[0].ToString());
                    count++;
                }
                count = 0;
                int diff      = supps.Count - tExp.Count;
                int supptigil = tExp.Count;
                for (int i = 0; i < diff; i++)
                {
                    tExp.Add("Vacant" + (i + 1), 0);
                    supps[supptigil] = ("Vacant" + (i + 1));
                    supptigil++;
                }
                dt.Rows.Add("", supps[0], supps[1], supps[2], supps[3], supps[4], supps[5], supps[6], supps[7], supps[8], supps[9], supps[10], supps[11], supps[12], supps[13], supps[14], supps[15], supps[16], supps[17], supps[18], supps[19], "Total Expense");
                foreach (DataRow eventdetail in disec.Rows)
                {
                    dt.Rows.Add(eventdetail.ItemArray[5].ToString());
                    if (showonce == eventdetail.ItemArray[5].ToString() && dt.Rows.Count != 0)
                    {
                        dt.Rows.RemoveAt(dt.Rows.Count - 1);
                    }
                    showonce = eventdetail.ItemArray[5].ToString();
                    catid    = eventdetail.ItemArray[8].ToString();
                    BO.catid = catid;
                    amounts  = BL.getSupplierBudget(BO);
                    foreach (DataRow amount in amounts.Rows)
                    {
                        totalExp[count] = (Convert.ToDecimal(amount.ItemArray[2].ToString()));
                        tExp[amount.ItemArray[1].ToString()] = (Convert.ToDecimal(amount.ItemArray[2].ToString()));
                        count++;
                    }

                    dt.Rows.Add(eventdetail.ItemArray[2].ToString() + " (" + eventdetail.ItemArray[3].ToString() + ")(" + eventdetail.ItemArray[6].ToString() + ")(" + eventdetail.ItemArray[7].ToString() + ")", "P " + tExp[supps[0]], "P " + tExp[supps[1]], "P " + tExp[supps[2]], "P " + tExp[supps[3]], "P " + tExp[supps[4]], "P " + tExp[supps[5]], "P " + tExp[supps[6]], "P " + tExp[supps[7]], "P " + tExp[supps[8]], "P " + tExp[supps[9]], "P " + tExp[supps[10]], "P " + tExp[supps[11]], "P " + tExp[supps[12]], "P " + tExp[supps[13]], "P " + tExp[supps[14]], "P " + tExp[supps[15]], "P " + tExp[supps[16]], "P " + tExp[supps[17]], "P " + tExp[supps[18]], "P " + tExp[supps[19]], "P " + totalExp.Sum().ToString("0.##"));
                    exp = exp + totalExp.Sum();
                    totalExp.Clear();
                    for (int i = 0; i < 20; i++)
                    {
                        totalExp.Add(0);
                        supps.Add("");
                    }
                    count = 0;
                }
                dt.Rows.Add("Number of Events : " + numberofevent, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Total Expense: ", "P " + exp);
                OverallReport cr   = new OverallReport();
                diagReport    diag = new diagReport(dt, "OverallReport");
                diag.Show();
            }
        }
Beispiel #16
0
        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {
            SupplierBL BL = new SupplierBL();
            SupplierBO BO = new SupplierBO();

            RecBO = new RecipeBO();
            RecBL = new RecipeBL();
            IngBO = new IngredientBO();
            IngBL = new IngredientBL();
            CatBO = new CateringBO();
            CatBL = new CateringBL();
            DataTable eventdetail;
            DataTable eventDishes;
            DataTable dishesrecipe;
            DataTable Others = new DataTable();

            Others.Columns.Add("1");
            Others.Columns.Add("2");
            Others.Columns.Add("3");
            Others.Columns.Add("4");
            Others.Columns.Add("5");
            Others.Columns.Add("6");
            DataTable ingredients = new DataTable();

            ingredients.Columns.Add("1", typeof(String));
            ingredients.Columns.Add("2");
            ingredients.Columns.Add("3");
            ingredients.Columns.Add("4");
            ingredients.Columns.Add("5");
            ingredients.Columns.Add("6");
            ingredients.PrimaryKey = new DataColumn[] { ingredients.Columns["1"] };
            DataTable popoy = new DataTable();

            popoy.Columns.Add("name", typeof(String));
            popoy.Columns.Add("2");
            popoy.Columns.Add("3");
            popoy.Columns.Add("4");
            popoy.Columns.Add("5");
            popoy.Columns.Add("6");
            popoy.Columns.Add("7");
            DataTable cdad = new DataTable();

            cdad.Columns.Add("name", typeof(String));
            cdad.Columns.Add("2");
            cdad.Columns.Add("3");
            cdad.Columns.Add("4");
            cdad.Columns.Add("5");
            cdad.Columns.Add("6");
            cdad.Columns.Add("7");
            DataTable supps = new DataTable();

            supps.Columns.Add("name", typeof(String));
            supps.Columns.Add("2");
            supps.Columns.Add("3");
            supps.Columns.Add("4");
            supps.Columns.Add("5");
            supps.Columns.Add("6");
            supps.Columns.Add("7");
            List <string> Categories = new List <string>();
            DataTable     Excel      = new DataTable();

            Excel.Columns.Add("1");
            Excel.Columns.Add("2");
            Excel.Columns.Add("3");
            Excel.Columns.Add("4");
            Excel.Columns.Add("5");
            Excel.Columns.Add("6");
            Excel.Columns.Add("7");
            Excel.Columns.Add("8");
            string         pax             = "";
            int            categoryshower  = 0;
            int            categoryshowerO = 0;
            string         lastCat         = "";
            string         lastCatOther    = "";
            List <double>  popoyP          = new List <double>();
            List <double>  cdadP           = new List <double>();
            List <double>  suppP           = new List <double>();
            List <double>  popoyPO         = new List <double>();
            List <double>  cdadPO          = new List <double>();
            List <double>  suppPO          = new List <double>();
            List <decimal> Total           = new List <decimal>();
            List <string>  nameEvents      = new List <string>();
            string         typeofservice   = "";
            string         category        = "";
            int            eventcount      = 0;
            double         popoyFP         = 0;
            double         cdadFP          = 0;
            double         suppFP          = 0;
            string         guestType       = "";
            int            indicator       = 0;
            decimal        OverAll         = 0;
            int            categorysorter  = 0;
            int            counter         = 0;
            int            foreachcutter   = 0;
            string         sampleevent     = "";
            int            showfirst       = 0;
            DataTable      suppliers       = new DataTable();

            suppliers.Columns.Add("Supp");
            foreach (DataRow supp in BL.getSupplier().Rows)
            {
                suppliers.Rows.Add(supp.ItemArray[0].ToString());
            }
            CatBO.dateF = dateTimePicker1.Value.ToString("yyyy-MM-dd");
            CatBO.dateT = dateTimePicker2.Value.ToString("yyyy-MM-dd");
            if (comboBox1.Text == "Future event")
            {
                CatBO.Status = "ACTIVE";
            }
            else if (comboBox1.Text == "Past event")
            {
                CatBO.Status = "DONE";
            }
            else
            {
                CatBO.Status = "";
            }
            DataTable eventsdetails = CatBL.getCatDetailByPeriod(CatBO);

            eventcount = eventsdetails.Rows.Count;
            foreach (DataRow events in eventsdetails.Rows)
            {
                nameEvents.Add(events.ItemArray[1].ToString());
            }
            foreach (DataRow passed in eventsdetails.Rows)
            {
                sampleevent = passed.ItemArray[1].ToString();
                CatBO.catID = passed.ItemArray[0].ToString();
                foreach (DataRow item in CatBL.getCategoryOfRecipes(CatBO).Rows)
                {
                    Categories.Add(item.ItemArray[0].ToString());
                }
                eventdetail = CatBL.getCatDetailByPeriod(CatBO);
                eventcount  = eventdetail.Rows.Count;
                foreach (DataRow row in eventdetail.Rows)
                {
                    vip              = vip + Convert.ToInt32(row.ItemArray[3].ToString());
                    guest            = guest + Convert.ToInt32(row.ItemArray[4].ToString());
                    kids             = kids + Convert.ToInt32(row.ItemArray[5].ToString());
                    crew             = crew + Convert.ToInt32(row.ItemArray[6].ToString());
                    Other            = Other + Convert.ToInt32(row.ItemArray[7].ToString());
                    typeofservice    = row.ItemArray[12].ToString();
                    contractfilename = row.ItemArray[1].ToString();
                    date             = row.ItemArray[9].ToString();
                    showfirst++;
                }
                if (showfirst == eventcount)
                {
                    Excel.Rows.Add("P.O Of Ingredients", "", "", "", "");
                    Excel.Rows.Add("", "", "");
                    Excel.Rows.Add("From: " + dateTimePicker1.Value.ToString("MM-dd-yyyy"), "", "");
                    Excel.Rows.Add("To: " + dateTimePicker2.Value.ToString("MM-dd-yyyy"), "", "");
                    Excel.Rows.Add("", "", "");
                    Excel.Rows.Add("No. Of event selected : " + nameEvents.Count(), "", "", "", "", "", "", "");
                    Excel.Rows.Add("List of event selected : ", "", "", "", "", "", "", "");
                    foreach (string eventnames in nameEvents)
                    {
                        Excel.Rows.Add("  " + eventnames, date, "", "", "", "", "", "");
                    }
                    Excel.Rows.Add("", "", "", "", "");
                    Excel.Rows.Add(guest + " Guest, " + vip + " Vip, " + kids + " Kids", "", "", "", "", "");
                    Excel.Rows.Add(crew + " Crew, " + Other + " Other", "", "", "", "", "");
                    Excel.Rows.Add("", "", "", "", "");
                    Excel.Rows.Add("Ingredient", "Quantity", " Budget");
                }
                int rowcounter = 0;
                categorysorter = Categories.Count();
                string recid = "";
                while (counter < categorysorter)
                {
                    CatBO.catID    = passed.ItemArray[0].ToString();
                    CatBO.category = Categories[counter];
                    eventDishes    = CatBL.getCateringDish(CatBO);
                    foreach (DataRow row in eventDishes.Rows)
                    {
                        category     = row.ItemArray[2].ToString();
                        guestType    = row.ItemArray[0].ToString();
                        RecBO.recipe = row.ItemArray[1].ToString();
                        foreach (DataRow rec in RecBL.searchRecipeByName(RecBO).Rows)
                        {
                            recid = rec.ItemArray[0].ToString();
                        }
                        CatBO.recipeid = recid;
                        CatBO.guest    = row.ItemArray[0].ToString();
                        dishesrecipe   = CatBL.getRecipeNameAndFormulaAndPrice(CatBO);
                        foreach (DataRow ing in dishesrecipe.Rows)
                        {
                            string paxx = row.ItemArray[3].ToString();
                            rowcounter++;
                            string  ins = ing[0].ToString();
                            decimal b   = getPrice(ing.ItemArray[1].ToString(), paxx);
                            if (typeofservice == "Plated" && category == "Main dish")
                            {
                                b = b * Properties.Settings.Default.Plated;
                            }
                            //decimal b = getPrice(ing.ItemArray[1].ToString(), paxx);
                            if (ingredients.Rows.Contains(ins))
                            {
                                for (int i = 0; i < ingredients.Rows.Count; i++)
                                {
                                    string temp = ingredients.Rows[i][0].ToString();
                                    if (ins == temp)
                                    {
                                        ingredients.Rows[i][2] = Convert.ToDecimal(ingredients.Rows[i][2].ToString()) + b;
                                        i = ingredients.Rows.Count;
                                    }
                                }
                            }
                            else
                            {
                                ingredients.Rows.Add(ing[0].ToString(), ing[2].ToString(), b);
                            }
                        }
                    }
                    categoryshower = categoryshower + 1;
                    counter        = counter + 1;
                    indicator      = indicator + 1;
                }
            }
            if (indicator != 0)
            {
                Excel.Rows.Add("", "", "", "", "", "");
                categoryshower = 0;
                counter        = counter + 1;
                DataView ingredientSorted = new DataView(ingredients);
                ingredientSorted.Sort = "[1] ASC";
                foreach (DataRow supplier in suppliers.Rows)
                {
                    Excel.Rows.Add(supplier.ItemArray[0].ToString().ToUpper(), "", "");
                    foreach (DataRowView ingredient in ingredientSorted)
                    {
                        IngBO.ing = ingredient[0].ToString();
                        DataTable dt         = IngBL.searchIngredientReturnPrice(IngBO);
                        string    suppliedby = ingredient[1].ToString();
                        if (supplier.ItemArray[0].ToString() == suppliedby)
                        {
                            foreach (DataRow price in dt.Rows)
                            {
                                Total.Add(Convert.ToDecimal(ingredient[2].ToString()) * Convert.ToDecimal(price.ItemArray[4].ToString()));
                                Excel.Rows.Add(" " + ingredient[0].ToString(), ingredient[2].ToString() + " " + price.ItemArray[2].ToString(), "P " + (Convert.ToDecimal(ingredient[2].ToString()) * Convert.ToDecimal(price.ItemArray[4].ToString())).ToString("0.##"));
                            }
                        }
                    }
                    Excel.Rows.Add("", "", "");
                    Excel.Rows.Add("Budget for " + supplier.ItemArray[0].ToString(), "", "P " + (Total.Sum()).ToString("0.##"));
                    Excel.Rows.Add("", "", "");
                    Excel.Rows.Add("", "", "");
                    OverAll = OverAll + Total.Sum();
                    Total.Clear();
                }
                Excel.Rows.Add("", "Grand Total", "P " + OverAll.ToString("0.##"));
                vip       = 0;
                guest     = 0;
                kids      = 0;
                crew      = 0;
                Other     = 0;
                indicator = 0;
                OverAll   = 0;
                CrystalReport2 cr = new CrystalReport2();
                cr.SetDataSource(Excel);
                crystalReportViewer1.ReportSource = cr;
            }
            else
            {
                MessageBox.Show("No event can be shown!");
            }
        }
Beispiel #17
0
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RecipeBL = new RecipeBL();
            RecipeBO = new RecipeBO();
            try
            {
                int selectedcat = Convert.ToInt32(tabControl1.SelectedIndex.ToString());
                if (selectedcat == 0)
                {
                    cat = "Appetizer";
                }
                else if (selectedcat == 1)
                {
                    cat = "Bread Service";
                }
                else if (selectedcat == 2)
                {
                    cat = "Soup";
                }
                else if (selectedcat == 3)
                {
                    cat = "Salad";
                }
                else if (selectedcat == 4)
                {
                    cat = "Pasta";
                }
                else if (selectedcat == 5)
                {
                    cat = "Main Dish";
                }
                else if (selectedcat == 6)
                {
                    cat = "Kiddie Meal";
                }
                else if (selectedcat == 7)
                {
                    cat = "Rice";
                }
                else if (selectedcat == 8)
                {
                    cat = "Dessert";
                }
                else if (selectedcat == 9)
                {
                    cat = "Cake";
                }
                else if (selectedcat == 10)
                {
                    cat = "Drinks";
                }
                else if (selectedcat == 11)
                {
                    cat = "Crew meal";
                }
                else if (selectedcat == 12)
                {
                    cat = "Others";
                }

                if (radioButton1.Checked == true)
                {
                    RecipeBO.recipe = textBox6.Text.Trim();
                    if (textBox6.Text == "Search box")
                    {
                        RecipeBO.recipe = "";
                    }
                    RecipeBO.cat             = cat;
                    dataGridView1.DataSource = RecipeBL.searchRecipe(RecipeBO);
                }
                else
                {
                    RecipeBO.recipe = textBox6.Text.Trim();
                    if (textBox6.Text == "Search box")
                    {
                        RecipeBO.recipe = " ";
                    }
                    RecipeBO.cat             = cat;
                    dataGridView1.DataSource = RecipeBL.searchRecipeUn(RecipeBO);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #18
0
        public void addAlteredDish()
        {
            catBL = new CateringBL();
            catBO = new CateringBO();
            RecBO = new RecipeBO();
            RecBL = new RecipeBL();
            decimal        dishprice       = 0;
            SupplierBL     SuppBL          = new SupplierBL();
            SupplierBO     SuppBO          = new SupplierBO();
            int            recipeid        = 0;
            decimal        price           = 0;
            int            count           = 0;
            int            counter         = 0;
            int            pricecounter    = 0;
            List <decimal> popoy           = new List <decimal>();
            List <decimal> cdad            = new List <decimal>();
            List <decimal> supp            = new List <decimal>();
            List <decimal> popoyP          = new List <decimal>();
            List <decimal> cdadP           = new List <decimal>();
            List <decimal> suppP           = new List <decimal>();
            List <decimal> totalPrice      = new List <decimal>();
            List <decimal> IngredientPrice = new List <decimal>();
            List <string>  Categories      = new List <string>();
            string         typeofevent     = "";
            DataTable      Suppliers       = new DataTable();

            Suppliers.Columns.Add("Supplier", typeof(string));
            Suppliers.Columns.Add("Amount", typeof(decimal));
            Suppliers.PrimaryKey = new DataColumn[] { Suppliers.Columns["Supplier"] };
            var SuppAmount   = new Dictionary <string, decimal>();
            int paramcounter = 0;

            if (dataGridView2.Rows.Count != 0)
            {
                foreach (DataGridViewRow row in dataGridView2.Rows)
                {
                    dishselected++;
                    RecBO.recipe = row.Cells[0].Value.ToString();
                    RecBO.cat    = comboBox1.Text.Trim();
                    DataTable Recipe = RecBL.searchRecipeSingle(RecBO);
                    foreach (DataRow rows in Recipe.Rows)
                    {
                        catBO.recipeid = rows.ItemArray[0].ToString();
                        DataTable supps = catBL.getSuppPrices(catBO);
                        foreach (DataRow prices in supps.Rows)
                        {
                            if (!SuppAmount.Keys.Contains(prices.ItemArray[1].ToString()))
                            {
                                SuppAmount[prices.ItemArray[1].ToString()] = 0;
                            }
                            if (!Suppliers.Rows.Contains(prices.ItemArray[1].ToString()))
                            {
                                Suppliers.Rows.Add(prices.ItemArray[1].ToString());
                            }
                            IngredientPrice.Add(Convert.ToDecimal(prices.ItemArray[0].ToString()));
                        }
                        recipeid       = Convert.ToInt32(rows.ItemArray[0].ToString());
                        catBO.recipeid = rows.ItemArray[0].ToString();
                        catBO.catID    = catID;
                    }
                    result.Rows.Add(dishselected + ": " + row.Cells[0].Value.ToString() + " (PAX:" + txtGuest.Text + " SERVICE:" + comboBox3.Text + ")", "Quantity", "Price");
                    ResultQty.Rows.Add(dishselected + ": " + row.Cells[0].Value.ToString() + " (PAX:" + txtGuest.Text + " SERVICE:" + comboBox3.Text + ")", "Quantity");
                    reserve.Rows.Add(dishselected + ": " + row.Cells[0].Value.ToString() + " (PAX:" + txtGuest.Text + " SERVICE:" + comboBox3.Text + ")");
                    RecBO.recipeid = Convert.ToString(recipeid);
                    DataTable dt       = RecBL.getIngByRecIdOrig(RecBO);
                    decimal   priceout = 0;
                    decimal   qty      = 0;
                    foreach (DataRow rowss in dt.Rows)
                    {
                        //AddDish
                        price = price + getPrice(rowss.ItemArray[2].ToString(), row.Cells[1].Value.ToString());
                        if (totalPrice.Count == 0)
                        {
                            qty = IngredientPrice[pricecounter] * Convert.ToDecimal(price);
                            if (comboBox1.Text == "Main dish" && comboBox3.Text == "Plated")
                            {
                                qty   = qty * Properties.Settings.Default.Plated;
                                price = price * Properties.Settings.Default.Plated;
                            }
                            dishprice = dishprice + qty;
                            SuppAmount[rowss.ItemArray[3].ToString()] = Convert.ToDecimal((SuppAmount[rowss.ItemArray[3].ToString()] + qty));
                            totalPrice.Add(qty);
                            result.Rows.Add("   " + rowss.ItemArray[4].ToString(), price + " " + rowss.ItemArray[5].ToString(), "P. " + qty.ToString("0.##"));
                            ResultQty.Rows.Add("   " + rowss.ItemArray[4].ToString(), price + " " + rowss.ItemArray[5].ToString());
                        }
                        else
                        {
                            qty = IngredientPrice[pricecounter] * Convert.ToDecimal(price);
                            if (comboBox1.Text == "Main dish" && comboBox3.Text == "Plated")
                            {
                                qty   = qty * Properties.Settings.Default.Plated;
                                price = price * Properties.Settings.Default.Plated;
                            }
                            dishprice = dishprice + qty;
                            SuppAmount[rowss.ItemArray[3].ToString()] = Convert.ToDecimal((SuppAmount[rowss.ItemArray[3].ToString()] + qty));
                            totalPrice[paramcounter] = totalPrice[paramcounter] + qty;
                            result.Rows.Add("   " + rowss.ItemArray[4].ToString(), price + " " + rowss.ItemArray[5].ToString(), "P. " + qty.ToString("0.##"));
                            ResultQty.Rows.Add("   " + rowss.ItemArray[4].ToString(), price + " " + rowss.ItemArray[5].ToString());
                        }
                        pricecounter = pricecounter + 1;
                        price        = 0;
                    }

                    ResultQty.Rows.Add("", "");
                    result.Rows.Add("Total ", "-------------", "P " + dishprice.ToString("0.##"));
                    result.Rows.Add("", "", "");
                    dishprice = 0;
                }
                if (totalPrice.Count != 0)
                {
                    totalExpense = totalPrice[0] + totalExpense;
                }
                notifier("Dish deleted!");
            }
        }
Beispiel #19
0
 private void button1_Click(object sender, EventArgs e)
 {
     RecBL = new RecipeBL();
     RecBO = new RecipeBO();
     try
     {
         RecBO.recipe   = textBox1.Text.Trim();
         RecBO.cat      = comboBox1.Text.Trim();
         RecBO.recipeid = Convert.ToString(RecipeID);
         if (SelectedAction == "New")
         {
             if (RecBL.checkRecipeName(RecBO).Rows.Count == 0)
             {
                 if (dataGridView1.Rows.Count != 0 && textBox1.Text != "" && comboBox1.Text != "")
                 {
                     RecBL.makeRecipeAvail(RecBO);
                     RecBL.updateRecipe(RecBO);
                     time = 0;
                     notifier("Dish Successfully added!");
                     lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                     this.panel3.BackColor = System.Drawing.Color.DodgerBlue;
                     acceptbutton          = true;
                     this.DialogResult     = DialogResult.OK;
                 }
                 else
                 {
                     time = 0;
                     notifier("Fill Dish description and add ingredients to dish!");
                     lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                     this.panel3.BackColor = System.Drawing.Color.Tomato;
                 }
             }
             else
             {
                 time = 0;
                 notifier("Dish name is already registered!");
                 lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                 this.panel3.BackColor = System.Drawing.Color.Tomato;
             }
         }
         else
         {
             RecBO.recipeid = Convert.ToString(RecipeID);
             RecBO.recipe   = textBox1.Text.Trim();
             bool notaltered = !(RecBL.checkRecipe(RecBO).Rows.Count == 1);
             bool unique     = !(RecBL.checkRecipeName(RecBO).Rows.Count == 1);
             if (string.Equals(textBox1.Text, origDesc, StringComparison.CurrentCultureIgnoreCase))
             {
                 notaltered = true;
                 unique     = true;
             }
             if (notaltered && unique)
             {
                 RecBO.recipeid = Convert.ToString(RecipeID);
                 RecBO.recipe   = textBox1.Text.Trim();
                 RecBO.cat      = comboBox1.Text.Trim();
                 if (MessageBox.Show("Done updating dish?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                 {
                     RecBL.updateRecipe(RecBO);
                     recipename        = textBox1.Text.Trim();
                     acceptbutton      = true;
                     this.DialogResult = DialogResult.OK;
                 }
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }