示例#1
0
 public frmWIPMT1()
 {
     InitializeComponent();
     mtbal = new WIPMTBAL();
     mt    = new tbl_100_WIP_MT();
     err   = new ErrorProviderExtended();
 }
示例#2
0
 private void AssignRecord(Boolean IsSave)
 {
     try
     {
         if (IsSave)
         {
             mt.YEARUSED = UserSettings.LogInYear;
             mt.PartNo   = mtxtPartNo.Text;
             mt.PartName = mtxtPartName.Text;
             mt.Usage    = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtUsage.Text, 0));
             mt.Process  = mtxtProcess.Text;
             mt.Vendor   = mtxtVendor.Text;
         }
         else
         {
             mt = mtbal.GetByID(UserSettings.LogInYear, pno);
             if (mt != null)
             {
                 mtxtPartNo.Text   = mt.PartNo;
                 mtxtPartName.Text = mt.PartName;
                 mtxtUsage.Text    = mt.Usage.ToString();
                 mtxtProcess.Text  = mt.Process;
                 mtxtVendor.Text   = mt.Vendor;
             }
             else
             {
                 throw new Exception("Record doesn't exist!");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
 public Boolean Delete(tbl_100_WIP_MT record)
 {
     try
     {
         return(mtdal.Delete(record));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#4
0
 public Boolean Save(tbl_100_WIP_MT record)
 {
     using (var dbContextTransaction = db.Database.BeginTransaction())
     {
         try
         {
             db.WIPMTList.Add(record);
             db.SaveChanges();
             dbContextTransaction.Commit();
             return(true);
         }
         catch (Exception ex)
         {
             dbContextTransaction.Rollback();
             throw ex;
         }
     }
 }
示例#5
0
 public Boolean Update(tbl_100_WIP_MT record)
 {
     try
     {
         if (record == null)
         {
             throw new Exception("Invalid Parameter!");
         }
         if (!mtdal.IsExistID(record.YEARUSED, record.PartNo))
         {
             throw new Exception("Record does not exist!");
         }
         return(mtdal.Update(record));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#6
0
 public Boolean Save(tbl_100_WIP_MT record)
 {
     try
     {
         if (record == null)
         {
             throw new Exception("Invalid Parameter!");
         }
         if (mtdal.IsExistID(record.YEARUSED, record.PartNo))
         {
             throw new Exception("No. already taken!");
         }
         return(mtdal.Save(record));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#7
0
 public Boolean Update(tbl_100_WIP_MT record)
 {
     using (var dbContextTransaction = db.Database.BeginTransaction())
     {
         try
         {
             var existrecord = GetByID(record.YEARUSED, record.PartNo);
             db.Entry(existrecord).GetDatabaseValues().SetValues(record);
             db.SaveChanges();
             dbContextTransaction.Commit();
             return(true);
         }
         catch (Exception ex)
         {
             dbContextTransaction.Rollback();
             throw ex;
         }
     }
 }
示例#8
0
 public Boolean Delete(tbl_100_WIP_MT record)
 {
     using (var dbContextTransaction = db.Database.BeginTransaction())
     {
         try
         {
             var existrecord = GetByID(record.YEARUSED, record.PartNo);
             db.WIPMTList.Attach(existrecord);
             db.WIPMTList.Remove(existrecord);
             db.SaveChanges();
             dbContextTransaction.Commit();
             return(true);
         }
         catch (Exception ex)
         {
             dbContextTransaction.Rollback();
             throw ex;
         }
     }
 }
示例#9
0
 private void DeleteRecord()
 {
     try
     {
         FormHelpers.CursorWait(true);
         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";
             mt = mtbal.GetByID(UserSettings.LogInYear, pno);
             if (mtbal.Delete(mt))
             {
                 isSuccess = true;
             }
             if (isSuccess)
             {
                 MessageHelpers.ShowInfo(msg + " Successful!");
                 FillComboBoxes();
                 RefreshGrid();
                 PageManager(1);
             }
             else
             {
                 MessageHelpers.ShowWarning(msg + " Failed!");
             }
         }
     }
     catch (Exception ex)
     {
         MessageHelpers.ShowError(ex.Message);
     }
     finally
     {
         FormHelpers.CursorWait(false);
     }
 }
示例#10
0
 public frmWIPMT1List()
 {
     InitializeComponent();
     mtbal = new WIPMTBAL();
     mt    = new tbl_100_WIP_MT();
 }