Esempio n. 1
0
        // Verify the data from excel file exists or not
        private string VerifyDuplicatedData(int iCount, DataRow row)
        {
            iCount = iCount + 1;
            StringBuilder returnResult   = new StringBuilder();
            StringBuilder verifiedResult = new StringBuilder();

            verifiedResult.Append("Row#").Append(iCount.ToString()).Append(":");

            int iLen = verifiedResult.ToString().Length;

            // Check whether the StockCode is duplicate or not
            //string sql = @"STKCODE = '" + Utility.VerifyQuotes(row[colSTKCode].ToString().Trim()) + "' AND APPENDIX1 = '" + Utility.VerifyQuotes(row[colAppendix1].ToString().Trim())
            //    + "' AND APPENDIX2 = '" + Utility.VerifyQuotes(row[colAppendix2].ToString().Trim()) + "' AND APPENDIX3 = '" + Utility.VerifyQuotes(row[colAppendix3].ToString().Trim()) + "'";

            //RT2020.DAL.Product oStockItem = RT2020.DAL.Product.LoadWhere(sql);
            //if (oStockItem != null)
            if (ProductHelper.IsDuplicated(
                    Utility.VerifyQuotes(row[colSTKCode].ToString().Trim()),
                    Utility.VerifyQuotes(row[colAppendix1].ToString().Trim()),
                    Utility.VerifyQuotes(row[colAppendix2].ToString().Trim()),
                    Utility.VerifyQuotes(row[colAppendix3].ToString().Trim())))
            {
                returnResult.Append("Duplicated Stock Code;");
            }

            // Appendix1
            //sql = "Appendix1Code = '" + Utility.VerifyQuotes(row[colAppendix1].ToString().Trim()) + "'";
            //ProductAppendix1 oApp1 = ProductAppendix1.LoadWhere(sql);
            //if (oApp1 != null)
            if (ProductAppendix1Ex.IsAppendixCodeInUse(Utility.VerifyQuotes(row[colAppendix3].ToString())))
            {
                verifiedResult.Append(colAppendix1).Append(";");
            }

            // Appendix2
            //sql = "Appednix2Code = '" + Utility.VerifyQuotes(row[colAppendix2].ToString().Trim()) + "'";
            //ProductAppendix2 oApp2 = ProductAppendix2.LoadWhere(sql);
            //if (oApp2 != null)
            if (ProductAppendix2Ex.IsAppendixCodeInUse(Utility.VerifyQuotes(row[colAppendix3].ToString())))
            {
                verifiedResult.Append(colAppendix2).Append(";");
            }

            // Appendix3
            //sql = "Appendix3Code = '" + Utility.VerifyQuotes(row[colAppendix3].ToString().Trim()) + "'";
            //ProductAppendix3 oApp3 = ProductAppendix3.LoadWhere(sql);
            //if (oApp3 != null)
            if (ProductAppendix3Ex.IsAppendixCodeInUse(Utility.VerifyQuotes(row[colAppendix3].ToString())))
            {
                verifiedResult.Append(colAppendix3).Append(";");
            }

            // Class1
            //sql = "Class1Code = '" + Utility.VerifyQuotes(row[colClass1].ToString().Trim()) + "'";
            //ProductClass1 oCls1 = ProductClass1.LoadWhere(sql);
            //if (oCls1 != null)
            if (ProductClass1Ex.IsClassCodeInUse(Utility.VerifyQuotes(row[colClass1].ToString().Trim())))
            {
                verifiedResult.Append(colClass1).Append(";");
            }

            // Class2
            //sql = "Class2Code = '" + Utility.VerifyQuotes(row[colClass2].ToString().Trim()) + "'";
            //ProductClass2 oCls2 = ProductClass2.LoadWhere(sql);
            //if (oCls2 != null)
            if (ProductClass2Ex.IsClassCodeInUse(Utility.VerifyQuotes(row[colClass2].ToString().Trim())))
            {
                verifiedResult.Append(colClass2).Append(";");
            }

            // Class3
            //sql = "Class3Code = '" + Utility.VerifyQuotes(row[colClass3].ToString().Trim()) + "'";
            //ProductClass3 oCls3 = ProductClass3.LoadWhere(sql);
            //if (oCls3 != null)
            if (ProductClass3Ex.IsClassCodeInUse(Utility.VerifyQuotes(row[colClass3].ToString().Trim())))
            {
                verifiedResult.Append(colClass3).Append(";");
            }

            // Class4
            //sql = "Class4Code = '" + Utility.VerifyQuotes(row[colClass4].ToString().Trim()) + "'";
            //ProductClass4 oCls4 = ProductClass4.LoadWhere(sql);
            //if (oCls4 != null)
            if (ProductClass4Ex.IsClassCodeInUse(Utility.VerifyQuotes(row[colClass4].ToString().Trim())))
            {
                verifiedResult.Append(colClass4).Append(";");
            }

            // Class5
            //sql = "Class5Code = '" + Utility.VerifyQuotes(row[colClass5].ToString().Trim()) + "'";
            //ProductClass5 oCls5 = ProductClass5.LoadWhere(sql);
            //if (oCls5 != null)
            if (ProductClass5Ex.IsClassCodeInUse(Utility.VerifyQuotes(row[colClass5].ToString().Trim())))
            {
                verifiedResult.Append(colClass5).Append(";");
            }

            // Class6
            //sql = "Class6Code = '" + Utility.VerifyQuotes(row[colClass6].ToString().Trim()) + "'";
            //ProductClass6 oCls6 = ProductClass6.LoadWhere(sql);
            //if (oCls6 != null)
            if (ProductClass6Ex.IsClassCodeInUse(Utility.VerifyQuotes(row[colClass6].ToString().Trim())))
            {
                verifiedResult.Append(colClass6).Append(";");
            }

            // Barcode
            var barcode = Utility.VerifyQuotes(row[colSTKCode].ToString().Trim()) + Utility.VerifyQuotes(row[colAppendix1].ToString().Trim()) + Utility.VerifyQuotes(row[colAppendix2].ToString().Trim()) + Utility.VerifyQuotes(row[colAppendix3].ToString().Trim());
            var sql     = "BARCODE = '" + barcode + "'";

            if (ProductBarcodeEx.IsBarcodeInUse(barcode))
            {
                returnResult.Append("Duplicated Barcode;");
            }

            if (verifiedResult.ToString().Length > iLen)
            {
                duplicatedRec.Add(verifiedResult.ToString());
            }

            return(returnResult.ToString());
        }
