private void DataGridViewMeterProtocol_SelectionChanged(object sender, EventArgs e) { LabelShow.Text = $"Showing {DataGridViewMeterProtocol.CurrentRow.Index + 1} index of {DataGridViewMeterProtocol.RowCount} records"; var meterProtocolId = (int)DataGridViewMeterProtocol.CurrentRow.Cells[0].Value; ReturnInfo getMeterProtocol = _meterProtocol.GetMeterProtocolById(new SmartDB(), meterProtocolId); bool flag = getMeterProtocol.Code == ErrorEnum.NoError; try { TMF.Reports.Model.MeterProtocol meterProtocol = (TMF.Reports.Model.MeterProtocol)getMeterProtocol.BizObject; if (meterProtocol.Id == 0 ? false : true) { TextBoxDescription.Text = meterProtocol.Description; _meterProtocolId = meterProtocol.Id; ButtonEdit.Enabled = true; ButtonDelete.Enabled = true; } } catch (Exception) { return; } }
private void SaveMeterProtocol() { if (!string.IsNullOrWhiteSpace(TextBoxDescription.Text)) { TMF.Reports.Model.MeterProtocol meterProtocol = new TMF.Reports.Model.MeterProtocol() { //TODO User id for CreatedBy Description = TextBoxDescription.Text, CreatedBy = _currentUser.Id.ToString(), DocDate = DateTime.Now, Show = 1, LockCount = 0 }; var createMeterProtocol = _meterProtocol.Create(new SmartDB(), ref meterProtocol); bool flag = createMeterProtocol.Code == ErrorEnum.NoError; if (flag) { MessageBox.Show("Meter Protocol Created"); ResetControls(); BindMeterProtocolWithDataGrid(); } else { MessageBox.Show(createMeterProtocol.Message); } } else { MessageBox.Show("No meter protocol to save or Contact Admin."); } }
private void EditMeterProtocol() { if (!string.IsNullOrWhiteSpace(TextBoxDescription.Text)) { //Todo EditedBy var lockcount = GetLockCount(_meterProtocolId); TMF.Reports.Model.MeterProtocol meterProtocol = new TMF.Reports.Model.MeterProtocol() { Id = _meterProtocolId, Description = TextBoxDescription.Text, EditedBy = _currentUser.Id.ToString(), DocDate = DateTime.Now, Show = 1, LockCount = lockcount }; var updateMeterProtocol = _meterProtocol.Update(new SmartDB(), meterProtocol); bool flag = updateMeterProtocol.Code == ErrorEnum.NoError; if (flag) { MessageBox.Show("Meter Protocol Updated"); ResetControls(); } else { MessageBox.Show(updateMeterProtocol.Message); } } else { MessageBox.Show("No meter protocol to edit or Contact Admin."); } }
public void MeterProtocol_INS_True() { //Arrange TMF.Reports.Model.MeterProtocol meterProtocol = new TMF.Reports.Model.MeterProtocol() { Description = "Protocol B", CreatedBy = "646f18f9-6425-4769-aa79-16ecdb7cf816", DocDate = DateTime.Now, Show = 1, LockCount = 0 }; //Act var createMeterProtocol = _meterProtocol.Create(new SmartDB(), ref meterProtocol); bool flag = createMeterProtocol.Code == ErrorEnum.NoError; //Assert Assert.IsTrue(flag); }