private void btnBack_Click(object sender, EventArgs e) { FoodManagement foodManagement = FoodManagement.getInstance(); foodManagement.Show(); this.Hide(); }
private void btnBackRPAlerts_Click(object sender, EventArgs e) { FoodManagement fm = FoodManagement.getInstance(); this.Hide(); fm.Show(); }
private void btndeleteFoodCard_Click(object sender, EventArgs e) { String cardID = this.cardId; //getting the cliked card id FoodManagement foodManagement = FoodManagement.getInstance(); foodManagement.deleteFood(cardID); //passing the Id }
public static FoodManagement getInstance() { if (uniqueInstance == null) { uniqueInstance = new FoodManagement(); } return(uniqueInstance); }
//Adding Item to the Data Base ----------------------- private void btnSaveFoodItem_Click(object sender, EventArgs e) { if (status == "food") //adding meal/food details { //getting the user entered value food.foodCode = txtID.Text; food.name = txtName.Text; food.description = txtDescription.Text; //setting selling price double sellingPrice; bool result1 = Double.TryParse(txtSellingPrice.Text, out sellingPrice); if (result1 == false) { MessageBox.Show("Please enter Selling price"); } else { food.sellingPrice = (float)sellingPrice; } //setting discount rate double discountRate; bool result2 = Double.TryParse(txtDiscountRate.Text, out discountRate); if (result2 == false) { MessageBox.Show("Please enter Discount Rate"); } else { food.disountRate = (float)discountRate; } //setting category id String cid = Util.getCategoryID("FoodCategory", comboCategory.Text); food.categoryID = cid; //setting Image food.foodImage = Util.convertImageToBinary(picBoxImage.Image); //****** saving informations to the database using (DBEntities db = new DBEntities()) { if (operation == "save") { db.Foods.Add(food); MessageBox.Show("Meal/Food Item Added Successfully!!!"); } else if (operation == "update") { //updating the database db.Entry(food).State = EntityState.Modified; MessageBox.Show("Food details Updated Successfully"); } db.SaveChanges(); clear(); } } else if (status == "readyMade") //addimng a readymade product details { //setting values to the row object itemModel.itemID = txtID.Text; itemModel.name = txtName.Text; //setting purchase price double purchaseprice; bool result3 = Double.TryParse(txtFoodPurchasePrice.Text, out purchaseprice); if (result3 == false) { MessageBox.Show("Please enter Purchase price"); } else { itemModel.purchase_price = (float)purchaseprice; } itemModel.suppliedBy = null; //this shold be implemented After adding supplier table itemModel.limitQuantity = Int32.Parse(textReadymadeLimitQuantity.Text); //setting category id String cid = Util.getCategoryID("ItemCategory", comboCategory.Text); itemModel.categoryID = cid; //setting Image itemModel.image = Util.convertImageToBinary(picBoxImage.Image); //************* details adding to readyMAde product table * readymaddModel.productID = txtID.Text; //setting selling price of the product double productSellPrice; bool result4 = Double.TryParse(txtReadyMadeSellingPrice.Text, out productSellPrice); if (result4 == false) { MessageBox.Show("Please enter Selling price of the product"); } else { readymaddModel.sellingPrice = (float)productSellPrice; } //************* using (DBEntities db = new DBEntities()) { db.Items.Add(itemModel); db.ReadyMadeProducts.Add(readymaddModel); db.SaveChanges(); MessageBox.Show("Ready Made product Added Successfully"); clear(); } } else { MessageBox.Show("Cannot identify !!! (rm or Food) "); } FoodManagement fm = FoodManagement.getInstance(); fm.clearFoodcardpanel(); fm.loadFoodItemCards(); this.Hide(); fm.Show(); } // --------------------------------------------------------------------------------------------