public int Insert(ServiceGroups serviceGroups) { try { aDatabaseDA.ServiceGroups.Add(serviceGroups); return aDatabaseDA.SaveChanges(); } catch (Exception ex) { throw new Exception(string.Format("ServiceGroupsBO.Ins :" + ex.Message)); } }
private void bnAdd_Click(object sender, EventArgs e) { try { if (ValidateData() == true) { ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO(); ServiceGroups aServiceGroups = new ServiceGroups(); aServiceGroups.Name = txtName.Text; aServiceGroups.Type = Convert.ToInt32(lueType.EditValue); aServiceGroups.Disable = bool.Parse(cbxDisable.SelectedItem.ToString()); int ret = aServiceGroupsBO.Insert(aServiceGroups); if (ret == 1) { lblID.Text = ""; txtName.Text = ""; lueType.EditValue = 0; cbxDisable.SelectedIndex = 0; MessageBox.Show("Thêm mới thành công","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Information); this.ReloadData(); if (afrmIns_Services != null) { this.afrmIns_Services.ReloadData(); } } else { MessageBox.Show("Thất mới nhóm dịch vụ thất bại.","Lỗi",MessageBoxButtons.OK,MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("frmIns_ServiceGroups.bnAdd_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Upd(ServiceGroups serviceGroups) { try { aDatabaseDA.ServiceGroups.AddOrUpdate(serviceGroups); aDatabaseDA.SaveChanges(); //return ret; } catch (Exception ex) { throw new Exception(string.Format("ServiceGroupsBO.Upd :" + ex.Message)); } }
private void bnEdit_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(txtName.Text) == true) { txtName.Focus(); MessageBox.Show("Vui lòng nhập tên nhóm dịch vụ.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { bnAdd.Enabled = true; bnEdit.Enabled = false; ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO(); ServiceGroups aServiceGroups = new ServiceGroups(); aServiceGroups.ID =Convert.ToInt32(lblID.Text); aServiceGroups.Name = txtName.Text; aServiceGroups.Type = Convert.ToInt32(lueType.EditValue); aServiceGroups.Disable = bool.Parse(cbxDisable.SelectedItem.ToString()); aServiceGroupsBO.Update(aServiceGroups); this.ReloadData(); if (afrmIns_Services != null) { this.afrmIns_Services.ReloadData(); } } } catch (Exception ex) { MessageBox.Show("frmIns_ServiceGroups.bnEdit_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }