Exemple #1
0
        private void dataGridViewCart_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridViewCart.CurrentCell.ColumnIndex == 3)
            {
                int item_id  = (int)dataGridViewCart.CurrentRow.Cells["oLITEMDataGridViewTextBoxColumn"].Value; //Other name!!
                int quantity = (int)dataGridViewCart.CurrentRow.Cells["oLQUANTITYDataGridViewTextBoxColumn"].Value;
                sum -= (double)ctx.ITEMS.Single(a => a.I_ID == item_id).I_PRICE *quantity;
                int line_id = (int)dataGridViewCart.CurrentRow.Cells["oLIDDataGridViewTextBoxColumn"].Value;
                if (dataGridViewCart.Rows.Count == 0)
                {
                    sum = 0;
                }
                labelPrice.Text = sum.ToString() + " грн.";

                var line = (from o in ctx.ORDER_LINES
                            where o.OL_ID == line_id
                            select o).First();

                ctx.ORDER_LINES.Remove(line);
                ctx.SaveChanges();
                orderLines.Remove(line_id);

                oRDERLINESBindingSource.RemoveCurrent();
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            AddImages addImages = new AddImages();

            addImages.ShowDialog(this);

            if (!addImages.success)
            {
                addImages.Dispose();
                return;
            }

            image_id = addImages.image_id;
            addImages.Dispose();

            var item = (from i in ctx.ITEMS
                        where i.I_ID == item_id
                        select i).First();

            item.I_IMAGE = image_id;
            ctx.SaveChanges();

            var picture = (from im in ctx.IMAGES
                           where im.IMG_id == image_id
                           select im.IMG_ImageData).First();

            System.IO.MemoryStream ms = new System.IO.MemoryStream(picture);
            var img = System.Drawing.Image.FromStream(ms);

            pictureBox1.Image = img;

            var old_image = (from im in ctx.IMAGES
                             where im.IMG_id == old_image_id
                             select im).First();

            ctx.IMAGES.Remove(old_image);
            ctx.SaveChanges();

            old_image_id = image_id;
        }
Exemple #3
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            string message = "Ви впевнені, що хочете відминити це замовлення?";
            string caption = "Увага!";

            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      result;

            result = MessageBox.Show(message, caption, buttons);

            if (result == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            var header = (from h in ctx.ORDER_HEADERS
                          where h.OH_ID == header_id
                          select h).First();

            ctx.ORDER_HEADERS.Remove(header);
            ctx.SaveChanges();

            this.Close();
        }