public AtkEdit(Entities.PriceList price) { InitializeComponent(); this.price = price; sqlPriceListRepository = new SqlPriceListRepository(); List<Entities.Category> listCategory = sqlPriceListRepository.GetTypeOfSupplier(1); if (!Constant.VisitaJayaPerkasaApplication.anyConnection) { MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } categorySupplier = listCategory != null ? listCategory.FirstOrDefault() : null; if (categorySupplier != null) { listSupplier = sqlPriceListRepository.GetSupplier(categorySupplier.ID); if (!Constant.VisitaJayaPerkasaApplication.anyConnection) { MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } cbSupplier.Enabled = true; cbSupplier.DataSource = listSupplier; cbSupplier.DisplayMember = "SupplierName"; cbSupplier.ValueMember = "Id"; cbSupplier.SelectedIndex = -1; cbSupplier.Text = "-- Choose --"; if (this.price == null) { pickerDate.Value = DateTime.Now; wantToCreateNew = true; } else { cbSupplier.SelectedValue = price.SupplierID; if (cbSupplier.Text.Equals(Constant.VisitaJayaPerkasaApplication.cboDefaultText) || cbSupplier.Text.Equals("")) radButtonElement1.Enabled = false; pickerDate.Value = price.DateFrom; etItem.Text = price.Item; etPrice.Text = price.PriceSupplier.ToString(); wantToCreateNew = false; } } listCategory = null; sqlPriceListRepository = null; }
private void RefreshTypeSupplier() { PriceListGridView.Rows.Clear(); PriceListGridView.DataSource = null; PriceListGridView.Enabled = false; sqlPriceListRepository = new SqlPriceListRepository(); listSupplier = sqlPriceListRepository.GetSupplier(Utility.Utility.ConvertToUUID(cboTypeSupplier.SelectedValue.ToString())); if (!Constant.VisitaJayaPerkasaApplication.anyConnection) MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cbSupplier.Enabled = true; cbSupplier.DataSource = listSupplier; cbSupplier.DisplayMember = "SupplierName"; cbSupplier.ValueMember = "Id"; cbSupplier.SelectedIndex = -1; cbSupplier.Text = "-- Choose --"; sqlPriceListRepository = null; }