Ejemplo n.º 1
0
        //****EVENTS*******************************************
        //Submit and Update Button
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            if (noChange == false)
            {
                if (token == 0)
                {
                    itemType = DrpBoxType.Text;
                    if (itemType == "Beer")
                    {
                        Beer temp = new Beer();
                        token++;
                        DropBoxEmpty(DrpBoxStyle);
                        DropBoxEmpty(DrpBoxSize);
                        TypeAdd(temp.BeerTypes, DrpBoxStyle);
                        TypeAdd(temp.BeerSizes, DrpBoxSize);
                        Show(itemType, "on");
                    }
                    else if (itemType == "Food")
                    {
                        token++;
                        DropBoxEmpty(DrpBoxStyle);
                        DropBoxEmpty(DrpBoxSize);
                        Show(itemType, "on");
                        LblSize.Visible    = false;
                        DrpBoxSize.Visible = false;
                    }
                    else if (itemType == "Liquor" || itemType == "Wine")
                    {
                        token++;
                        DropBoxEmpty(DrpBoxStyle);
                        DropBoxEmpty(DrpBoxSize);
                        if (itemType == "Liquor")
                        {
                            Liquor temp = new Liquor();
                            TypeAdd(temp.LiquorTypes, DrpBoxStyle);
                            TypeAdd(temp.LiquorSizes, DrpBoxSize);
                        }
                        else
                        {
                            Wine temp = new Wine();
                            TypeAdd(temp.WineTypes, DrpBoxStyle);
                            TypeAdd(temp.WineSizes, DrpBoxSize);
                        }
                        Show(itemType, "on");
                    }

                    else
                    {
                        LblErrType.Text = "*Pick One*";
                    }
                    if (token == 1)
                    {
                        LblErrType.Text = "";
                    }
                }
                else if (token == 1)
                {
                    if (itemType == "Beer")
                    {
                        Beer temp = new Beer();

                        temp.Brand  = TxtBrand.Text;
                        temp.Name   = TxtName.Text;
                        temp.Style  = DrpBoxStyle.Text;
                        temp.Size   = DrpBoxSize.Text;
                        temp.Stock  = TxtStock.Text;
                        temp.Price  = TxtPrice.Text;
                        temp.Cost   = TxtCost.Text;
                        temp.Season = TxtSeason.Text;
                        if (temp.ErrMsg.Length < 1)
                        {
                            token = 0;
                            MessageBox.Show(temp.Display());
                            Show(itemType, "off");
                            MessageBox.Show(temp.SendData(itemType));
                        }
                        LblErrMsg.Text = temp.ErrMsg;
                    }
                    else if (itemType == "Food")
                    {
                        Item temp = new Item();

                        temp.Brand = TxtBrand.Text;
                        temp.Name  = TxtName.Text;
                        temp.Stock = TxtStock.Text;
                        temp.Price = TxtPrice.Text;
                        temp.Cost  = TxtCost.Text;
                        if (temp.ErrMsg.Length < 1)
                        {
                            token = 0;
                            MessageBox.Show(temp.Display());
                            Show(itemType, "off");
                            MessageBox.Show(temp.SendData(itemType));
                        }
                        LblErrMsg.Text = temp.ErrMsg;
                    }
                    else if (itemType == "Liquor")
                    {
                        Liquor temp = new Liquor();

                        temp.Brand = TxtBrand.Text;
                        temp.Name  = TxtName.Text;
                        temp.Style = DrpBoxStyle.Text;
                        temp.Size  = DrpBoxSize.Text;
                        temp.Stock = TxtStock.Text;
                        temp.Price = TxtPrice.Text;
                        temp.Cost  = TxtCost.Text;
                        if (temp.ErrMsg.Length < 1)
                        {
                            token = 0;
                            MessageBox.Show(temp.Display());
                            Show(itemType, "off");
                            MessageBox.Show(temp.SendData(itemType));
                        }
                        LblErrMsg.Text = temp.ErrMsg;
                    }
                    else
                    {
                        Wine temp = new Wine();

                        temp.Brand = TxtBrand.Text;
                        temp.Name  = TxtName.Text;
                        temp.Style = DrpBoxStyle.Text;
                        temp.Size  = DrpBoxSize.Text;
                        temp.Stock = TxtStock.Text;
                        temp.Price = TxtPrice.Text;
                        temp.Cost  = TxtCost.Text;
                        if (temp.ErrMsg.Length < 1)
                        {
                            token = 0;
                            MessageBox.Show(temp.Display());
                            Show(itemType, "off");
                            MessageBox.Show(temp.SendData(itemType));
                        }
                        LblErrMsg.Text = temp.ErrMsg;
                    }
                }
            }
            else
            {
                if (itemType == "Food")
                {
                    Item temp = new Item();
                    temp.Brand  = TxtBrand.Text;
                    temp.Name   = TxtName.Text;
                    temp.Stock  = TxtStock.Text;
                    temp.Price  = TxtPrice.Text;
                    temp.Cost   = TxtCost.Text;
                    temp.Markup = temp.GetMark(temp.Price, temp.Cost);
                    temp.Profit = temp.GetProfit(temp.Stock, temp.Price, temp.Cost);
                    if (temp.ErrMsg.Length < 1)
                    {
                        token = 0;
                        MessageBox.Show(temp.Display());
                        MessageBox.Show(temp.UpdateData(indexSQL));
                        this.Close();
                    }
                    LblErrMsg.Text = temp.ErrMsg;
                }
                else if (itemType == "Beer")
                {
                    Beer temp = new Beer();
                    temp.Brand  = TxtBrand.Text;
                    temp.Name   = TxtName.Text;
                    temp.Style  = DrpBoxStyle.Text;
                    temp.Size   = DrpBoxSize.Text;
                    temp.Stock  = TxtStock.Text;
                    temp.Price  = TxtPrice.Text;
                    temp.Cost   = TxtCost.Text;
                    temp.Season = TxtSeason.Text;
                    temp.Markup = temp.GetMark(temp.Price, temp.Cost);
                    temp.Profit = temp.GetProfit(temp.Stock, temp.Price, temp.Cost);
                    if (temp.ErrMsg.Length < 1)
                    {
                        token = 0;
                        MessageBox.Show(temp.Display());
                        MessageBox.Show(temp.UpdateData(indexSQL));
                        this.Close();
                    }
                    LblErrMsg.Text = temp.ErrMsg;
                }
                else if (itemType == "Liquor")
                {
                    Liquor temp = new Liquor();
                    temp.Brand  = TxtBrand.Text;
                    temp.Name   = TxtName.Text;
                    temp.Style  = DrpBoxStyle.Text;
                    temp.Size   = DrpBoxSize.Text;
                    temp.Stock  = TxtStock.Text;
                    temp.Price  = TxtPrice.Text;
                    temp.Cost   = TxtCost.Text;
                    temp.Markup = temp.GetMark(temp.Price, temp.Cost);
                    temp.Profit = temp.GetProfit(temp.Stock, temp.Price, temp.Cost);
                    if (temp.ErrMsg.Length < 1)
                    {
                        token = 0;
                        MessageBox.Show(temp.Display());
                        MessageBox.Show(temp.UpdateData(indexSQL));
                        this.Close();
                    }
                    LblErrMsg.Text = temp.ErrMsg;
                }
                else
                {
                    Wine temp = new Wine();
                    temp.Brand  = TxtBrand.Text;
                    temp.Name   = TxtName.Text;
                    temp.Style  = DrpBoxStyle.Text;
                    temp.Size   = DrpBoxSize.Text;
                    temp.Stock  = TxtStock.Text;
                    temp.Price  = TxtPrice.Text;
                    temp.Cost   = TxtCost.Text;
                    temp.Markup = temp.GetMark(temp.Price, temp.Cost);
                    temp.Profit = temp.GetProfit(temp.Stock, temp.Price, temp.Cost);
                    if (temp.ErrMsg.Length < 1)
                    {
                        token = 0;
                        MessageBox.Show(temp.Display());
                        MessageBox.Show(temp.UpdateData(indexSQL));
                        this.Close();
                    }
                    LblErrMsg.Text = temp.ErrMsg;
                }
            }
        }