private void btnDisAdd_Click(object sender, RoutedEventArgs e)
        {
            DTO.Entity.Distributor item = new DTO.Entity.Distributor();

            try
            {
                item.Name      = txtDisName.Text;
                item.TimeLimit = int.Parse(txtDisTimeLimit.Text);
                item.Phone     = txtDisPhone.Text;
                item.Email     = txtDisEmail.Text;
                item.Address   = txtDisAddress.Text;
            }
            catch (System.Exception ex)
            {
                DXMessageBox.Show("Thêm không thành công!");
                return;
            }

            if (new DistributorDAO().Add(item))
            {
                DXMessageBox.Show("Thêm thành công!");
            }
            else
            {
                DXMessageBox.Show("Thêm không thành công!");
            }

            grdDistributor.ItemsSource = new DistributorDAO().GetAll();
        }
 private void btnDisRefresh_Click(object sender, RoutedEventArgs e)
 {
     DTO.Entity.Distributor item = new DTO.Entity.Distributor();
     ChangeInput(item);
     btnDisAdd.IsEnabled    = true;
     btnDisUpdate.IsEnabled = false;
 }
 private void ChangeInput(DTO.Entity.Distributor item)
 {
     txtDisId.Text        = item.Id.ToString();
     txtDisName.Text      = item.Name;
     txtDisTimeLimit.Text = item.TimeLimit.ToString();
     txtDisPhone.Text     = item.Phone;
     txtDisEmail.Text     = item.Email;
     txtDisAddress.Text   = item.Address;
 }
        private void removeDistributor_Loaded(object sender, RoutedEventArgs e)
        {
            DTO.Entity.Distributor cat = null;
            try
            {
                cat = grdDistributor.SelectedItem as DTO.Entity.Distributor;
            }
            catch (System.Exception ex)
            {
                return;
            }

            if (cat == null)
            {
                removeDistributor.IsEnabled = false;
            }
            else
            {
                removeDistributor.IsEnabled = true;
            }
        }