예제 #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();
        }
        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;
            }
        }
        private void LoadLabelFormatsList()
        {
            ExtraSytelineTablesSettings objExtraSytelineTableSettings;
            DataTable      objDataTable = new DataTable();
            SqlDataAdapter objDataAdapter;
            SqlCommand     objSQLCommand;

            WTFClassLibrary.Label objLabel;
            string strSQL;
            long   lngTemp;
            int    intTemp;


            objExtraSytelineTableSettings = new ExtraSytelineTablesSettings();

            strSQL = QueryDefinitions.GetQuery("SelectCustomerLabels", new string[] { mintCustomerNumber.ToString() });
            objExtraSytelineTableSettings.SQLConnection.Open();
            objSQLCommand             = objExtraSytelineTableSettings.SQLConnection.CreateCommand();
            objSQLCommand.CommandText = strSQL;
            objDataAdapter            = new SqlDataAdapter(objSQLCommand);
            objDataAdapter.Fill(objDataTable);

            cboLabels.Items.Clear();

            objLabel             = new WTFClassLibrary.Label();
            objLabel.Description = "--- Select Label Format ---";

            cboLabels.Items.Add(objLabel);

            foreach (DataRow objRow in objDataTable.Rows)
            {
                objLabel = new WTFClassLibrary.Label();

                if (long.TryParse(objRow["CustomerLabelID"].ToString(), out lngTemp))
                {
                    objLabel.CustomerLabelID = lngTemp;
                }
                else
                {
                    objLabel.CustomerLabelID = 0;
                }

                if (int.TryParse(objRow["AddrLineCt"].ToString(), out intTemp))
                {
                    objLabel.AddressLineCount = intTemp;
                }
                else
                {
                    objLabel.AddressLineCount = 0;
                }

                objLabel.Description    = objRow["Description"].ToString();
                objLabel.LabelFile      = objRow["LabelFile"].ToString();
                objLabel.SupplierNumber = objRow["SupplierNumber"].ToString();

                if (long.TryParse(objRow["Sequence"].ToString(), out lngTemp))
                {
                    objLabel.Sequence = lngTemp;
                }
                else
                {
                    objLabel.Sequence = 0;
                }

                cboLabels.Items.Add(objLabel);
            }

            cboLabels.SelectedIndex = 0;
        }