private void btnSave_Click(object sender, EventArgs e) { loInventoryType.Id = lId; loInventoryType.Description = GlobalFunctions.replaceChar(txtDescription.Text); if (cboQty.Text != "") { loInventoryType.Qty = cboQty.Text; } else { MessageBoxUI _mb = new MessageBoxUI("You must select a Qty!", GlobalVariables.Icons.Error, GlobalVariables.Buttons.OK); _mb.showDialog(); cboQty.Focus(); return; } if (cboSource.Text != "") { loInventoryType.Source = cboSource.Text; } else { MessageBoxUI _mb = new MessageBoxUI("You must select a Source!", GlobalVariables.Icons.Error, GlobalVariables.Buttons.OK); _mb.showDialog(); cboSource.Focus(); return; } loInventoryType.Remarks = GlobalFunctions.replaceChar(txtRemarks.Text); MySqlTransaction _Trans = GlobalVariables.Connection.BeginTransaction(); try { string _InventoryTypeId = loInventoryType.save(lOperation, ref _Trans); if (_InventoryTypeId != "") { _Trans.Commit(); MessageBoxUI _mb = new MessageBoxUI("Inventory Type has been saved successfully!", GlobalVariables.Icons.Save, GlobalVariables.Buttons.OK); _mb.showDialog(); lRecords[0] = _InventoryTypeId; lRecords[1] = txtDescription.Text; lRecords[2] = cboQty.Text; lRecords[3] = cboSource.Text; lRecords[4] = txtRemarks.Text; object[] _params = { lRecords }; if (lOperation == GlobalVariables.Operation.Edit) { try { ParentList.GetType().GetMethod("updateData").Invoke(ParentList, _params); } catch { } this.Close(); } else { ParentList.GetType().GetMethod("addData").Invoke(ParentList, _params); clear(); //this.Close(); } } } catch (Exception ex) { _Trans.Rollback(); if (ex.Message.Contains("Duplicate")) { MessageBoxUI _mb = new MessageBoxUI("Inventory Type Id already exist!", GlobalVariables.Icons.Information, GlobalVariables.Buttons.OK); _mb.showDialog(); return; } } }
private void btnSave_Click(object sender, EventArgs e) { try { if (cboQty.Text == "") { MessageBoxUI _mb = new MessageBoxUI("Qty must have a value!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mb.showDialog(); cboQty.Focus(); return; } if (cboSource.Text == "") { MessageBoxUI _mb = new MessageBoxUI("Source must have a value!", GlobalVariables.Icons.Warning, GlobalVariables.Buttons.OK); _mb.showDialog(); cboSource.Focus(); return; } loInventoryType.Id = lId; loInventoryType.Description = GlobalFunctions.replaceChar(txtDescription.Text); loInventoryType.Qty = cboQty.Text; loInventoryType.Source = cboSource.Text; loInventoryType.Remarks = GlobalFunctions.replaceChar(txtRemarks.Text); loInventoryType.UserId = GlobalVariables.UserId; string _Id = loInventoryType.save(lOperation); if (_Id != "") { MessageBoxUI _mb = new MessageBoxUI("Inventory Type has been saved successfully!", GlobalVariables.Icons.Save, GlobalVariables.Buttons.OK); _mb.showDialog(); lRecords[0] = _Id; lRecords[1] = txtDescription.Text; lRecords[2] = cboQty.Text; lRecords[3] = cboSource.Text; lRecords[4] = txtRemarks.Text; object[] _params = { lRecords }; if (lOperation == GlobalVariables.Operation.Edit) { ParentList.GetType().GetMethod("updateData").Invoke(ParentList, _params); this.Close(); } else { ParentList.GetType().GetMethod("addData").Invoke(ParentList, _params); clear(); } } else { MessageBoxUI _mb = new MessageBoxUI("Failure to save the record!", GlobalVariables.Icons.Error, GlobalVariables.Buttons.OK); _mb.showDialog(); return; } } catch (Exception ex) { ErrorMessageUI em = new ErrorMessageUI(ex.Message, this.Name, "btnSave_Click"); em.ShowDialog(); return; } }