public Boolean Save(tbl_100_WIP record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { if (BPSUtilitiesV1.NZ(record.WIPMaterials, "").ToString() != "") { foreach (tbl_100_WIP_Materials wipmat in record.WIPMaterials) { db.WIPMaterialsList.Add(wipmat); db.SaveChanges(); } } db.WIPList.Add(record); db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
public Boolean Update(tbl_100_WIP record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { if (BPSUtilitiesV1.NZ(record.WIPMaterials, "").ToString() != "") { foreach (tbl_100_WIP_Materials wipmat in record.WIPMaterials) { if (wipmat.state == "update") { db.Entry(wipmat).State = EntityState.Modified; db.SaveChanges(); } else if (wipmat.state == "add") { db.WIPMaterialsList.Add(wipmat); db.SaveChanges(); } } } dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
public Boolean Delete(tbl_100_WIP record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { var existrecord = GetByID(record.YEARUSED, record.ItemNo, record.PartCode); if (BPSUtilitiesV1.NZ(record.WIPMaterials, "").ToString() != "") { foreach (tbl_100_WIP_Materials mat in record.WIPMaterials) { db.WIPMaterialsList.Remove(mat); db.SaveChanges(); } } db.WIPList.Remove(existrecord); db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
public Boolean Save(tbl_100_WIP record) { try { if (record == null) { throw new Exception("Invalid Parameter!"); } return(wipdal.Save(record)); } catch (Exception ex) { throw ex; } }
public frmWIPCosting() { InitializeComponent(); itembal = new ItemBAL(); itemcombal = new ItemCompositionBAL(); item = new tbl_000_H_ITEM(); itemcom = new tbl_000_H_ITEM_PART(); catbal = new CategoryBAL(); wip = new tbl_100_WIP(); wipbal = new WIPBAL(); wipmatbal = new WIPMaterialsBAL(); wipmatlist = new List <tbl_100_WIP_Materials>(); dt = new DataTable(); err = new ErrorProviderExtended(); }
private void AssignMain() { wip = wipbal.GetByRecID(recid); if (wip == null) { wip = new tbl_100_WIP(); wip.YEARUSED = UserSettings.LogInYear; wip.ItemNo = mtxtItemNo.Text; wip.PartCode = mtxtPartCode.Text; GetRefCompDetails(); wip.PartName = mtxtPartName.Text; wip.CatCode = BPSUtilitiesV1.NZ(mcboCatCode.SelectedValue, "").ToString(); wip.MaterialLabor = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtSubTotal.Text, 0)); wip.ProfitRate = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtProfitRate.Text, 0)); wip.SellingPrice = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtSellingPrice.Text, 0)); wip.ForexRate = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtForex.Text, 0)); wip.CreatedBy = UserSettings.Username; wip.UpdatedBy = UserSettings.Username; wip.Remarks = mtxtRemarks.Text; } }
private void DeleteRecord() { try { FormHelpers.CursorWait(true); var ino = mgridList.Rows[mgridList.SelectedCells[0].RowIndex].Cells["colItemNo"].Value.ToString(); 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"; wip = wipbal.GetByID(UserSettings.LogInYear, ino, pno); if (wipbal.Delete(wip)) { 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 frmWIPCostingList() { InitializeComponent(); wipbal = new WIPBAL(); wip = new tbl_100_WIP(); }
//Get Sub private tbl_100_WIP GetSubDatas(int yearused, string itemno, string partno, tbl_100_WIP exist) { exist.WIPMaterials = wipmatdal.GetByNo(yearused, itemno, partno); return(exist); }