Ejemplo n.º 1
0
        public void LoadForm()
        {
            if (_isLoaded)
            {
                return;
            }

            try
            {
                lblSendReport.Text = String.Empty;

                UserTypeTableAdapter userTypeTA = new UserTypeTableAdapter();

                userTypeDT = userTypeTA.GetData();
                if (userTypeDT.Rows.Count > 0)
                {
                    List<KeyValuePair<string, string>> userTypeDS = new List<KeyValuePair<string, string>>();

                    userTypeDS.Add(new KeyValuePair<string, string>("", "<<Tất cả>>"));

                    string typeName;
                    string typeShortName;
                    foreach (DataRow row in userTypeDT.Rows)
                    {
                        typeName = row.Field<string>("TypeName");
                        typeShortName = row.Field<string>("TypeShortName");
                        userTypeDS.Add(new KeyValuePair<string, string>(typeShortName, typeName));
                    }

                    cbxUserTypeSearch.DataSource = userTypeDS;
                    cbxUserTypeSearch.DisplayMember = "Value";
                    cbxUserTypeSearch.ValueMember = "Key";
                }

                CustomerTableAdapter customerTA = new CustomerTableAdapter();

                if (customerDT == null)
                {
                    customerDT = customerTA.GetData();
                }
                dataGridView.DataSource = customerDT;
                CustomGrid(dataGridView);

                List<KeyValuePair<int, string>> activeList = new List<KeyValuePair<int, string>>();
                activeList.Add(new KeyValuePair<int, string>(-1, "<<Tất cả>>"));
                activeList.Add(new KeyValuePair<int, string>(1, "Có"));
                activeList.Add(new KeyValuePair<int, string>(0, "Không"));

                cbxActive.DataSource = activeList;
                cbxActive.DisplayMember = "Value";
                cbxActive.ValueMember = "Key";

                _isLoaded = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi xảy ra, không thể tải dữ liệu.");
                Log.ErrorLog(ex.Message);
            }
        }