Exemplo n.º 1
0
 private void loadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     clear();
     Form frm = new RawMixManager();
     frm.ShowDialog(this);
     checkInRawMix();
     if(!String.IsNullOrEmpty(mix_id))
     {
         enableOrDisableControls(true);
     }
 }
Exemplo n.º 2
0
        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;
                    }
                }
            }
        }