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 frmComponent() { InitializeComponent(); combal = new ComponentBAL(); com = new tbl_000_H_PART(); err = new ErrorProviderExtended(); }
public Boolean Save(tbl_000_H_PART record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { db.ComponentList.Add(record); db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
public Boolean Delete(tbl_000_H_PART record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { var existrecord = GetByID(record.YEARUSED, record.PartNo); db.ComponentList.Remove(existrecord); db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
public Boolean Update(tbl_000_H_PART record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { var existrecord = GetByID(record.YEARUSED, record.PartNo); db.Entry(existrecord).CurrentValues.SetValues(record); db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
public Boolean Delete(tbl_000_H_PART record) { try { if (record == null) { throw new Exception("Invalid Parameter!"); } if (!comdal.IsExistID(record.YEARUSED, record.PartNo)) { throw new Exception("Record does not exist!"); } return(comdal.Delete(record)); } catch (Exception ex) { throw ex; } }
private void Init_Form() { try { var strheader = "Component"; switch (MyState) { case FormState.Add: LockFields(false); strheader += " - New"; break; case FormState.Edit: case FormState.View: tbl_000_H_PART currcom = new tbl_000_H_PART(); currcom = combal.GetAll().Where(i => i.YEARUSED == yearused && i.PartNo == partno).FirstOrDefault(); mlblLastUpdate.Text = currcom.UpdatedDate.ToString(); AssignRecord(false); LockFields(false); if (MyState == FormState.View) { LockFields(true); mbtnSave.Text = "Edit"; strheader += " - View"; mbtnSave.Focus(); } else { mtxtPartNo.ReadOnly = true; mbtnSave.Text = "Update"; strheader += " - Edit"; } break; } this.Text = strheader; } catch (Exception ex) { throw ex; } }
public frm_DynamicList() { InitializeComponent(); combal = new ComponentBAL(); com = new tbl_000_H_PART(); pibal = new PlasticInjectionBAL(); pi = new tbl_000_H_PI(); vpbal = new VacuumPlatingBAL(); vp = new tbl_000_H_VP(); assybal = new AssymblyBAL(); assy = new tbl_000_H_ASSY(); mrbal = new MODRCBAL(); modrc = new tbl_000_MODRC(); itembal = new ItemBAL(); item = new tbl_000_H_ITEM(); catbal = new CategoryBAL(); cat = new tbl_000_H_CATEGORY(); comlist = new List <tbl_000_H_PART>(); }
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); } }
public Boolean Save(tbl_000_H_PART record) { try { if (record == null) { throw new Exception("Invalid Parameter!"); } if (comdal.IsExistID(record.YEARUSED, record.PartNo)) { throw new Exception("No. already taken!"); } if (comdal.IsExistName(record.YEARUSED, record.PartName)) { throw new Exception("Name already taken!"); } return(comdal.Save(record)); } catch (Exception ex) { throw ex; } }
public frmComponentList() { InitializeComponent(); combal = new ComponentBAL(); com = new tbl_000_H_PART(); }