Ejemplo n.º 1
0
        private void GetItems()
        {
            SL8_WTF_DataBaseSettings objSL8_WTF_DataBaseSettings;
            DataTable      objDataTable = new DataTable();
            SqlDataAdapter objDataAdapter;
            SqlCommand     objSQLCommand;
            Item           objItem;
            string         strSQL;
            double         dblTemp;
            Match          objMFGMatch, objDashIntMatch;


            Cursor.Current   = Cursors.WaitCursor;
            dgvItems.Visible = false;

            objSL8_WTF_DataBaseSettings = new SL8_WTF_DataBaseSettings();
            strSQL = QueryDefinitions.GetQuery("SelectTopNItems", new string[] { MINTMAXRECORDCOUNT.ToString(),
                                                                                 ((ComboBoxItem)cboSortSearch.SelectedItem).Value, txtItem.Text, ((ComboBoxItem)cboSortSearch.SelectedItem).Value });
            objSL8_WTF_DataBaseSettings.SQLConnection.Open();
            objSQLCommand  = new SqlCommand(strSQL, objSL8_WTF_DataBaseSettings.SQLConnection);
            objDataAdapter = new SqlDataAdapter(objSQLCommand);
            objDataAdapter.Fill(objDataTable);

            mobjItemList = new SortableSearchableBindingList <Item>();

            if (objDataTable.Rows.Count > 0)
            {
                foreach (DataRow objRow in objDataTable.Rows)
                {
                    objItem = new Item();

                    objItem.ItemID      = objRow["Item"].ToString();
                    objItem.Description = objRow["Description"].ToString();
                    objItem.Revision    = objRow["revision"].ToString();
                    objItem.QtyOnHand   = double.TryParse(objRow["qty_on_hand"].ToString(), out dblTemp) ? dblTemp : 0.0;

                    objMFGMatch     = Regex.Match(objItem.ItemID, @"-MFG\Z", RegexOptions.IgnoreCase);
                    objDashIntMatch = Regex.Match(objItem.ItemID, @"-[0-9]\Z", RegexOptions.IgnoreCase);
                    //objItem.IsMFG = objRow["Item"].ToString().ToUpper().EndsWith("MFG");
                    objItem.IsSubItem = objMFGMatch.Success || objDashIntMatch.Success;//Implemented so isMFG functionality could be utilized for -1, -2, etc items


                    mobjItemList.Add(objItem);
                }
            }
            else
            {
                MessageBox.Show(((ComboBoxItem)cboSortSearch.SelectedItem).Text + " " + txtItem.Text + " not found!", "No Item Found", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }

            Cursor.Current      = Cursors.Default;
            dgvItems.Visible    = true;
            dgvItems.DataSource = mobjItemList;
            dgvItems.Refresh();
        }
Ejemplo n.º 2
0
        private void LoadCustomerAddresses()
        {
            SL8_WTF_DataBaseSettings objSL8_WTF_DataBaseSettings;
            DataTable       objDataTable = new DataTable();
            SqlDataAdapter  objDataAdapter;
            SqlCommand      objSQLCommand;
            CustomerAddress objCustomerAddress;
            string          strSQL;


            objSL8_WTF_DataBaseSettings = new SL8_WTF_DataBaseSettings();
            strSQL = QueryDefinitions.GetQuery("SelectCustomerAddresses", new string[] { mintCustomerNumber.ToString() });
            objSL8_WTF_DataBaseSettings.SQLConnection.Open();
            objSQLCommand  = new SqlCommand(strSQL, objSL8_WTF_DataBaseSettings.SQLConnection);
            objDataAdapter = new SqlDataAdapter(objSQLCommand);
            objDataAdapter.Fill(objDataTable);

            mobjCustomerAddressList = new BindingList <CustomerAddress>();

            foreach (DataRow objRow in objDataTable.Rows)
            {
                objCustomerAddress = new CustomerAddress();

                objCustomerAddress.Name         = objRow["Name"].ToString();
                objCustomerAddress.AddressLine1 = objRow["Addr##1"].ToString();
                objCustomerAddress.AddressLine2 = objRow["Addr##2"].ToString();
                objCustomerAddress.AddressLine3 = objRow["Addr##3"].ToString();
                objCustomerAddress.AddressLine4 = objRow["Addr##4"].ToString();
                objCustomerAddress.City         = objRow["City"].ToString();
                objCustomerAddress.State        = objRow["State"].ToString();
                objCustomerAddress.ZipCode      = objRow["ZIP"].ToString();
                objCustomerAddress.Country      = objRow["Country"].ToString();

                mobjCustomerAddressList.Add(objCustomerAddress);
            }

            mintSelectedAddressIndex = -1;

            if (objDataTable.Rows.Count > 0)
            {
                SelectCustomerAddress(0);
                grpAddress.Enabled = (mobjSelectedLabel.AddressLineCount > 0);
            }
            else
            {
                MessageBox.Show("No addresses found for customer!", "No Addresses Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                lblAddrCt.Text     = "";
                grpAddress.Enabled = false;
            }
        }