Esempio n. 1
0
        private void ResetArticleStockOutData()
        {
            try
            {
                grpFilters.Enabled = true;
                cmbStockOutReason.SelectedIndex = 0;

                cmbSupplierName.SelectedIndex = 0;
                cmbSupplierName.Enabled       = true;

                cmbFromLocation.SelectedIndex = 0;
                cmbFromLocation.Enabled       = true;

                txtRemark.Value            = string.Empty;
                txtRemark.MaxLength        = 100;
                ArticleStockList           = new List <ArticlePurchaseStockoutModel>();
                gridScanArticle.DataSource = ArticleStockList;
                DefaultGridSetting();
                //remove error indicator
                Itemerrorprovider.SetError(txtRemark, string.Empty);
                txtRemark.BorderColor = CommonFunc.DefaultBorderColor;
                Itemerrorprovider.SetError(cmbFromLocation, string.Empty);
                cmbFromLocation.BackColor = CommonFunc.DefaultBorderColor;
            }
            catch (Exception ex)
            {
                Logger.Log(ex, Logger.LogingLevel.Error);
                throw ex;
            }
        }
Esempio n. 2
0
        private bool ValidateArticleStock()
        {
            try
            {
                bool   valfields = true, valAdjQuantity = true, valAdjNegativeQuantity = true;
                int    ValidReasonLengthCounter = 0;
                int    ValidReasonTextCounter = 0;
                string a    = (string)cmbStockOutReason.SelectedValue;
                Regex  patt = new Regex("^[A-Za-z0-9!@#$%&*()-{}.,/ ]+$");


                if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref Itemerrorprovider, ref cmbStockOutReason, "Stock Out Reason required"))
                {
                    this.cmbStockOutReason.Focus();
                    valfields = false;
                }

                if ((string)cmbStockOutReason.SelectedValue == "SupplierReturn" || (string)cmbStockOutReason.SelectedValue == "WriteOff")
                {
                    if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref Itemerrorprovider, ref cmbFromLocation, "From Location Reason required"))
                    {
                        this.cmbFromLocation.Focus();
                        valfields = false;
                    }
                    else
                    {
                        Itemerrorprovider.SetError(cmbFromLocation, string.Empty);
                        cmbFromLocation.BackColor = CommonFunc.DefaultBorderColor;
                    }
                }
                if (!string.IsNullOrEmpty(txtRemark.Text.Trim()))
                {
                    if (patt.IsMatch(txtRemark.Text) == false)
                    {
                        valfields = false;
                        if (!CommonFunc.SetCustomErrorProvidertoControl(ref Itemerrorprovider, ref txtRemark, "Remark Allows Alphanumeric Character", false))
                        {
                            this.txtRemark.Focus();
                        }
                    }
                    else
                    {
                        Itemerrorprovider.SetError(txtRemark, string.Empty);
                        txtRemark.BorderColor = CommonFunc.DefaultBorderColor;
                    }
                }
                int rowcount = gridScanArticle.Rows.Count;
                if (rowcount > 1)
                {
                    for (int rowIndex = 1; rowIndex < gridScanArticle.Rows.Count; rowIndex++)
                    {
                        Int64 intavailqty = Convert.ToInt64(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.AvailableQty]);
                        Int64 LookupValue;
                        bool  LookupValueIsANumber = Int64.TryParse(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.AdjustmentQty].ToString(), out LookupValue);

                        if (LookupValueIsANumber == false)
                        {
                            CommonFunc.ShowMessage("Please Enter Proper Adjustment quantity", Models.Enums.MessageType.Information);
                            gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.AdjustmentQty] = 0;
                            return(false);
                        }
                        Int64  intadjustqty = Convert.ToInt64(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.AdjustmentQty]);
                        string reason       = Convert.ToString(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.Reason]);
                        if (intadjustqty > 0 && intadjustqty > intavailqty)
                        {
                            valAdjQuantity = false;
                        }
                        else if (intadjustqty <= 0)
                        {
                            valAdjNegativeQuantity = false;
                        }
                        if (reason.Trim() != "" && reason.Trim().Length > 30)
                        {
                            ValidReasonLengthCounter = ValidReasonLengthCounter + 1;
                        }
                        else if (reason.Trim() != "" && patt.IsMatch(reason.Trim()) == false)
                        {
                            ValidReasonTextCounter = ValidReasonTextCounter + 1;
                        }
                    }
                }
                else
                {
                    if (valfields)
                    {
                        CommonFunc.ShowMessage("Please add Item", MessageType.Information);
                        valfields = false;
                        return(valfields);
                    }
                }
                if (!valAdjQuantity)
                {
                    CommonFunc.ShowMessage("Adjustment quantity must be less than Available quantity", Models.Enums.MessageType.Information);
                    return(false);
                }
                if (!valAdjNegativeQuantity)
                {
                    CommonFunc.ShowMessage("Adjustment quantity must be greater than Zero(0)", Models.Enums.MessageType.Information);
                    return(false);
                }
                if (ValidReasonLengthCounter > 0)
                {
                    CommonFunc.ShowMessage("Reason allows 30 characters only", Models.Enums.MessageType.Information);
                    return(false);
                }
                if (ValidReasonTextCounter > 0)
                {
                    CommonFunc.ShowMessage("Reason allows alphnumeric characters only", Models.Enums.MessageType.Information);
                    return(false);
                }
                return(valfields);
            }
            catch (Exception ex)
            {
                Logger.Log(ex, Logger.LogingLevel.Error);
                throw ex;
            }
        }