private void AssignRecord(Boolean IsSave) { try { if (IsSave) { tbl_000_H_PART existcom = new tbl_000_H_PART(); existcom = combal.GetAll().Where(m => m.YEARUSED == UserSettings.LogInYear && m.PartNo == mtxtPartNo.Text).FirstOrDefault(); if (existcom == null) { com.YEARUSED = UserSettings.LogInYear; com.PartNo = mtxtPartNo.Text; com.CreatedDate = DateTime.Now; com.CreatedBy = UserSettings.Username; com.IsCopied = false; com.CopyDate = DateTime.Now; com.IsImported = false; com.ImportDate = DateTime.Now; com.ImportBy = UserSettings.Username; } com.PartName = mtxtPartName.Text; com.WholeQty = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtWholeQty.Text, 0)); com.WholeUnit = mtxtWholeUnit.Text; com.ConversionQty = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtConversionQty.Text, 0)); com.ConversionUnit = mtxtConversionUnit.Text; com.WholePrice = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtWholePrice.Text, 0)); com.ConversionPrice = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtConversionPrice.Text, 0)); com.PreviousPrice = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtPreviousPrice.Text, 0)); com.IsLocked = mcbLocked.Checked; com.ExpDate = DateTime.Now; com.UpdatedDate = DateTime.Now; com.UpdatedBy = UserSettings.Username; } else { com = combal.GetByID(yearused, partno); if (com != null) { mtxtPartNo.Text = com.PartNo; mtxtPartName.Text = com.PartName; mcbLocked.Checked = com.IsLocked; mtxtPreviousPrice.Text = String.Format("{0:n4}", com.PreviousPrice); mtxtWholePrice.Text = String.Format("{0:n4}", com.WholePrice); mtxtWholeQty.Text = String.Format("{0:n2}", com.WholeQty); mtxtWholeUnit.Text = com.WholeUnit; mtxtConversionPrice.Text = String.Format("{0:n4}", com.ConversionPrice); mtxtConversionQty.Text = String.Format("{0:n2}", com.ConversionQty); mtxtConversionUnit.Text = com.ConversionUnit; } else { throw new Exception("Record doesn't exist!"); } } } catch (Exception ex) { throw ex; } }
public void DeleteRecord() { try { FormHelpers.CursorWait(true); var year = UserSettings.LogInYear; int yearused = year; var no = mgridList.Rows[mgridList.SelectedCells[0].RowIndex].Cells["colPartNo"].Value.ToString(); string partno = no; if (MessageHelpers.ShowQuestion("Are you sure want to delete record?") == DialogResult.Yes) { var isSuccess = false; var msg = "Deleting"; com = combal.GetByID(yearused, partno); if (combal.Delete(com)) { isSuccess = true; } if (isSuccess) { MessageHelpers.ShowInfo(msg + " Successful!"); RefreshGrid(); PageManager(1); } else { MessageHelpers.ShowWarning(msg + " Failed!"); } } } catch (Exception ex) { MessageHelpers.ShowError(ex.Message); } finally { FormHelpers.CursorWait(false); } }