Exemple #1
0
        public Object[] GetCustomerWithAbbreviationOrBarcodeId(string abbreviationId, string barcodeId)
        {
            Object[]              custObjects = new Object[2];
            CustomerObject        customerO   = new CustomerObject();
            BarcodeCustomerObject barcodeCust = new BarcodeCustomerObject();

            // find customer in SINGULAR's tables...
            customerO = this.GetCustomerWithAbbreviation(abbreviationId);
            if (customerO.Name == null && barcodeId.Equals(""))
            {
                return(null);
            }
            custObjects[1] = customerO;

            String SQLQuery = "SELECT * FROM " + Properties.Resources.BarcodeCustomersTable;

            if (abbreviationId.Equals("") && !barcodeId.Equals(""))
            {
                SQLQuery += " WHERE BARCODEID = '" + barcodeId + "'";
            }
            if (!abbreviationId.Equals("") && barcodeId.Equals(""))
            {
                SQLQuery += " WHERE ABBREVIATION = '" + abbreviationId + "'";
            }
            if (!abbreviationId.Equals("") && !barcodeId.Equals(""))
            {
                SQLQuery += " WHERE ABBREVIATION = '" + abbreviationId + "' AND BARCODEID = '" + barcodeId + "'";
            }

            DataTable DBTable = this.RefreshSQLConnection(SQLQuery, Properties.Resources.BarcodeCustomersTable);

            // there is no customer in barcodecust table...
            if (DBTable == null)
            {
                custObjects[0] = null;
                return(custObjects);
            }

            if (DBTable.Rows.Count > 0)
            {
                barcodeCust.AbbreviationId = DBTable.Rows[0]["ABBREVIATION"].ToString();
                barcodeCust.BarcodeId      = DBTable.Rows[0]["BARCODEID"].ToString();
                barcodeCust.OfferId        = Convert.ToInt32(DBTable.Rows[0]["OFFERID"].ToString());
                barcodeCust.DateRegistered = Convert.ToDateTime(DBTable.Rows[0]["DATEREGISTERED"].ToString());

                custObjects[0] = barcodeCust;
                custObjects[1] = customerO;

                DBTable.Clear();
            }

            return(custObjects);
        }
Exemple #2
0
        private CustomerObject GetCustomerWithAbbreviation(string abbreviationId)
        {
            CustomerObject customerO = new CustomerObject();

            String SQLQuery = "SELECT ID, NAME FROM " + Properties.Resources.CustomersTable +
                              " WHERE ABBREVIATION = '" + abbreviationId + "'";
            DataTable DBTable = this.RefreshSQLConnection(SQLQuery, Properties.Resources.CustomersTable);

            if (DBTable == null)
            {
                return(customerO);
            }

            if (DBTable.Rows.Count > 0)
            {
                // find customer
                customerO.Name = DBTable.Rows[0]["NAME"].ToString();

                // find license plates
                String SQLQueryL = "SELECT NAME FROM " + Properties.Resources.LicensePlatesTable +
                                   " WHERE CUAID = '" + DBTable.Rows[0]["ID"] + "'";
                DataTable DBTableL = this.RefreshLicensePlatesSQLConnection(SQLQueryL, Properties.Resources.LicensePlatesTable);

                if (DBTableL.Rows.Count > 0)
                {
                    customerO.LicensePlates = new String[DBTableL.Rows.Count];
                    int i = 0;
                    foreach (DataRow row in DBTableL.Rows)
                    {
                        customerO.LicensePlates[i] = row["NAME"].ToString();
                        i++;
                    }
                }

                DBTable.Clear();
                DBTableL.Clear();
            }

            return(customerO);
        }