Example #1
0
        public bool UpdateBillItem(CaffeBillItem caffeBillItem)
        {
            int result = this.billItemRepository.UpdateBillItem(caffeBillItem);

            if (result != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public int InsertCaffeBillItem(CaffeBillItem caffeBillItem)
        {
            int result;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection  = connection;
                sqlCommand.CommandText = $"Insert into BillItems(Article_ID, Bill_ID, Quantity) values({caffeBillItem.Article_ID},{caffeBillItem.Bill_ID},{caffeBillItem.Quantity})";
                result = sqlCommand.ExecuteNonQuery();
            }
            return(result);
        }
Example #3
0
        public int UpdateBillItem(CaffeBillItem caffeBillItem)
        {
            int result;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection  = connection;
                sqlCommand.CommandText = "Update BillItems SET Quantity=@quantity where Article_ID =@articleID and Bill_ID = @bill_ID";
                sqlCommand.Parameters.AddWithValue("@quantity", caffeBillItem.Quantity);
                sqlCommand.Parameters.AddWithValue("@articleID", caffeBillItem.Article_ID);
                sqlCommand.Parameters.AddWithValue("@bill_ID", caffeBillItem.Bill_ID);
                result = sqlCommand.ExecuteNonQuery();
            }
            return(result);
        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            BillBusiness     billb = new BillBusiness();
            BillItemBusiness bb    = new BillItemBusiness();
            ArticleBusiness  ab    = new ArticleBusiness();

            if (comboBox1.Text != "Bezalkoholna pica")
            {
                string       tempname = comboBox1.Text.Split('-')[0];
                CaffeArticle ca       = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0];
                BillBusiness.currentBill.Total_Price += ca.Price;
                billb.UpdateCaffeBill(BillBusiness.currentBill);
                try
                {
                    CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1);
                    bb.InsertBillItem(cb);
                }
                catch
                {
                    CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    zeka.Quantity++;
                    bb.UpdateBillItem(zeka);
                }
                refresh();
            }
            if (comboBox2.Text != "Zestina")
            {
                string       tempname = comboBox2.Text.Split('-')[0];
                CaffeArticle ca       = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0];
                BillBusiness.currentBill.Total_Price += ca.Price;
                billb.UpdateCaffeBill(BillBusiness.currentBill);
                try
                {
                    CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1);
                    bb.InsertBillItem(cb);
                }
                catch
                {
                    CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    zeka.Quantity++;
                    bb.UpdateBillItem(zeka);
                }
                refresh();
            }
            if (comboBox3.Text != "Pivo")
            {
                string       tempname = comboBox3.Text.Split('-')[0];
                CaffeArticle ca       = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0];
                BillBusiness.currentBill.Total_Price += ca.Price;
                billb.UpdateCaffeBill(BillBusiness.currentBill);
                try
                {
                    CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1);
                    bb.InsertBillItem(cb);
                }
                catch
                {
                    CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    zeka.Quantity++;
                    bb.UpdateBillItem(zeka);
                }
                refresh();
            }
            if (comboBox4.Text != "Topli napici")
            {
                string       tempname = comboBox4.Text.Split('-')[0];
                CaffeArticle ca       = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0];
                BillBusiness.currentBill.Total_Price += ca.Price;
                billb.UpdateCaffeBill(BillBusiness.currentBill);
                try
                {
                    CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1);
                    bb.InsertBillItem(cb);
                }
                catch
                {
                    CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    zeka.Quantity++;
                    bb.UpdateBillItem(zeka);
                }
                refresh();
            }
        }
        protected void dodaj_ServerClick(object sender, EventArgs e)
        {
            ArticleRepository  ab       = new ArticleRepository();
            BillItemRepository billItem = new BillItemRepository();
            BillBusiness       bp       = new BillBusiness();
            String             s        = toplinapici.Value;

            if (s != null && s != "Topli napici")
            {
                CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s)).ToList()[0];
                BillBusiness.currentBill.Total_Price += c.Price;
                HtmlGenericControl par = new HtmlGenericControl("p");
                par.InnerText = c.ToString();
                // contentmain.Controls.Add(par);
                BillItemRepository br = new BillItemRepository();
                try
                {
                    billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1));
                }
                catch (Exception xr)
                {
                    CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    cs.Quantity = cs.Quantity + 1;
                    billItem.UpdateBillItem(cs);
                }
                Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD";
                bp.UpdateCaffeBill(BillBusiness.currentBill);
            }
            String s1 = zestina.Value;

            if (s1 != null && s1 != "Žestina")
            {
                CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s1)).ToList()[0];
                BillBusiness.currentBill.Total_Price += c.Price;
                HtmlGenericControl par = new HtmlGenericControl("p");
                par.InnerText = c.ToString();
                // contentmain.Controls.Add(par);
                BillItemRepository br = new BillItemRepository();
                try
                {
                    billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1));
                }
                catch (Exception xr)
                {
                    CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    cs.Quantity = cs.Quantity + 1;
                    billItem.UpdateBillItem(cs);
                }
                Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD";
                bp.UpdateCaffeBill(BillBusiness.currentBill);
            }
            String s2 = Pivo.Value;

            if (s2 != null && s2 != "Pivo")
            {
                CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s2)).ToList()[0];
                BillBusiness.currentBill.Total_Price += c.Price;
                HtmlGenericControl par = new HtmlGenericControl("p");
                par.InnerText = c.ToString();
                // contentmain.Controls.Add(par);
                BillItemRepository br = new BillItemRepository();
                try
                {
                    billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1));
                }
                catch (Exception xr)
                {
                    CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    cs.Quantity = cs.Quantity + 1;
                    billItem.UpdateBillItem(cs);
                }
                Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD";
                bp.UpdateCaffeBill(BillBusiness.currentBill);
            }
            String s3 = bezalkohola.Value;

            if (s3 != null && s3 != "Bezalkoholna pića")
            {
                CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s3)).ToList()[0];
                BillBusiness.currentBill.Total_Price += c.Price;
                HtmlGenericControl par = new HtmlGenericControl("p");
                par.InnerText = c.ToString();
                // contentmain.Controls.Add(par);
                BillItemRepository br = new BillItemRepository();
                try
                {
                    billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1));
                }
                catch (Exception xr)
                {
                    CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0];
                    cs.Quantity = cs.Quantity + 1;
                    billItem.UpdateBillItem(cs);
                }
                Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD";
                bp.UpdateCaffeBill(BillBusiness.currentBill);
            }
            Response.Redirect("Bill.aspx");
        }
Example #6
0
 public void init()
 {
     c  = new CaffeBillItem(4, 5204, 8);
     cr = new BillItemRepository();
 }