コード例 #1
0
        public SearchCustomerTrans()
        {
            InitializeComponent();
            SqlCustomerTransRepository sqlCustomerTransRepository = new SqlCustomerTransRepository();
            listCustomerTrans = sqlCustomerTransRepository.ListCustomerTrans();

            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
            {
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            

            CustomerTransGridView.DataSource = listCustomerTrans;

            sqlCustomerTransRepository = null;
        }
コード例 #2
0
        public void LoadData()
        {
            sqlCustomerTransRepository = new SqlCustomerTransRepository();
            listCustomerTrans = null;

            string searchValue = radTextBoxElementSearchWord.Text;
            string searchKey = radComboBoxElement.Text;

            listCustomerTrans = sqlCustomerTransRepository.ListCustomerTrans();

            if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else if (listCustomerTrans != null)
            {
                if (!string.IsNullOrEmpty(searchValue) && !string.IsNullOrEmpty(searchKey))
                {
                    switch (searchKey)
                    {
                        case "Customer Name":
                            showListCustomerTrans = listCustomerTrans.Where(c => c.CustomerName.Contains(searchValue)).ToList<VisitaJayaPerkasa.Entities.CustomerTrans>();
                            break;
                    }

                }
                else
                    showListCustomerTrans = listCustomerTrans;
            }
            else
                showListCustomerTrans = null;

            if (showListCustomerTrans != null)
            {
                totalPage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(showListCustomerTrans.Count() / Convert.ToDecimal(pageSize))));
                currentPage = 1;
            }
            else
                totalPage = 0;

            RefreshGrid();
        }