private void checkInRawMix() { List<Raw_Mix> lst = ctx.Raw_Mix.Where(o => o.mix_id == mix_id && o.finished == false).ToList(); if (lst.Count > 1) { MessageBox.Show("There is more than one Mix on the go","Can't Continue",MessageBoxButtons.OK,MessageBoxIcon.Error); Form frm = new RawMixManager(); frm.ShowDialog(); Close(); } else if(lst.Count == 1) { isNew = false; List<LotCode> lotCodes = getAvailableLotCodes();//this is needed later on foreach (Raw_Mix r in lst) { cmbRecipeName.SelectedIndex = cmbRecipeName.Items.IndexOf(r.mix_name); mix_id = r.mix_id; txtAmount.Value = Convert.ToDecimal(r.litresToProduce); txtButterFat.Value = Convert.ToDecimal(r.butter_fat); txtSNF.Value = Convert.ToDecimal(r.snf); txtPtNumber.Value = Convert.ToDecimal(r.pt_number); dtPtWashDate.Value = Convert.ToDateTime(r.pt_wash_Date); DateTime dt = DateTime.ParseExact(r.pt_wash_time, "HHmmss", CultureInfo.InvariantCulture); dtPtWashTime.Value = dt; dtSanitizedDate.Value = Convert.ToDateTime(r.sanitized_date); dt = DateTime.ParseExact(r.sanitized_time, "HHmmss", CultureInfo.InvariantCulture); dtSanitizedTime.Value = dt; KeyValuePair<string, bool> kvpYesNo; if (Convert.ToBoolean(r.agitator_verification)) { kvpYesNo = new KeyValuePair<string, bool>("Yes", true); } else { kvpYesNo = new KeyValuePair<string, bool>("Yes", true); } cmbAgitatorVerification.SelectedIndex = cmbAgitatorVerification.Items.IndexOf(kvpYesNo); if (Convert.ToBoolean(r.cooling_Verification)) { kvpYesNo = new KeyValuePair<string, bool>("Yes", true); } else { kvpYesNo = new KeyValuePair<string, bool>("Yes", true); } cmbCoolingVerification.SelectedIndex = cmbAgitatorVerification.Items.IndexOf(kvpYesNo); cmbCreamTank.SelectedIndex = cmbCreamTank.Items.IndexOf(r.cream_Tank_Number.ToString()); txtMixMaker.Text = r.mix_maker; List<Raw_Mix_Ingredient_list> rawMixIngredientList = ctx.Raw_Mix_Ingredient_list.Where(o => o.mix_id == r.mix_id).ToList(); foreach (Raw_Mix_Ingredient_list rmil in rawMixIngredientList) { RawMixIngredient ingred = new RawMixIngredient(); ingred.name = rmil.ingredient; ingred.ingredient_id = rmil.ingredient_id; ingred.quantity = Convert.ToDecimal(rmil.quantity); ingred.weight = Convert.ToDecimal(rmil.ingredient_weight); ingred.availableLotCodes = lotCodes.Where(o => o.ingredientName == ingred.name).Select(o => new LotCode { ingredientName = o.ingredientName, lotCode = o.lotCode, quantity = o.quantity }).ToList(); List<Raw_Mix_Ingredient_Lot_code> rawMixLotCodeList = ctx.Raw_Mix_Ingredient_Lot_code.Where(o => o.ingredient_id == rmil.ingredient_id).ToList(); foreach(Raw_Mix_Ingredient_Lot_code rmilc in rawMixLotCodeList) { LotCode lc = new LotCode(); lc.lotCode = rmilc.lot_code; lc.po = rmilc.po_Number; lc.quantity = Convert.ToDecimal(rmilc.quantity); lc.ingredientName = rmil.ingredient; ingred.lotCodes.Add(lc); } var whatever = ingred.panel; ingred.showSelectedLotCodes(); listOfIngredientsAndQuantities.Add(ingred); } displayTheRecipe(listOfIngredientsAndQuantities); foreach(RawMixIngredient rawMixIngredient in listOfIngredientsAndQuantities) { string strLabel = ""; foreach(LotCode lt in rawMixIngredient.lotCodes) { strLabel += lt.display(); } rawMixIngredient.lblLotCodes.Text = strLabel; } if(Convert.ToBoolean(r.finished)) { confirmSaveToolStripMenuItem.Enabled = false; } } } }
/// <summary> /// this is called to save to temp table /// </summary> /// <param name="ing"></param> /// <param name="l"></param> private void createDryIngredientUseTemp(RawMixIngredient ing, LotCode l) { Dry_Ingredient_Use_Temp d = new Dry_Ingredient_Use_Temp(); if (l != null) { d.Lot_Code = l.lotCode; d.bags_used = l.quantity; } else { d.bags_used = ing.quantity; d.totalWeightForLotCode = ing.weight; } //d.bags_used = ing.quantity;//l.quantity; d.mix_date = DateTime.Today; d.litresToProduce = txtAmount.Value; d.flavour = cmbRecipeName.Text; d.PT_Number = Convert.ToInt32(txtPtNumber.Value); d.ingredient = ing.name; d.total_amount = ing.totalVolume; d.butterFat = txtButterFat.Value; d.snf = txtSNF.Value; d.ptWashDate = dtPtWashDate.Value; d.ptWashTime = dtPtWashTime.Value.ToShortTimeString(); d.sanitizedDate = dtSanitizedDate.Value; d.sanitizedTime = dtSanitizedTime.Value.ToShortTimeString(); d.agiatorVerification = Convert.ToBoolean(cmbAgitatorVerification.SelectedValue); d.coolingVerification = Convert.ToBoolean(cmbCoolingVerification.SelectedValue); d.creamTank = Convert.ToInt32(cmbCreamTank.SelectedValue); d.mixMaker = txtMixMaker.Text; d.purchase_order_number = ing.purchaseOrderNumber; //switch (ing.name) //{ // case "Cream": // d.ord = 1; // break; // case "Glucose": // d.ord = 2; // break; // case "Whey": // d.ord = 3; // break; // case "Skim Powder": // d.ord = 3; // break; // case "Sugar": // d.ord = 4; // break; // case "DI 15 Stabilizer": // d.ord = 5; // break; // case "CCC360 Stabilizer": // d.ord = 5; // break; // case "Annatto Yellow #170": // d.ord = 5; // break; // case "Egg Yellow": // d.ord = 5; // break; // case "CP5303 Cocoa": // d.ord = 5; // break; // case "CP5171 Cocoa": // d.ord= 5; // break; // case "Water": // d.ord = 6; // break; // default: // d.ord = 5; // break; //} ctx.Dry_Ingredient_Use_Temp.Add(d); }
private void BtnAdd_Click(object sender, EventArgs e) { if((!string.IsNullOrEmpty(cmbLotCodes.Text.ToString()) && txtQty.Value > 0 ) || name.Equals("Water")) { if(txtQty.Value <= Convert.ToDecimal(cmbLotCodes.SelectedValue) || name == "Cream" || name == "Water" ) { LotCode lt = new LotCode(); lt.ingredientName = name; lt.lotCode = cmbLotCodes.Text.ToString(); lt.quantity = txtQty.Value; lt.po = cmbPO.Text; lotCodes.Add(lt); lblLotCodes.Text += lt.display(); totalVolume += Convert.ToDecimal(lt.quantity); totalRemainder = decimal.Add(totalRemainder, getRoundedNumber(Convert.ToDecimal(lt.quantity))); lblRemainder.Text = totalRemainder.ToString(); setRemainderColor(); } else { MessageBox.Show("you have selected more than you have in stock"); } } else { MessageBox.Show("Please enter the amount you would like to add"); } }