Beispiel #1
0
        private void FillParentAppendixList()
        {
            string sql;

            string[] orderBy;

            switch (_AppendixMode)
            {
            case ProductHelper.Appendix.Appendix1:
                sql     = "Appendix1Id NOT IN ('" + _AppendixId.ToString() + "')";
                orderBy = new string[] { "Appendix1Code" };
                ProductAppendix1Ex.LoadCombo(ref cboParentAppendix, "Appendix1Code", true, true, "", sql, orderBy);
                break;

            case ProductHelper.Appendix.Appendix2:
                sql     = "Appendix1Id NOT IN ('" + this.AppendixId.ToString() + "')";
                orderBy = new string[] { "Appendix1Code" };
                ProductAppendix1Ex.LoadCombo(ref cboParentAppendix, "Appendix1Code", true, true, "", sql, orderBy);
                break;

            case ProductHelper.Appendix.Appendix3:
                sql     = "Appendix3Id NOT IN ('" + this.AppendixId.ToString() + "')";
                orderBy = new string[] { "Appendix3Code" };
                ProductAppendix3Ex.LoadCombo(ref cboParentAppendix, "Appendix3Code", true, true, "", sql, orderBy);
                break;
            }

            cboParentAppendix.SelectedIndex = cboParentAppendix.Items.Count - 1;
        }
Beispiel #2
0
        private bool IsValid()
        {
            bool result = true;

            errorProvider.SetError(txtCode, string.Empty);

            #region Class Code 唔可以吉
            if (txtCode.Text.Length == 0)
            {
                errorProvider.SetError(txtCode, "Cannot be blank!");
                errorProvider.SetIconAlignment(txtCode, ErrorIconAlignment.TopLeft);
                result = false;
            }
            #endregion

            #region 新增,要 check Tag Code 係咪 in use
            if (_AppendixId == Guid.Empty)
            {
                switch (_AppendixType)
                {
                case ProductHelper.Appendix.Appendix1:
                    #region ProductAppendix1
                    if (ProductAppendix1Ex.IsAppendixCodeInUse(txtCode.Text.Trim()))
                    {
                        errorProvider.SetError(txtCode, "Class Code in use");
                        errorProvider.SetIconAlignment(txtCode, ErrorIconAlignment.TopLeft);
                        result = false;
                    }
                    break;

                    #endregion
                case ProductHelper.Appendix.Appendix2:
                    #region ProductAppendix2
                    if (ProductAppendix2Ex.IsAppendixCodeInUse(txtCode.Text.Trim()))
                    {
                        errorProvider.SetError(txtCode, "Class Code in use");
                        errorProvider.SetIconAlignment(txtCode, ErrorIconAlignment.TopLeft);
                        result = false;
                    }
                    break;

                    #endregion
                case ProductHelper.Appendix.Appendix3:
                    #region ProductAppendix3
                    if (ProductAppendix3Ex.IsAppendixCodeInUse(txtCode.Text.Trim()))
                    {
                        errorProvider.SetError(txtCode, "Class Code in use");
                        errorProvider.SetIconAlignment(txtCode, ErrorIconAlignment.TopLeft);
                        result = false;
                    }
                    break;
                    #endregion
                }
            }
            #endregion

            return(result);
        }
Beispiel #3
0
        private void AddToList(ref ListView oList, string a1, string a2, string a3)
        {
            ListViewItem objItem = oList.Items.Add((oList.Items.Count + 1).ToString());

            objItem.SubItems.Add(a1);
            objItem.SubItems.Add(a2);
            objItem.SubItems.Add(a3);
            objItem.SubItems.Add(ProductAppendix1Ex.GetIdByInitial(a1).ToString());
            objItem.SubItems.Add(ProductAppendix2Ex.GetIdByInitial(a2).ToString());
            objItem.SubItems.Add(ProductAppendix3Ex.GetIdByInitial(a3).ToString());
        }
        private void FillAppendixe3()
        {
            string[] orderBy = new string[] { "Appendix3Code" };
            ProductAppendix3Ex.LoadCombo(ref cboAppendix3, "Appendix3Code", false, true, "", "", orderBy);

            /**
             * cboAppendix3.Items.Clear();
             *
             * string[] orderBy = new string[] { "Appendix3Code" };
             * ProductAppendix3Collection oA3List = ProductAppendix3.LoadCollection(orderBy, true);
             * oA3List.Add(new ProductAppendix3());
             * cboAppendix3.DataSource = oA3List;
             * cboAppendix3.DisplayMember = "Appendix3Code";
             * cboAppendix3.ValueMember = "Appendix3Id";
             */
            //cboAppendix3.SelectedIndex = cboAppendix3.Items.Count - 1;
        }
Beispiel #5
0
        private void Delete()
        {
            bool result = false;

            switch (_AppendixType)
            {
            case ProductHelper.Appendix.Appendix1:
                result = ProductAppendix1Ex.Delete(_AppendixId);
                break;

            case ProductHelper.Appendix.Appendix2:
                result = ProductAppendix2Ex.Delete(_AppendixId);
                break;

            case ProductHelper.Appendix.Appendix3:
                result = ProductAppendix3Ex.Delete(_AppendixId);
                break;
            }
            MessageBox.Show(result ? "Record Removed" : "Can't Delete Record...", "Delete Result");
        }
Beispiel #6
0
        private void FillComboBox()
        {
            string textField = this.AppendixType.Trim() + "Code";

            switch (this.AppendixType.Trim().ToUpper())
            {
            case "APPENDIX1":
                ProductAppendix1Ex.LoadCombo(ref cmbFrom, textField, false);
                ProductAppendix1Ex.LoadCombo(ref cmbTo, textField, false);
                break;

            case "APPENDIX2":
                ProductAppendix2Ex.LoadCombo(ref cmbFrom, textField, false);
                ProductAppendix2Ex.LoadCombo(ref cmbTo, textField, false);
                break;

            case "APPENDIX3":
                ProductAppendix3Ex.LoadCombo(ref cmbFrom, textField, false);
                ProductAppendix3Ex.LoadCombo(ref cmbTo, textField, false);
                break;
            }

            cmbTo.SelectedIndex = cmbTo.Items.Count - 1;
        }
        // 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());
        }