Exemplo n.º 1
0
        private void btnAddArticle_Click(object sender, EventArgs e)
        {
            try
            {
                bool isValid = true;
                if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref Itemerrorprovider, ref cmbStockOutReason, "Stock Out Reason required"))
                {
                    this.cmbStockOutReason.Focus();
                    isValid = false;
                }
                if ((string)cmbStockOutReason.SelectedValue == "SupplierReturn" || (string)cmbStockOutReason.SelectedValue == "WriteOff")
                {
                    if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref Itemerrorprovider, ref cmbFromLocation, "From Location Reason required"))
                    {
                        this.cmbFromLocation.Focus();
                        isValid = false;
                    }
                }

                if (!isValid)
                {
                    return;
                }
                string supplierCode = "";
                if (cmbSupplierName.SelectedValue != null)
                {
                    supplierCode = (cmbSupplierName.SelectedValue != "Select") ? cmbSupplierName.SelectedValue.ToString() : string.Empty;
                }
                var articleList = this.articleManager.GetArticlePurchaseList(supplierCode);



                frmCommonSearchTrueGrid objSearch = new frmCommonSearchTrueGrid(multipleSelect: true, defaultFilter: false);
                DataTable dtItems = CommonFunc.ConvertListToDataTable(articleList);

                objSearch.Text           = "Item Search";
                objSearch.boolWildSearch = true;
                objSearch.dtcommonSearch = dtItems;
                DataTable dtSelectedItems = new DataTable();

                if (objSearch.ShowDialog() == DialogResult.OK)
                {
                    dtSelectedItems = objSearch.dtSelectedList;
                    //  List<ArticlePurchaseModel> selectedIArticleList = DataTableToList.ConvertDataTableToList<ArticlePurchaseModel>(dtSelectedItems);
                    List <ArticlePurchaseStockoutModel> selectedIArticleList = DataTableToList.ToList <ArticlePurchaseStockoutModel>(dtSelectedItems);

                    AddSelectedArticlesIntoGrid(selectedIArticleList);
                }
                objSearch.Dispose();
            }
            catch (Exception ex)
            {
                CommonFunc.ShowMessage(ex.Message, MessageType.Information);
                Logger.Log(ex.Message, Logger.LogingLevel.Error);
            }
        }
Exemplo 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;
            }
        }
Exemplo n.º 3
0
        private bool IsFormvalidate()
        {
            try
            {
                bool isValid         = true;
                bool isTenderChecked = false;
                // Regex patt = new Regex("^[A-Za-z0-9]+$");
                Regex alphanumericpatt = new Regex("^[A-Za-z0-9!@#$%&*()-{}.,/ ]+$");
                if (string.IsNullOrEmpty(txtTenderCode.Text.Trim()))
                {
                    if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtTenderCode, "Tender Code required"))
                    {
                        this.txtTenderCode.Focus();
                        isValid = false;
                    }
                }
                else
                {
                    if (alphanumericpatt.IsMatch(txtTenderCode.Text) == false)
                    {
                        isValid = false;
                        if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTenderCode, "Tender Code allows Alphanumeric Character", false))
                        {
                            this.txtTenderCode.Focus();
                        }
                    }
                    else
                    {
                        isTenderChecked = true;
                        errorProvider.SetError(txtTenderCode, string.Empty);
                        txtTenderCode.BorderColor = CommonFunc.DefaultBorderColor;
                    }
                }
                if (string.IsNullOrEmpty(txtTenderName.Text.Trim()))
                {
                    if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtTenderName, "Tender Name required"))
                    {
                        this.txtTenderName.Focus();
                        isValid = false;
                    }
                }
                else
                {
                    if (alphanumericpatt.IsMatch(txtTenderName.Text) == false)
                    {
                        isValid = false;
                        if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTenderName, "Tender Name allows Alphanumeric Character", false))
                        {
                            this.txtTenderName.Focus();
                        }
                    }
                    else
                    {
                        errorProvider.SetError(txtTenderName, string.Empty);
                        txtTenderName.BorderColor = CommonFunc.DefaultBorderColor;
                    }
                }
                if (cboTenderType.SelectedIndex == -1 || cboTenderType.SelectedValue == null)
                {
                    if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref errorProvider, ref cboTenderType, "Select Tender Type"))
                    {
                        this.cboTenderType.Focus();
                        isValid = false;
                    }
                }
                else
                {
                    errorProvider.SetError(cboTenderType, string.Empty);
                    cboTenderType.BackColor = CommonFunc.DefaultBorderColor;
                    if (cboTenderType.SelectedValue.ToString() == "CreditVouc(I)" || cboTenderType.SelectedValue.ToString() == "GiftVoucher(R)" || cboTenderType.SelectedValue.ToString() == "CLPPoint")
                    {
                        if (cboProgramCode.SelectedIndex == -1 || cboProgramCode.SelectedValue == null)
                        {
                            if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref errorProvider, ref cboProgramCode, "Select Program Code"))
                            {
                                this.cboProgramCode.Focus();
                                isValid = false;
                            }
                        }
                        else
                        {
                            errorProvider.SetError(cboProgramCode, string.Empty);
                            cboProgramCode.BackColor = CommonFunc.DefaultBorderColor;
                        }
                    }
                    else
                    {
                        errorProvider.SetError(cboProgramCode, string.Empty);
                        cboProgramCode.BackColor = CommonFunc.DefaultBorderColor;
                    }
                }


                if (!string.IsNullOrEmpty(txtTenderCode.Text.Trim()) && isTenderChecked == true)
                {
                    var tenderDetails = this.tenderManager.GetTenderByID(txtTenderCode.Text.Trim());
                    if (tenderDetails != null)
                    {
                        isValid = false;
                        if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTenderCode, "Tender Code Already Exists For this Site", false))
                        {
                            this.txtTenderCode.Focus();
                        }
                    }
                    else
                    {
                        errorProvider.SetError(txtTenderCode, string.Empty);
                        txtTenderCode.BorderColor = CommonFunc.DefaultBorderColor;
                    }
                }

                if (isTenderChecked == false)
                {
                    txtTenderCode.Focus();
                }

                return(isValid);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }