private void Fill() { ContractorsLogic contractors = new ContractorsLogic(manager); DataGV.AutoGenerateColumns = false; List <Contractor> resultA = contractors.GetAll(); List <ContractorView> contractorsView = new List <ContractorView>(); foreach (Contractor a in resultA) { ContractorView c = new ContractorView(a, manager); contractorsView.Add(c); } view = new SortableBindingList <ContractorView>(contractorsView); DataGV.DataSource = view; DataGV.AutoResizeRows(); DataGV.Update(); PersonCB.SelectedIndex = 0; ContractorTypesDDL.Items.Clear(); ContractorTypesLogic types = new ContractorTypesLogic(manager); ContractorTypesDDL.DisplayMember = "Name"; ContractorTypesDDL.ValueMember = "ID"; ContractorType all = new ContractorType(); all.ID = -1; all.Name = " - всі - "; ContractorTypesDDL.Items.Add(all); foreach (var a in types.GetAll()) { ContractorTypesDDL.Items.Add(a); } ContractorTypesDDL.SelectedIndex = 0; }
private void DeleteSB_Click(object sender, EventArgs e) { ContractorsLogic wares = new ContractorsLogic(manager); wares.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value)); manager.Save(); Fill(); }
/// <summary> /// Заповнення переліку контрагентів /// </summary> private void InitContractorsLookUp() { ContractorsLogic contractors = new ContractorsLogic(manager); BindingSource bs = new BindingSource(); bs.DataSource = contractors.GetAll(); // Bind the edit value to the ProductID field of the "Order Details" table. // The edit value matches the value of the ValueMember field //ContractorLUE.DataBindings.Add("EditValue", bs, "ID"); // Specify the data source to display in the dropdown. ContractorLUE.Properties.DataSource = bs; // The field providing the editor's display text. ContractorLUE.Properties.DisplayMember = "LastName"; // The field matching the edit value. ContractorLUE.Properties.ValueMember = "ID"; // Add two columns to the dropdown. LookUpColumnInfoCollection coll = ContractorLUE.Properties.Columns; // A column to display the ProductID field's values. coll.Add(new LookUpColumnInfo("ID", 0)); // A column to display the ProductName field's values. coll.Add(new LookUpColumnInfo("LastName", 0, "Прізвище")); // A column to display the QuantityPerUnit field's values. coll.Add(new LookUpColumnInfo("FirstName", 0, "Ім'я")); coll.Add(new LookUpColumnInfo("MiddleName", 0, "По-батькові")); coll.Add(new LookUpColumnInfo("City", 0, "Місто")); // Set column widths according to their contents and resize the popup, if required. ContractorLUE.Properties.BestFitMode = BestFitMode.BestFitResizePopup; // Enable auto completion search mode. ContractorLUE.Properties.SearchMode = SearchMode.AutoFilter; // Specify the column against which to perform the search. ContractorLUE.Properties.AutoSearchColumnIndex = 1; //ContractorCB.DataSource = contractors.GetAll(); //ContractorCB.DisplayMember = "LastName"; //ContractorCB.ValueMember = "ID"; //ContractorCB.Update(); }
private void Fill() { ContractorsLogic contractors = new ContractorsLogic(manager); DataGV.AutoGenerateColumns = false; List<Contractor> resultA = contractors.GetAll(); List<ContractorView> contractorsView = new List<ContractorView>(); foreach (Contractor a in resultA) { ContractorView c = new ContractorView(a,manager); contractorsView.Add(c); } view = new SortableBindingList<ContractorView>(contractorsView); DataGV.DataSource = view; DataGV.AutoResizeRows(); DataGV.Update(); PersonCB.SelectedIndex = 0; ContractorTypesDDL.Items.Clear(); ContractorTypesLogic types = new ContractorTypesLogic(manager); ContractorTypesDDL.DisplayMember = "Name"; ContractorTypesDDL.ValueMember = "ID"; ContractorType all = new ContractorType(); all.ID = -1; all.Name = " - всі - "; ContractorTypesDDL.Items.Add(all); foreach (var a in types.GetAll()) { ContractorTypesDDL.Items.Add(a); } ContractorTypesDDL.SelectedIndex = 0; }
private void Fill() { ContractorsLogic cl = new ContractorsLogic(manager); ContractorTypesLogic types = new ContractorTypesLogic(manager); ContractorTypesCBE.Properties.ValueMember = "ID"; ContractorTypesCBE.Properties.DisplayMember = "Name"; foreach (var a in types.GetAll()) { ContractorTypesCBE.Properties.Items.Add(a.ID, a.Name, CheckState.Unchecked, true); } if (mode == "edit") { Contractor contractor = cl.Get(Convert.ToInt32(id)); if (contractor != null) { PrefixNameTE.Text = contractor.PrefixName; LastNameTE.Text = contractor.LastName; FirstNameTE.Text = contractor.FirstName; MiddleNameE.Text = contractor.MiddleName; CountryTE.Text = contractor.Country; RegionTE.Text = contractor.Region; DistrictTE.Text = contractor.District; CityTE.Text = contractor.City; StreetTE.Text = contractor.Street; BuildingTE.Text = contractor.Building; FlatTE.Text = contractor.Flat; PhoneTE.Text = contractor.Phone; MobPhoneTE.Text = contractor.MobilePhone; EmailTE.Text = contractor.EMail; SiteTE.Text = contractor.Site; if (contractor.Birthdate != null) { BirthDateTE.DateTime = Convert.ToDateTime(contractor.Birthdate); } if (contractor.Sex != null) { if (contractor.Sex == true) { SexRG.SelectedIndex = 0; } if (contractor.Sex == false) { SexRG.SelectedIndex = 1; } } if (contractor.Person != null) { if (contractor.Person == true) { PersonRG.SelectedIndex = 1; } if (contractor.Person == false) { PersonRG.SelectedIndex = 0; } } List <ContractorContractorType> checkedTypes = cl.GetContractorTypesForContractor(contractor.ID); foreach (DevExpress.XtraEditors.Controls.CheckedListBoxItem i in ContractorTypesCBE.Properties.Items) { foreach (var a in checkedTypes) { if (a.ContractorTypeID == Convert.ToInt32(i.Value)) { i.CheckState = CheckState.Checked; } } } //вибираємо картки по клієнту DataGV.AutoGenerateColumns = false; DataGV.DataSource = cl.GetCards(contractor.ID); DataGV.Update(); } } }
private void SaveBt_Click(object sender, EventArgs e) { ContractorsLogic cl = new ContractorsLogic(manager); string lastName = LastNameTE.Text; string firstName = FirstNameTE.Text; if (FirstNameTE.Enabled == false) { firstName = ""; } string middleName = MiddleNameE.Text; if (MiddleNameE.Enabled == false) { middleName = ""; } string country = CountryTE.Text; string region = RegionTE.Text; string district = DistrictTE.Text; string city = CityTE.Text; string street = StreetTE.Text; string building = BuildingTE.Text; string flat = FlatTE.Text; string phone = PhoneTE.Text; string mobilePhone = MobPhoneTE.Text; string email = EmailTE.Text; string site = SiteTE.Text; string prefixName = PrefixNameTE.Text; DateTime?birthDate = null; if (BirthDateTE.Text.Length > 0) { birthDate = BirthDateTE.DateTime; } bool?sex = null; if (SexRG.SelectedIndex == 0) { //чоловік sex = true; } if (SexRG.SelectedIndex == 1) { //жінка sex = false; } bool?person = null; switch (PersonRG.SelectedIndex) { case 0: { person = false; //фізична особа break; } case 1: { person = true; //фізична особа break; } } string newCardCode = CardCodeTB.Text.Trim(); //List<DevExpress.XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit> checkedItems; //checkedItems = (List<DevExpress.XtraEditors.Repository.RepositoryItemCheckedComboBoxEdit>)ContractorTypesCBE.Properties.GetCheckedItems(); //List<ContractorType> selectedTypes = (List<ContractorType>)ContractorTypesCBE.Properties.GetCheckedItems(); List <int> selectedTypes = new List <int>(); foreach (DevExpress.XtraEditors.Controls.CheckedListBoxItem i in ContractorTypesCBE.Properties.Items) { if (i.CheckState == CheckState.Checked) { selectedTypes.Add(Convert.ToInt32(i.Value)); } } Contractor contractor = new Contractor(); if (mode == "new") { contractor = cl.Create(prefixName, lastName, firstName, middleName, country, region, district, city, street, building, flat, phone, mobilePhone, email, site, birthDate, sex, person, selectedTypes); } if (mode == "edit") { contractor = cl.Update(Convert.ToInt32(id), prefixName, lastName, firstName, middleName, country, region, district, city, street, building, flat, phone, mobilePhone, email, site, birthDate, sex, person, selectedTypes); } cl.AddCard(contractor, newCardCode); manager.Save(); this.Close(); }