static public String[] FindCred(String ID) { String[] result = new String[6]; String connString = Properties.Settings.Default.HQ; DataTable dt1 = new DataTable(); DataTable dt2 = new DataTable(); SqlConnection con = new SqlConnection(connString); con.Open(); SqlCommand command1 = new SqlCommand("SELECT * FROM Franchisee WHERE franchisee_id = " + ID, con); SqlDataAdapter adap1 = new SqlDataAdapter(command1); adap1.Fill(dt1); SqlCommand command2 = new SqlCommand("SELECT * FROM Operational_Region WHERE zone_id = " + dt1.Rows[0]["zone_id"].ToString(), con); SqlDataAdapter adap2 = new SqlDataAdapter(command2); adap2.Fill(dt2); con.Close(); result[0] = dt1.Rows[0]["company_name"].ToString(); result[1] = dt1.Rows[0]["isHQ"].ToString(); result[2] = dt2.Rows[0]["zone_title"].ToString(); result[3] = MCountry.GetName(dt2.Rows[0]["country_id"].ToString()); result[4] = MProvState.GetName(dt2.Rows[0]["province_id"].ToString()); result[5] = MCity.GetName(dt2.Rows[0]["city_id"].ToString()); return(result); }
public void Edit_Client_Populate(object sender, EventArgs e) { String clientID = _clientForm.GetSelectedClient(); if (clientID != "") { OldClient(clientID); String[] fields = _client.Get(); _clientForm.setFields(fields); _clientForm.SetCountryBox(MCountry.GetList(), fields[11]); _clientForm.SetProvStateBox(fields[12]); _clientForm.SetCityBox(fields[13]); } }
public void Add_Old_Row(String[] rowElements) { int index = ServiceAddrGridView.Rows.Add(); SetTableButtonMetrics(index, rowElements[0]); DataTable country, province, city; country = MCountry.GetList(); province = MProvState.GetFilteredList(rowElements[6]); city = MCity.GetFilteredList(rowElements[5]); //country.TableName = "country"; var countryCell = ServiceAddrGridView.Rows[index].Cells["countryCol"] as DataGridViewComboBoxCell; //(ServiceAddrGridView.Rows[index].Cells[0].DataPropertyName = "Type"; countryCell.DataSource = country; countryCell.DisplayMember = "name"; countryCell.ValueMember = "id"; var provCell = ServiceAddrGridView.Rows[index].Cells["provStateCol"] as DataGridViewComboBoxCell; provCell.DataSource = province; provCell.DisplayMember = "name"; provCell.ValueMember = "id"; var cityCell = ServiceAddrGridView.Rows[index].Cells["cityCol"] as DataGridViewComboBoxCell; cityCell.DataSource = city; cityCell.DisplayMember = "name"; cityCell.ValueMember = "id"; ServiceAddrGridView.Rows[index].Cells["idCol"].Value = rowElements[0]; ServiceAddrGridView.Rows[index].Cells["address_col"].Value = rowElements[1]; ServiceAddrGridView.Rows[index].Cells["postal_code_col"].Value = rowElements[2]; ServiceAddrGridView.Rows[index].Cells["on_site_contact_col"].Value = rowElements[3]; try { ServiceAddrGridView.Rows[index].Cells["countryCol"].Value = rowElements[4]; ServiceAddrGridView.Rows[index].Cells["provStateCol"].Value = rowElements[5]; ServiceAddrGridView.Rows[index].Cells["cityCol"].Value = rowElements[6]; } catch (Exception) { } ServiceAddrGridView.Rows[index].Cells["num_floors"].Value = rowElements[7]; ServiceAddrGridView.Rows[index].Cells["roomButton"].Value = rowElements[8]; }
/********************************* Service Address Grid View *****************************/ private void ServiceAddrGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { var c = ServiceAddrGridView.Rows[e.RowIndex].Cells["countryCol"] as DataGridViewComboBoxCell; DataTable dt = MCountry.GetList(); c.DataSource = dt; c.DisplayMember = "name"; c.ValueMember = "id"; MServiceAddress _srvAddr = new MServiceAddress(); ServiceAddrGridView.Rows[e.RowIndex].Cells[0].Value = _srvAddr.FindID(); ServiceAddrGridView.Rows[e.RowIndex].Cells["editButton"].Value = "0"; ServiceAddrGridView.Rows[e.RowIndex].Cells["roomButton"].Value = "0"; ServiceAddrGridView.Rows[e.RowIndex].Cells["num_floors"].Value = "0"; }
public void InitializeCombos(String countryID, String ProvID, String CityID) { DataTable country = MCountry.GetList(); DataTable province; DataTable city; if (String.Equals(countryID, "noChange")) { province = MProvState.GetFilteredList(CountryBox.SelectedValue.ToString()); } else { CountryBox.SelectedValueChanged -= CountryBoxChanged; CountryBox.DataSource = country; CountryBox.DisplayMember = country.Columns[1].ToString(); CountryBox.ValueMember = country.Columns[0].ToString(); province = MProvState.GetFilteredList(countryID); CountryBox.SelectedValueChanged += new EventHandler(CountryBoxChanged); } if (String.Equals(ProvID, "noChange")) { city = MCity.GetFilteredList(ProvStateBox.SelectedValue.ToString()); } else { ProvStateBox.SelectedValueChanged -= ProvBoxChanged; ProvStateBox.DataSource = province; ProvStateBox.DisplayMember = province.Columns[1].ToString(); ProvStateBox.ValueMember = province.Columns[0].ToString(); city = MCity.GetFilteredList(ProvID); ProvStateBox.SelectedValueChanged += new EventHandler(ProvBoxChanged); } CityBox.DataSource = city; CityBox.DisplayMember = city.Columns[1].ToString(); CityBox.ValueMember = city.Columns[0].ToString(); }
public void LoadOpRegions() { DataTable dt = MOpReg.GetRegions(); DataTable regs = new DataTable(); regs.Columns.Add("ID", typeof(string)); regs.Columns.Add("Display", typeof(string)); regs.Rows.Add(new String[] { "NULL", "<All>" }); foreach (DataRow r in dt.Rows) { regs.Rows.Add(r["zone_id"].ToString(), r["zone_Title"].ToString() + " ( " + MCity.GetName(r["city_id"].ToString()) + ", " + MProvState.GetName(r["province_id"].ToString()) + ", " + MCountry.GetName(r["country_id"].ToString()) + ")"); } OpRegionCombo.DataSource = regs; OpRegionCombo.ValueMember = regs.Columns["ID"].ToString(); OpRegionCombo.DisplayMember = regs.Columns["Display"].ToString(); OpRegionCombo.SelectedValue = "NULL"; }
public void PopulateBAddrsGridView(DataTable Addrs) { DataGridViewComboBoxCell country; DataTable co = MCountry.GetList(); DataGridViewComboBoxCell province; DataTable pr; DataGridViewComboBoxCell city; DataTable ci; int n = Addrs.Rows.Count, index; for (int i = 0; i < n; i++) { index = BAddrGridView.Rows.Add(); BAddrGridView.Rows[index].Cells["locID"].Value = Addrs.Rows[i]["location_id"]; BAddrGridView.Rows[index].Cells["bAddr"].Value = Addrs.Rows[i]["address"]; BAddrGridView.Rows[index].Cells["bPostal"].Value = Addrs.Rows[i]["postal_code"]; country = BAddrGridView.Rows[index].Cells["bCountry"] as DataGridViewComboBoxCell; country.DataSource = co; country.DisplayMember = co.Columns[1].ToString(); country.ValueMember = co.Columns[0].ToString(); country.Value = Addrs.Rows[i]["country_id"]; province = BAddrGridView.Rows[index].Cells["bProvince"] as DataGridViewComboBoxCell; pr = MProvState.GetFilteredList(Addrs.Rows[i]["country_id"].ToString()); province.DataSource = pr; province.DisplayMember = pr.Columns[1].ToString(); province.ValueMember = pr.Columns[0].ToString(); province.Value = Addrs.Rows[i]["province_id"]; city = BAddrGridView.Rows[index].Cells["bCity"] as DataGridViewComboBoxCell; ci = MCity.GetFilteredList(Addrs.Rows[i]["province_id"].ToString()); city.DataSource = ci; city.DisplayMember = ci.Columns[1].ToString(); city.ValueMember = ci.Columns[0].ToString(); city.Value = Addrs.Rows[i]["city_id"]; } }
private void AddAddrButton_Click(object sender, EventArgs e) { int i = BAddrGridView.Rows.Add(); DataGridViewComboBoxCell country = BAddrGridView.Rows[i].Cells["bCountry"] as DataGridViewComboBoxCell; DataTable co = MCountry.GetList(); country.DataSource = co; country.DisplayMember = co.Columns[1].ToString(); country.ValueMember = co.Columns[0].ToString(); DataGridViewComboBoxCell province = BAddrGridView.Rows[i].Cells["bProvince"] as DataGridViewComboBoxCell; DataTable pr = MProvState.GetFilteredList("1"); province.DataSource = pr; province.DisplayMember = pr.Columns[1].ToString(); province.ValueMember = pr.Columns[0].ToString(); DataGridViewComboBoxCell city = BAddrGridView.Rows[i].Cells["bCity"] as DataGridViewComboBoxCell; DataTable ci = MCity.GetFilteredList("1"); city.DataSource = ci; city.DisplayMember = ci.Columns[1].ToString(); city.ValueMember = ci.Columns[0].ToString(); }
public AddEditClientForm(MaintainClientController parent, bool edit, int id) { InitializeComponent(); my_controller = parent; isEdit = edit; userid = id; noChanges = true; #region Form Event Handlers /* this.Back_Button.Click += new System.EventHandler(my_controller.Client_Cancel_Button_Click); * this.Back_Button.MouseEnter += new EventHandler(button1_MouseEnter); * this.Back_Button.MouseLeave += new EventHandler(button1_MouseLeave); * this.Back_Button.Location = new Point(65, 38); * this.Back_Button.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.Back2)); * Back_Button.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; * Back_Button.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; */ // this.contract_Button.Click += new EventHandler(my_controller.Client_Contract_Button_Click); this.Ok_Button.Click += new System.EventHandler(my_controller.Client_Ok_Button_Click); // this.Cancel_Button.Click += new System.EventHandler(my_controller.Client_Cancel_Button_Click); this.delete_Button.Click += new EventHandler(my_controller.Client_Delete_Button_Click); this.CountryBox.SelectedValueChanged += new System.EventHandler(my_controller.Country_Changed); this.ProvStateBox.SelectedValueChanged += new EventHandler(my_controller.Province_Changed); this.CityBox.SelectedValueChanged += new EventHandler(my_controller.City_Changed); this.nameTxtBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); this.typeTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); this.addrTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); this.postalCodeTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); this.PoBoxTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); this.EmailTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); this.mainPhoneTxtBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); this.SecondPhoneTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); this.FaxTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); this.PrimContactTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); #endregion if (isEdit) { #region Create and set a combo selection box DataTable clients = MClient.GetList(); nameComboBox = new ComboBox(); nameComboBox.Location = new Point(300, 31); nameComboBox.Font = new Font(nameComboBox.Font.FontFamily, 10); nameComboBox.Size = new Size(195, 28); DataTable dt = new DataTable(); dt = clients.Clone(); dt.Rows.Add(new String[] { null, "<Select Client>" }); foreach (DataRow r in clients.Rows) { dt.ImportRow(r); } nameComboBox.DataSource = dt; nameComboBox.DisplayMember = dt.Columns[1].ToString(); nameComboBox.ValueMember = dt.Columns[0].ToString(); nameComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; nameComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource; for (int i = 0; i < clients.Rows.Count; i++) { nameComboBox.AutoCompleteCustomSource.Add(clients.Rows[i][1].ToString()); } nameComboBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed); nameComboBox.SelectedValueChanged += new EventHandler(my_controller.Edit_Client_Populate); this.Controls.Add(nameComboBox); Label nameSelection = new Label(); nameSelection.Text = "Select Client:"; nameSelection.Font = new Font(nameComboBox.Font.FontFamily, 10); nameSelection.Location = new Point(490, 166); this.Controls.Add(nameSelection); #endregion } here : try { SetCountryBox(MCountry.GetList(), "0"); } catch (Exception) { if (MessageBox.Show("Error connecting to Database\nDo you want to retry?", "Connection Problems", MessageBoxButtons.YesNo) == DialogResult.Yes) { goto here; } } //User label user = new Users(); userid = id; setup(userid.ToString(), "FAFOS Client Form"); }