private void AssignRecord(Boolean IsSave) { try { if (IsSave) { mt.YEARUSED = UserSettings.LogInYear; mt.PartNo = mtxtPartNo.Text; mt.PartName = mtxtPartName.Text; mt.Usage = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtUsage.Text, 0)); mt.Process = mtxtProcess.Text; mt.Vendor = mtxtVendor.Text; } else { mt = mtbal.GetByID(UserSettings.LogInYear, pno); if (mt != null) { mtxtPartNo.Text = mt.PartNo; mtxtPartName.Text = mt.PartName; mtxtUsage.Text = mt.Usage.ToString(); mtxtProcess.Text = mt.Process; mtxtVendor.Text = mt.Vendor; } else { throw new Exception("Record doesn't exist!"); } } } catch (Exception ex) { throw ex; } }
private void DeleteRecord() { try { FormHelpers.CursorWait(true); var pno = mgridList.Rows[mgridList.SelectedCells[0].RowIndex].Cells["colPartNo"].Value.ToString(); if (MessageHelpers.ShowQuestion("Are you sure you want to delete record?") == System.Windows.Forms.DialogResult.Yes) { var isSuccess = false; var msg = "Deleting"; mt = mtbal.GetByID(UserSettings.LogInYear, pno); if (mtbal.Delete(mt)) { isSuccess = true; } if (isSuccess) { MessageHelpers.ShowInfo(msg + " Successful!"); FillComboBoxes(); RefreshGrid(); PageManager(1); } else { MessageHelpers.ShowWarning(msg + " Failed!"); } } } catch (Exception ex) { MessageHelpers.ShowError(ex.Message); } finally { FormHelpers.CursorWait(false); } }