예제 #1
0
        /// <summary>
        /// Validates Form Fields data
        /// </summary>
        /// <returns>If Validation succed, returns True. If not, returns false.</returns>
        private bool ValidatedFields()
        {
            var ctrlTextBoxes2 = LocalUtils.GetAll(pageProductDetail, typeof(BunifuTextBox))
                                 .Where(c => c.CausesValidation == true).OrderBy(c => c.TabIndex);

            foreach (BunifuTextBox item in ctrlTextBoxes2)
            {
                if (item.Text == string.Empty)
                {
                    LocalUtils.ShowValidationFailedMessage(this);
                    return(false);
                }
            }
            var ctrlDropdown = LocalUtils.GetAll(pageProductDetail, typeof(Bunifu.UI.WinForms.BunifuDropdown))
                               .Where(c => c.CausesValidation == true).OrderBy(c => c.TabIndex);

            foreach (Bunifu.UI.WinForms.BunifuDropdown item in ctrlDropdown)
            {
                if (item.SelectedIndex < 0)
                {
                    item.Focus();
                    LocalUtils.ShowValidationFailedMessage(this);
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        private void Save()
        {
            var model = new SupplyInventoryModel();

            model.SupplyTypeID     = supplyTypeID;
            model.SupplyClassID    = supplyClassID;
            model.PurchaseQuantity = LocalUtils.ConvertToDouble(txtPurchaseQty.Text);
            // get id
            if (id != 0)
            {
                model.Date = dtDate.Value;
                if (!ValidateFields())
                {
                    LocalUtils.ShowValidationFailedMessage(this);
                    return;
                }
                Factories.CreateSupplyInventory().Edit(id, model);
                LocalUtils.ShowSaveMessage(this);
            }
            else
            {
                model.Date = dtSearchDate.Value;
                Factories.CreateSupplyInventory().Add(model);
                id = model.ID;
                mainPage.SetPage(pageDetail);
                bunifuTransition1.HideSync(pnlSide, false, BunifuAnimatorNS.Animation.Transparent);
            }
        }
예제 #3
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);
     }
 }
        private bool ValidatedFields()
        {
            var ctrlTextBoxes2 = LocalUtils.GetAll(tabSupplierDetail, typeof(BunifuTextBox))
                                 .Where(c => c.CausesValidation == true).OrderBy(c => c.TabIndex);

            foreach (BunifuTextBox item in ctrlTextBoxes2)
            {
                if (item.Text == string.Empty)
                {
                    item.Focus();
                    LocalUtils.ShowValidationFailedMessage(this);
                    return(false);
                }
            }

            var ctrlDropdown = LocalUtils.GetAll(tabSupplierDetail, typeof(Bunifu.UI.WinForms.BunifuDropdown))
                               .Where(c => c.CausesValidation == true).OrderBy(c => c.TabIndex);

            foreach (Bunifu.UI.WinForms.BunifuDropdown item in ctrlDropdown)
            {
                if (item.SelectedIndex < 0)
                {
                    item.Focus();
                    MetroMessageBox.Show(this, string.Format("Empty field {0 }", item.Tag), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            return(true);
        }
예제 #5
0
        private void Save()
        {
            try
            {
                if (!ValidateFields())
                {
                    LocalUtils.ShowValidationFailedMessage(this);
                    return;
                }

                var model = new UserModel();
                model.Password       = txtPassword.Text;
                model.ReTypePassword = txtRetypePassword.Text;
                model.UserName       = txtUserName.Text;
                if (userID > 0)
                {
                    Factories.CreateUser().Edit(userID, model);
                }
                else
                {
                    Factories.CreateUser().Add(model);
                    userID = model.ID;
                }
                ShowMainGrid();
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.Message);
            }
        }
        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);
        }
예제 #7
0
 public void Save()
 {
     try
     {
         if (!ValidateFields(pnlUpdate))
         {
             LocalUtils.ShowValidationFailedMessage(this);
         }
         else
         {
             var model = new ProductSaleModel();
             model.CustomerName    = txtCustomerName.Text;
             model.Date            = dtDate.Value;
             model.Discount        = LocalUtils.ConvertToDouble(txtDiscount.Text);
             model.IsBuyOneTakeOne = chkIsBuyOneTakeOne.Checked;
             model.Quantity        = LocalUtils.ConvertToDouble(txtQuantity.Text);
             model.UnitPrice       = LocalUtils.ConvertToDouble(txtUnitPrice.Text);
             model.OutletSaleName  = cboOutletSaleName.Text;
             model.ProductID       = int.Parse(((ItemX)cboProducts.SelectedItem).Value);
             // get id
             if (productSaleID != 0)
             {
                 Factories.CreateProductSale().Edit(productSaleID, model);
                 LocalUtils.ShowSaveMessage(this);
             }
             else
             {
                 Factories.CreateProductSale().Add(model);
                 productSaleID = model.ID;
                 LocalUtils.ShowSaveMessage(this);
             }
         }
     }
     catch (ApplicationException ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.Message);
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.ToString());
     }
 }
예제 #8
0
 private void SaveMainData()
 {
     try
     {
         if (!ValidateFields())
         {
             LocalUtils.ShowValidationFailedMessage(this);
         }
         else
         {
             // get id
             if (expenseID != 0)
             {
                 var model = new ExpenseModel();
                 model.Date          = dtDate.Value;
                 model.Particular    = txtParticulars.Text;
                 model.ExpenseTypeID = int.Parse(((ItemX)cboExpenseType.SelectedItem).Value);
                 model.UnitPrice     = double.Parse(txtUnitPrice.Text);
                 model.Quantity      = int.Parse(txtQuantity.Text);
                 mainLogic.Edit(expenseID, model);
                 LocalUtils.ShowSaveMessage(this);
             }
             else
             {
                 var model = new ExpenseModel();
                 model.Date          = dtDate.Value;
                 model.Particular    = txtParticulars.Text;
                 model.ExpenseTypeID = int.Parse(((ItemX)cboExpenseType.SelectedItem).Value);
                 model.UnitPrice     = double.Parse(txtUnitPrice.Text);
                 model.Quantity      = int.Parse(txtQuantity.Text);
                 mainLogic.Add(model);
                 expenseID = model.ID;
                 LocalUtils.ShowSaveMessage(this);
             }
         }
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.ToString());
     }
 }
예제 #9
0
 private void SaveProduct()
 {
     try
     {
         if (!ValidateFields(pageUpdateProduct))
         {
             LocalUtils.ShowValidationFailedMessage(this);
         }
         else
         {
             var model = new ProductModel();
             model.Name      = txtProductName.Text;
             model.UnitPrice = LocalUtils.ConvertToDouble(txtUnitPrice.Text);
             model.IsProduce = chkProduce.Checked;
             // get id
             if (productID != 0)
             {
                 Factories.CreateProduct().Edit(productID, model);
                 LoadProductsGridList();
                 LocalUtils.ShowSaveMessage(this);
             }
             else
             {
                 Factories.CreateProduct().Add(model);
                 productID = model.ID;
                 LoadProductsGridList();
                 LocalUtils.ShowSaveMessage(this);
             }
         }
     }
     catch (ApplicationException ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.Message);
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.ToString());
     }
 }
예제 #10
0
        public void Save()
        {
            try
            {
                if (!ValidateFields())
                {
                    LocalUtils.ShowValidationFailedMessage(this);
                }
                else
                {
                    var model = new DailySaleRecordModel();

                    model.Debtor         = txtDebtor.Text;
                    model.Date           = dtDate.Value;
                    model.ProcessingSale = LocalUtils.ConvertToDouble(txtProcessingSale.Text);
                    model.SaleOnAccount  = LocalUtils.ConvertToDouble(txtSalesOnAccount.Text);
                    // get id
                    if (dailySaleID != 0)
                    {
                        Factories.CreateDailySale().Edit(dailySaleID, model);
                        LocalUtils.ShowSaveMessage(this);
                    }
                    else
                    {
                        Factories.CreateDailySale().Add(model);
                        dailySaleID = model.ID;
                        LocalUtils.ShowSaveMessage(this);
                    }
                }
            }
            catch (ApplicationException ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.Message);
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.ToString());
            }
        }
예제 #11
0
 private void SaveProductRawMaterial()
 {
     try
     {
         if (!ValidateFields(pageUpdateProductRawMaterials))
         {
             LocalUtils.ShowValidationFailedMessage(this);
         }
         else
         {
             var model = new AddEditProductRawMaterialModel();
             model.ProductID    = productID;
             model.SupplyTypeID = int.Parse(((ItemX)cboSupplyTypes.SelectedItem).Value);
             model.Quantity     = LocalUtils.ConvertToDouble(txtQuantity.Text);
             // get id
             if (productRawMaterialID != 0)
             {
                 Factories.CreateProduct().EditProductRawMaterial(productRawMaterialID, model);
             }
             else
             {
                 Factories.CreateProduct().AddProductRawMaterial(model);
             }
             LoadProductRawMaterialGridList();
             LocalUtils.ShowSaveMessage(this);
         }
         page.SetPage(pageUpdateProduct);
     }
     catch (ApplicationException ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.Message);
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.ToString());
     }
 }