예제 #1
0
        private void materialButton1_save_Click(object sender, EventArgs e)
        {
            if (betterTextBox1_name.Text.Trim() == "")
            {
                CustomControls.Alert.show("name", "enter item name", 1500);
                return;
            }
            if (betterTextBox1_price.Text.Trim() == "")
            {
                CustomControls.Alert.show("price", "enter price", 1200);
                return;
            }
            if (comboBox1_category.SelectedItem == null)
            {
                CustomControls.Alert.show("Categories", "select categories", 1200);
                return;
            }
            if (betterTextBox_unit.Text.Trim() == "")
            {
                CustomControls.Alert.show("Unit", "Please enter unit", 1200);
                return;
            }
            var      db   = Model.DatabaseConfigure.getConfigure();
            menuitem item = new menuitem()
            {
                name         = betterTextBox1_name.Text,
                price        = (betterTextBox1_price.decVal),
                unit         = betterTextBox_unit.Text,
                category_id  = ((comboBox1_category.SelectedItem as Model.category).id),
                estimated_by = betterTextBox_Estimateby.Text,
                qty          = betterTextBox_qty.decVal,
                admin_id     = INFO.admin_id,
                created_at   = DateTime.Now,
                updated_at   = DateTime.Now
            };

            db.menuitems.Add(item);
            db.SaveChanges();
            adddata?.Invoke(item);
            foreach (ListViewItem list in betterListView1.Items)
            {
                var purchaseitem_id = Convert.ToInt32(list.SubItems[5].Text);
                var qty             = Convert.ToDecimal(list.SubItems[2].Text);

                Model.manufacturingestimation MC = new Model.manufacturingestimation()
                {
                    purchaseitem_id = purchaseitem_id,
                    menuitem_id     = item.id,
                    quantity        = qty,
                    unit            = item.unit,
                    updated_at      = DateTime.Now,
                    created_at      = DateTime.Now
                };
                db.manufacturingestimations.Add(MC);
                db.SaveChanges();
            }
            this.Close();
        }
예제 #2
0
        private void materialButton_Addtocart_Click(object sender, EventArgs e)
        {
            var selitem = (purchaseitem)comboBox_pitems.SelectedItem;

                Model.manufacturingestimation MC = new Model.manufacturingestimation()
                {
                    purchaseitem_id = selitem.id,
                    menuitem_id = id,
                    quantity = betterTextBox_qty.decVal,
                    unit=betterTextBox_unitforestimate.Text,
                    updated_at = DateTime.Now,
                    created_at = DateTime.Now
                };
                db.manufacturingestimations.Add(MC);
                db.SaveChanges();
            comboBox_pitems.SelectedIndex = -1;
            betterTextBox_qty.Clear();

        }