コード例 #1
0
 private void SaveProduction()
 {
     if (!ValidateFields(pageUpdateProduction))
     {
         LocalUtils.ShowValidationFailedMessage(this);
     }
     else
     {
         var model = new AddEditProductionModel();
         model.Date      = dtDate.Value;
         model.ProductID = int.Parse(((ItemX)cboProducts.SelectedItem).Value);
         model.Quantity  = LocalUtils.ConvertToInteger(txtQuantity.Text);
         // get id
         if (productionID != 0)
         {
             Factories.CreateProduction().Edit(productionID, model);
         }
         else
         {
             Factories.CreateProduction().Add(model);
             productionID = model.ID;
         }
         LoadProductionGridList();
         LocalUtils.ShowSaveMessage(this);
     }
 }
コード例 #2
0
        private void Compute()
        {
            try
            {
                var quantity  = LocalUtils.ConvertToInteger(txtQuantity.Text);
                var unitprice = LocalUtils.ConvertToDouble(txtUnitPrice.Text);

                var total = mainLogic.ComputeTotal(quantity, unitprice);
                txtTotal.Text = total.ToString();
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        private void Save()
        {
            //id greater than zero = edit
            //id equal to zero = add
            if (milkUtilizeRecordID == 0)
            {
                // Add new record
                var model = new MilkUtilizeAddModel();

                model.ActualDate = dtDateSelection.Value;
                //model.Analysis = LocalUtils.ConvertToDouble(txtAnalysis.Text);
                //model.Demo = LocalUtils.ConvertToInteger(txtDemo.Text);
                //model.Remarks = txtRemarks.Text;
                //model.Spillage = LocalUtils.ConvertToDouble(txtSpillage.Text);
                //model.SpoilageQty = LocalUtils.ConvertToDouble(txtSpoilageQty.Text);
                //model.SpoilageValue = LocalUtils.ConvertToDouble(txtSpoilageValue.Text);
                //model.WithdrawnByProcessor = txtWithdrawnByProcessor.Text;
                //model.Remarks = txtRemarks.Text;
                Factories.CreateMilkUtilize().Add(model);
                milkUtilizeRecordID = model.ID;
            }
            else
            {
                if (!ValidateFields())
                {
                    LocalUtils.ShowValidationFailedMessage(this);
                    return;
                }
                // Edit record
                var model = new MilkUtilizeEditModel();
                model.Analysis             = LocalUtils.ConvertToDouble(txtAnalysis.Text);
                model.Demo                 = LocalUtils.ConvertToInteger(txtDemo.Text);
                model.Remarks              = txtRemarks.Text;
                model.Spillage             = LocalUtils.ConvertToDouble(txtSpillage.Text);
                model.SpoilageQty          = LocalUtils.ConvertToDouble(txtSpoilageQty.Text);
                model.SpoilageValue        = LocalUtils.ConvertToDouble(txtSpoilageValue.Text);
                model.WithdrawnByProcessor = txtWithdrawnByProcessor.Text;
                model.Remarks              = txtRemarks.Text;
                Factories.CreateMilkUtilize().Edit(milkUtilizeRecordID, model);
                mainPage.SetPage(pageList);
            }

            LocalUtils.ShowSaveMessage(this);
        }