private void btnUpdate_Click(object sender, EventArgs e) { if (cmbBeams.SelectedIndex == -1) { MessageBox.Show("Kiriş tipi seçiniz."); } if (txtName.Text == String.Empty) { MessageBox.Show("Yük tipi adı giriniz."); } try { using (ILoadRepository loadRepo = new LoadRepository(new Datacore.Data.BeamDeflectionDbContext())) { Load oldLoad = loadRepo.Get(x => x.ID == _Load.ID).Result; oldLoad.BeamId = ((Beam)cmbBeams.SelectedItem).ID; oldLoad.Name = txtName.Text; oldLoad.IsActive = chkIsActive.Checked; oldLoad.IsDeleted = chkIsDeleted.Checked; oldLoad.UpdatedAt = DateTime.UtcNow; var result = loadRepo.Update(oldLoad); switch (result.State) { case Basecore.Model.Enums.BusinessResultType.NotSet: lblMessage.Text = result.Message; break; case Basecore.Model.Enums.BusinessResultType.Success: lblMessage.Text = "Güncelleme başarılı. Son güncellenen yük tipinin adı : " + result.Result.Name; txtName.Text = String.Empty; cmbBeams.SelectedIndex = 0; chkIsActive.Checked = true; chkIsDeleted.Checked = false; break; case Basecore.Model.Enums.BusinessResultType.Error: lblMessage.Text = result.Message; break; case Basecore.Model.Enums.BusinessResultType.Warning: lblMessage.Text = result.Message; break; case Basecore.Model.Enums.BusinessResultType.Info: lblMessage.Text = result.Message; break; default: break; } ucEditLoads_Load(sender, e); } } catch (Exception ex) { lblMessage.Text = "Hata : " + ex.GetBaseException(); } }
private void btnDelete_Click(object sender, EventArgs e) { if (_Load == null) { lblMessage.Text = "Silinecek yük tipini seçiniz."; return; } try { using (ILoadRepository loadRepo = new LoadRepository(new Datacore.Data.BeamDeflectionDbContext())) { Load oldLoad = loadRepo.Get(x => x.ID == _Load.ID).Result; var result = loadRepo.Delete(oldLoad); switch (result.State) { case Basecore.Model.Enums.BusinessResultType.NotSet: lblMessage.Text = result.Message; break; case Basecore.Model.Enums.BusinessResultType.Success: lblMessage.Text = "Silme işlemi başarılı. Son silinen yük tipi adı : " + oldLoad.Name; break; case Basecore.Model.Enums.BusinessResultType.Error: lblMessage.Text = result.Message; break; case Basecore.Model.Enums.BusinessResultType.Warning: lblMessage.Text = result.Message; break; case Basecore.Model.Enums.BusinessResultType.Info: lblMessage.Text = result.Message; break; default: break; } ucEditLoads_Load(sender, e); } } catch (Exception ex) { lblMessage.Text = "Hata : " + ex.GetBaseException(); } }