public Boolean addCity(CityTable newCity) { try { UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn); db.CityTables.InsertOnSubmit(newCity); db.SubmitChanges(); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
public Boolean removeCity(CityTable newCity) { try { UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn); var q = from a in db.CityTables where a.Id == newCity.Id select a; foreach (var a in q) { db.CityTables.DeleteOnSubmit(a); } db.SubmitChanges(); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
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; } } }
private void detach_CityTables(CityTable entity) { this.SendPropertyChanging(); entity.UserTable = null; }
private void attach_CityTables(CityTable entity) { this.SendPropertyChanging(); entity.UserTable = this; }
partial void DeleteCityTable(CityTable instance);
partial void UpdateCityTable(CityTable instance);
partial void InsertCityTable(CityTable instance);