Esempio n. 2
0
        private void CheckBarcode()
        {
            int  barcodeLen = 22;
            bool isValid    = false;

            if (string.IsNullOrEmpty(txtBarcode.Text))
            {
                errorProvider.SetError(txtBarcode, "Can not be blank!");
            }
            else
            {
                if (txtBarcode.Text.Length > barcodeLen)
                {
                    errorProvider.SetError(txtBarcode, "Invalid Barcode Length!");
                }
                else if (cboBarcodeType.Text.Length == 0)
                {
                    errorProvider.SetError(cboBarcodeType, "Cannot be blank!");
                }
                else
                {
                    errorProvider.SetError(txtBarcode, string.Empty);
                    errorProvider.SetError(cboBarcodeType, string.Empty);
                    isValid = true;
                }
            }

            if (isValid)
            {
                string sql = "ProductId = '" + this.ProductId.ToString() + "' AND Barcode = '" + txtBarcode.Text.Trim() + "'";
                //ProductBarcode oBarcode = ProductBarcode.LoadWhere(sql);
                if (ProductBarcodeEx.IsBarcodeInUse(this.ProductId, txtBarcode.Text.Trim()))
                {
                    errorProvider.SetError(txtBarcode, "Barcode Already Exists");
                }
                else
                {
                    errorProvider.SetError(txtBarcode, string.Empty);
                }

                if (string.IsNullOrEmpty(errorProvider.GetError(txtBarcode)))
                {
                    //Verify type and check digit
                    switch (cboBarcodeType.SelectedItem.ToString())
                    {
                    case "INTERNAL (128B)":     // INTERNAL (128B)
                        txtBarcode.Text = Utility.VerifyQuotes(txtBarcode.Text);
                        if (txtBarcode.Text.Length > 22)
                        {
                            errorProvider.SetError(txtBarcode, "The length of Barcode(INTERNAL (128B)) must be <= 22!");
                        }
                        else
                        {
                            errorProvider.SetError(txtBarcode, string.Empty);
                        }
                        break;

                    case "EAN8":     // EAN8 (GTIN-8)
                        if (txtBarcode.Text.Length != 8)
                        {
                            errorProvider.SetError(txtBarcode, "The length of Barcode(EAN8) must be 8!");
                        }
                        else if (!VerifyBarcodeNumber(txtBarcode.Text))
                        {
                            errorProvider.SetError(txtBarcode, "Barcode(EAN8) must be Numeric Only!");
                        }
                        else if (!VerifyBarcodeCheckDigit(txtBarcode.Text))
                        {
                            errorProvider.SetError(txtBarcode, "The Check Digit of Barcode(EAN8) is Not Valid!");
                        }
                        else
                        {
                            errorProvider.SetError(txtBarcode, string.Empty);
                        }
                        break;

                    case "EAN13":     // EAN13 (GTIN-13)
                        if (txtBarcode.Text.Length != 13)
                        {
                            errorProvider.SetError(txtBarcode, "The length of Barcode(EAN13) must be 13!");
                        }
                        else if (!VerifyBarcodeNumber(txtBarcode.Text))
                        {
                            errorProvider.SetError(txtBarcode, "Barcode(EAN13) must be Numeric Only!");
                        }
                        else if (!VerifyBarcodeCheckDigit(txtBarcode.Text))
                        {
                            errorProvider.SetError(txtBarcode, "The Check Digit of Barcode(EAN13) is Not Valid!");
                        }
                        else
                        {
                            errorProvider.SetError(txtBarcode, string.Empty);
                        }
                        break;

                    case "UPC12":     // UPC12 (GTIN-12)
                        if (txtBarcode.Text.Length != 12)
                        {
                            errorProvider.SetError(txtBarcode, "The length of Barcode(UPC12) must be 12!");
                        }
                        else if (!VerifyBarcodeNumber(txtBarcode.Text))
                        {
                            errorProvider.SetError(txtBarcode, "Barcode(UPC12) must be Numeric Only!");
                        }
                        else if (!VerifyBarcodeCheckDigit(txtBarcode.Text))
                        {
                            errorProvider.SetError(txtBarcode, "The Check Digit of Barcode(UPC12) is Not Valid!");
                        }
                        else
                        {
                            errorProvider.SetError(txtBarcode, string.Empty);
                        }
                        break;
                    }
                }
            }
        }