Beispiel #1
0
        private void btn_Save_Click(object sender, RoutedEventArgs e)
        {
            if (productCode != 0)
            {
                int currentStock = OpeningStockController.GetCurrentStockByProductCode(productCode);
                if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(txtQuantity.Text) || string.IsNullOrEmpty(txtDate.Text))
                {
                    //  msg = "Fill all required fields";
                    ConfirmationPopup form = new ConfirmationPopup((string)Application.Current.Resources["error_message_Tax"], header, false);
                    form.ShowDialog();
                    // Common.ErrorNotification((string)Application.Current.Resources["error_message_Tax"], header, false);
                }
                else if (Convert.ToInt64(txtQuantity.Text) < 1)
                {
                    ConfirmationPopup form = new ConfirmationPopup((string)Application.Current.Resources["wastage_popupquantityerrormsgForZeroQuantity"], header, false);
                    form.ShowDialog();
                    //  Common.ErrorNotification((string)Application.Current.Resources["wastage_popupquantityerrormsg"], header, false);

                    //txtQuantity.Text = string.Empty;
                }
                else if (Convert.ToInt64(txtQuantity.Text) > currentStock)
                {
                    ConfirmationPopup form = new ConfirmationPopup((string)Application.Current.Resources["wastage_popupquantityerrormsg"], header, false);
                    form.ShowDialog();
                    //  Common.ErrorNotification((string)Application.Current.Resources["wastage_popupquantityerrormsg"], header, false);
                }
                else
                {
                    try
                    {
                        WastageModel wastageModel = new WastageModel(RowId, productCode, txtName.Text, Convert.ToInt32(txtQuantity.Text), txtDate.Text, txt_Reason.Text, txtBatchNo.Text, UserModelVm.BranchId, UserModelVm.CompanyId);
                        controller.SaveUpdateWastage(wastageModel);
                        Common.Notification((string)Application.Current.Resources["wastage_UpdatedSuccessMsg"], header, false);
                        ClearFields();
                        GoToBackPage();
                    }
                    catch (Exception ex)
                    {
                        ConfirmationPopup form = new ConfirmationPopup(ex.Message, header, false);
                        form.ShowDialog();
                        // Common.ErrorNotification(ex.Message, header, false);
                    }
                }
            }
            else
            {
                Common.ErrorMessage((string)Application.Current.Resources["errorInvalidProductSelection"], header);
            }
        }
 public void SaveUpdateWastage(WastageModel model)
 {
     try
     {
         objProductService.ProductServiceInstance().SaveUpdateWastage(model);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         objProductService.ProductServiceInstanceClosed();
     }
 }
Beispiel #3
0
 private void btn_Save_Click(object sender, RoutedEventArgs e)
 {
     if (productCode != 0)
     {
         if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(txtQuantity.Text) || string.IsNullOrEmpty(txtDate.Text) || string.IsNullOrEmpty(txt_Reason.Text))
         {
             Common.ErrorMessage((string)Application.Current.Resources["wastage_popupquantityerrormsgRequiredFields"], header);
         }
         else if (Convert.ToInt64(txtQuantity.Text) < 1)
         {
             Common.ErrorMessage((string)Application.Current.Resources["wastage_popupquantityerrormsgForZeroQuantity"], header);
         }
         else if (Convert.ToInt64(txtQuantity.Text) > OpeningStockController.GetCurrentStockByProductCode(Convert.ToInt64(productCode)))
         {
             Common.ErrorMessage((string)Application.Current.Resources["wastage_popupquantityerrormsg"], header);
             txtQuantity.Text = string.Empty;
         }
         else
         {
             try
             {
                 #region Save
                 ProductController controller = new ProductController();
                 WastageModel      model      = new WastageModel(0, productCode, txtName.Text, Convert.ToInt32(txtQuantity.Text), txtDate.Text, txt_Reason.Text, txtBatchNo.Text, UserModelVm.BranchId, UserModelVm.CompanyId);
                 controller.SaveUpdateWastage(model);
                 Common.Notification((string)Application.Current.Resources["wastage_SavedSuccessMsg"], header, false);
                 ClearFields();
                 NavigateToParent();
                 #endregion
             }
             catch (Exception ex)
             {
                 Common.ErrorMessage(ex.Message, header);
             }
         }
     }
     else
     {
         Common.ErrorMessage((string)Application.Current.Resources["errorInvalidProductSelection"], header);
     }
 }
Beispiel #4
0
 public void SaveUpdateWastage(WastageModel model)
 {
     try
     {
         Wastage wastage;
         if (model.WastageId > 0)
         {
             wastage              = _productRepository.GetWastage().FirstOrDefault(x => x.Id == model.WastageId);
             wastage.ModifiedBy   = 1;
             wastage.ModifiedDate = CommonFunctions.ParseDateToFinclaveString(DateTime.Now.ToShortDateString());
         }
         else
         {
             wastage             = new Wastage();
             wastage.Id          = model.WastageId;
             wastage.ItemCode    = model.ItemCode;
             wastage.ProductName = model.ProductName;
             wastage.CreatedDate = model.Date;
             wastage.CreatedBy   = 1;
         }
         wastage.Id          = model.WastageId;
         wastage.ItemCode    = model.ItemCode;
         wastage.ProductName = model.ProductName;
         wastage.CreatedDate = model.Date;
         wastage.Quantity    = model.Quantity;
         wastage.Reason      = model.Reason;
         wastage.BatchNo     = model.BatchNo;
         wastage.BranchCode  = model.BranchCode;
         wastage.CompanyCode = model.CompanyCode;
         _productRepository.SaveUpdateWastage(wastage);
     }
     catch (Exception ex)
     {
         fault.Result       = false;
         fault.ErrorMessage = "Error During Save Or Update Wastage";
         fault.ErrorDetails = ex.ToString();
         throw new FaultException <FaultData>(fault);
     }
 }