private void ManagerForm_Load(object sender, EventArgs e) { ExtensionMethods.DoubleBuffered(this.usersDataGridView, true); selectedRow = 0; SqlManipulator sql = new SqlManipulator(); try { makeTableUsers(sql.getDataLogin()); //usersDataGridView.Columns[0].Visible = false; var cities = sql.queryCities(); cityComboBox.DataSource = cities; // this.cityTableTableAdapter.Fill(this.daftarDataSet1.CityTable); makeTable(sql.getDataCity()); makeTableUsers(sql.getDataLogin()); makeValidationTable(sql.getValidationData()); startendDate = sql.findMaxminMonthDay(0); this.versionTextBox.Text = global.currentVersion.ToString(); this.versionTextBox.Enabled = false; DGV_SetStyle(this.cityDataGridView); changeCityDGVname(); changeColumnName(); selectedRow = 0; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void tabControl1_Selected(object sender, TabControlEventArgs e) { if (e.TabPage == tabPage1) { selectedRow = 0; SqlManipulator sql = new SqlManipulator(); try { makeTableUsers(sql.getDataLogin()); /// usersDataGridView.Columns[0].Visible = false; var cities = sql.queryCities(); cityComboBox.DataSource = cities; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } if (e.TabPage == tabPage2) { selectedRow = 0; SqlManipulator sql = new SqlManipulator(); makeTable(sql.getDataCity()); } if (e.TabPage == tabPage4) { try { SqlManipulator sql = new SqlManipulator(); makeValidationTable(sql.getValidationData()); var cities = sql.queryCities(); validCityComboBox.DataSource = cities; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void addCityToFormManagerButton_Click(object sender, EventArgs e) { try { CityTable newCity = new CityTable(); newCity.CityName = CityTextBox.Text; newCity.Id = Convert.ToInt64(IDTextBox.Text); SqlManipulator sql = new SqlManipulator(); if (sql.addCity(newCity)) { makeTable(sql.getDataCity()); MessageBox.Show("با موفقیت شهر مورد نظر اضافه گردید"); mainForm.setCityComboBox(); } else { MessageBox.Show("خطا"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void RemoveButton_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("آیا از حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { try { selectedRow = cityDataGridView.CurrentCell.RowIndex; SqlManipulator sql = new SqlManipulator(); DataGridViewRow newDataRow = cityDataGridView.Rows[selectedRow]; CityTable deletedCity = new CityTable(); deletedCity.Id = (long)newDataRow.Cells[1].Value; deletedCity.CityName = (string)newDataRow.Cells[0].Value; sql.removeCity(deletedCity); var cityData = sql.getDataCity(); makeTable(cityData); } catch (Exception) { throw; } } }