private void Delete() { try { FormHelpers.CursorWait(true); var msg = "Deleting"; if (MessageHelpers.ShowQuestion("Are you sure you want to delete record?") == System.Windows.Forms.DialogResult.Yes) { var yearused = UserSettings.LogInYear; var moldno = mgridListPI.Rows[mgridListPI.SelectedCells[0].RowIndex].Cells["colMoldNo"].Value.ToString(); pi = pibal.GetByID(Convert.ToInt32(yearused), moldno.ToString());; if (pibal.Delete(pi)) { MessageHelpers.ShowInfo(msg + " Successful!"); RefreshGrid(); PageManager(1); } else { MessageHelpers.ShowWarning(msg + " Failed!"); } } } catch (Exception ex) { throw ex; } finally { FormHelpers.CursorWait(false); } }
private void AssignRecord(Boolean IsSave) { try { if (IsSave) { tbl_000_H_PI existpi = new tbl_000_H_PI(); existpi = pibal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && w.MoldNo == mtxtMoldNo.Text).FirstOrDefault(); if (existpi == null) { pi.YEARUSED = UserSettings.LogInYear; pi.CreatedDate = DateTime.Now; pi.CreatedBy = UserSettings.Username; pi.IsCopied = false; pi.CopyDate = DateTime.Now; pi.IsImported = false; pi.ImportDate = DateTime.Now; pi.ImportBy = UserSettings.Username; } pi.MoldNo = mtxtMoldNo.Text; pi.MoldName = mtxtMoldName.Text; pi.Oz = mtxtOz.Text; pi.Cavity = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtCavity.Text, 0)); pi.SPH = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtSPH.Text, 0)); pi.PPH = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtPPH.Text, 0)); pi.Cavity = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtCavity.Text, 0)); pi.MolSetUpTime = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtMoldSetupTime.Text, 0)); pi.Usage = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtUsage.Text, 0)); pi.PurgePerG = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtPPG.Text, 0)); pi.IsLocked = mcbLocked.Checked; pi.UpdatedDate = DateTime.Now; pi.UpdatedBy = UserSettings.Username; } else { pi = pibal.GetByID(yearused, moldno); if (pi != null) { mtxtMoldNo.Text = pi.MoldNo; mtxtMoldName.Text = pi.MoldName; mtxtOz.Text = pi.Oz; mtxtPPG.Text = pi.PurgePerG.ToString(); mtxtSPH.Text = Convert.ToInt32(pi.SPH).ToString(); mtxtCavity.Text = Convert.ToInt32(pi.Cavity).ToString(); mtxtPPH.Text = Convert.ToInt32(pi.PPH).ToString(); mtxtMoldSetupTime.Text = pi.MolSetUpTime.ToString(); mtxtUsage.Text = Convert.ToInt32(pi.Usage).ToString(); mcbLocked.Checked = pi.IsLocked; pi.UpdatedDate = DateTime.Now; pi.UpdatedBy = UserSettings.Username; } else { throw new Exception("Record doesn't exist!"); } } } catch (Exception ex) { throw ex; } }