Example #1
0
        public async Task <int> AddAsync(MaterialHistory materialHistory)
        {
            var cmd = QueriesCreatingHelper.CreateQueryInsert(materialHistory);

            cmd += ";SELECT LAST_INSERT_ID();";
            return((await DALHelper.ExecuteQuery <int>(cmd, dbTransaction: DbTransaction, connection: DbConnection)).First());
        }
        public override async Task <int> HandleCommand(DeleteMaterialHistoryCommand request, CancellationToken cancellationToken)
        {
            MaterialHistory materialHistory = null;

            if (request.Model == 0)
            {
                throw new BusinessException("MaterialHistory.NotSelected");
            }
            else
            {
                materialHistory = await _materialHistoryQueries.GetByIdAsync(request.Model);

                if (materialHistory == null)
                {
                    throw new BusinessException("MaterialHistory.NotSelected");
                }
            }

            var rs = -1;

            using (var conn = DALHelper.GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        materialHistory.IsDeleted   = true;
                        materialHistory.DeletedDate = DateTime.Now;
                        materialHistory.DeletedBy   = request.LoginSession.Id;

                        if (await _materialHistoryRepository.UpdateAsync(materialHistory) > 0)
                        {
                            rs = 0;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (rs == 0)
                        {
                            trans.Commit();
                        }
                        else
                        {
                            try { trans.Rollback(); } catch { }
                        }
                    }
                }
            }

            return(rs);
        }
Example #3
0
 public static void AddMaterialHistory(MaterialHistory model)
 {
     try
     {
         var db = new RoyalFinishingDataContext();
         db.MaterialHistories.InsertOnSubmit(model);
         db.SubmitChanges();
         MessageBox.Show("Saved");
     }
     catch
     {
         MessageBox.Show("Unable to save. Try again shortly", "An error occured");
     }
 }
Example #4
0
 public AddMaterialViewModel()
 {
     EmployeeList = RFRepo.GetEmployees();
     MaterialList = RFRepo.GetMaterials();
     if (SearchAllJobs)
     {
         JobList = RFRepo.GetJobs(0);
     }
     else
     {
         JobList = RFRepo.GetJobs(RFRepo.JobStatusInProgress);
     }
     Model = new MaterialHistory();
 }
 public InsertMaterialHistoryCommand(MaterialHistory materialHistory)
 {
     Model = materialHistory;
 }
Example #6
0
 public void SaveState(Status status)
 {
     NeedSave = false;
     status.MaterialHistory = MaterialHistory.ToList();
 }
Example #7
0
        public async Task <int> UpdateAsync(MaterialHistory materialHistory)
        {
            var cmd = QueriesCreatingHelper.CreateQueryUpdate(materialHistory);

            return(await DALHelper.Execute(cmd, dbTransaction : DbTransaction, connection : DbConnection));
        }