private void RefreshItems(object sender, EventArgs e) { var biz = new CityBiz(); dataGridView.DataSource = biz.LoadItems(); dataGridView.Refresh(); }
private bool CustomValidation() { bool hasError = true; errorProvider.Clear(); if (string.IsNullOrEmpty(textName.Text)) { errorProvider.SetError(textName, Constants.Messages.RequireMessage); hasError = false; textName.Focus(); } else { var biz = new CityBiz(); var result = biz.SearchByName(textName.Text.Trim()); if (result) { errorProvider.SetError(textName, Constants.Messages.CityExist); hasError = false; textName.Focus(); } } return(hasError); }
private void LoadCities() { var biz = new CityBiz(); drlCity.Items.Clear(); drlCity.DataSource = biz.GetAll(); }
private bool CustomValidation() { bool hasError = true; errorProvider.Clear(); if (string.IsNullOrEmpty(textName.Text)) { errorProvider.SetError(textName, Constants.Messages.RequireMessage); hasError = false; textName.Focus(); } else { var biz = new CityBiz(); var result = biz.SearchByName(textName.Text.Trim()); if(result) { errorProvider.SetError(textName, Constants.Messages.CityExist); hasError = false; textName.Focus(); } } return hasError; }
public CityView(User user) { InitializeComponent(); currentUser = user; dataGridView.AutoGenerateColumns = false; var biz = new CityBiz(); dataGridView.DataSource = biz.LoadItems(); dataGridView.Refresh(); }
protected void ddlDivision_SelectedIndexChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(ddlDivision.SelectedValue)) { ddlCity.DataSource = CityBiz.GetCity(Convert.ToInt32(ddlDivision.SelectedValue)); ddlCity.DataBind(); ddlCity.SelectedIndex = 1; } else { ddlCity.Items.Clear(); ddlCity.Items.Insert(0, "--Select Option--"); } }
public CityForm(int id, User user) { InitializeComponent(); textName.Focus(); itemId = id; var biz = new CityBiz(); var item = biz.LoadItem(id); textName.Text = item.Name; InitForm(user); this.Text = "Sửa thông tin thành phố"; }
private void SaveItem(object sender, EventArgs e) { if (CustomValidation()) { var item = new City(); item.Name = textName.Text; if (itemId > 0) { try { item.Id = itemId; var biz = new CityBiz(); biz.UpdateItem(item); } catch (Exception ex) { logger.LogInfoMessage("----Update City ERROR----"); logger.LogException(ex); } } else { try { var biz = new CityBiz(); biz.SaveItem(item); } catch (Exception ex) { logger.LogInfoMessage("----Create City ERROR----"); logger.LogException(ex); } } this.Close(); } else { this.DialogResult = System.Windows.Forms.DialogResult.None; } }
private void DeleteItem(object sender, EventArgs e) { var items = new List <City>(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[0].Value != null && row.Cells[0].Value == "1") { items.Add(row.DataBoundItem as City); } } if (items.Count > 0) { var biz = new CityBiz(); biz.RemoveItem(items); RefreshItems(sender, e); } }
private void DeleteItem(object sender, EventArgs e) { var items = new List<City>(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[0].Value != null && row.Cells[0].Value == "1") { items.Add(row.DataBoundItem as City); } } if (items.Count > 0) { var biz = new CityBiz(); biz.RemoveItem(items); RefreshItems(sender, e); } }
private void SaveItem(object sender, EventArgs e) { if (CustomValidation()) { var item = new City(); item.Name = textName.Text; if (itemId > 0) { try { item.Id = itemId; var biz = new CityBiz(); biz.UpdateItem(item); } catch (Exception ex) { logger.LogInfoMessage("----Update City ERROR----"); logger.LogException(ex); } } else { try { var biz = new CityBiz(); biz.SaveItem(item); } catch(Exception ex) { logger.LogInfoMessage("----Create City ERROR----"); logger.LogException(ex); } } this.Close(); } else { this.DialogResult = System.Windows.Forms.DialogResult.None; } }