private void New_Job(object sender, EventArgs e)
        {
            JobEntityModel job     = new JobEntityModel();
            bool           newAble = false;

            job.JobEntiryDate = DateTime.Now;
            job.OpenStatus    = true;
            job.CancelFlag    = false;
            job.CreatedBy     = _view.EpiSession.User.Id;
            job.LastUpdatedBy = _view.EpiSession.User.Id;

            var tempExist = _view.jobs.Where(x => x.JobEntityId.Equals(0));

            if (tempExist.Count() == 0)
            {
                newAble = true;
            }

            if (newAble)
            {
                _view.jobs.Add(job);
                _view.bindingJobs.DataSource = _view.jobs.OrderByDescending(o => o.JobEntiryDate);
                _view.BindingJob();
                _view.bindingJobs.Position = _view.bindingJobs.IndexOf(job);
            }
        }
        private void CancelJob(object sender, EventArgs e)
        {
            MetroGrid      grd = sender as MetroGrid;
            JobEntityModel job = _view.jobSelected;

            if (grd.Rows.Count > 0)
            {
                if (job.ProcessFlag)
                {
                    MessageBox.Show(string.Format("Cannot cancel this Job, because Job : {0} was Processed"
                                                  , job.JobEntityName)
                                    , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DialogResult dialogResult = MessageBox.Show("Are you sure to Cancel this job.", "Please confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.Yes)
                {
                    foreach (DataGridViewRow dgr in grd.Rows)
                    {
                        JobTaskModel curr = (JobTaskModel)dgr.DataBoundItem;
                        if (curr.Priority > 0)
                        {
                            curr.CancelFlag     = true;
                            curr.LastUpdateDate = DateTime.Now;
                            _repository.UpdateTask(curr);
                        }
                    }
                    _view.tasks = _repository.GetTasksByJobID(_view.jobSelected.JobEntityId);
                    _view.bindingTasks.DataSource = _view.tasks;
                }
            }
        }
Ejemplo n.º 3
0
 private object[] Take(JobEntityModel model)
 {
     return(new object[]
     {
         "@Id", model.JobEntityId,
         "@OrganizationId", model.OrganizationId,
         "@LastUpdateDate", model.LastUpdateDate,
         "@LastUpdatedBy", model.LastUpdatedBy,
         "@CreationDate", model.CreationDate,
         "@CreatedBy", model.CreatedBy,
         "@JobEntityName", model.JobEntityName,
         "@JobEntiryDate", model.JobEntiryDate,
         "@EntityType", model.EntityType,
         "@Description", model.Description,
         "@PrimaryItemId", model.PrimaryItemId,
         "@PrimaryItemCode", model.PrimaryItemCode,
         "@PrimaryItemModel", model.PrimaryItemModel,
         "@PrimaryQuantity", model.PrimaryQuantity,
         "@Segment1", model.Segment1,
         "@segment2", model.Segment2,
         "@segment3", model.Segment3,
         "@segment4", model.Segment4,
         "@segment5", model.Segment5,
         "@OpenStatus", (model.OpenStatus) ? 1 : 0,
         "@ProcessFlag", (model.ProcessFlag) ? 1 : 0,
         "@CompletedFlag", (model.CompletedFlag) ? 1 : 0,
         "@CancelFlag", (model.CancelFlag) ? 1 : 0,
         "@PoHeaderId", model.PoHeaderId,
         "@PoLineId", model.PoLineId
     });
 }
Ejemplo n.º 4
0
        public void Delete(JobEntityModel model)
        {
            string sql = @"DELETE FROM JobEntities WHERE Id = @Id";

            object[] parms = { "@Id", model.JobEntityId };
            db.Update(sql, parms);
        }
Ejemplo n.º 5
0
        public void Update(JobEntityModel model)
        {
            string sql =
                @"UPDATE JobEntities
                   SET OrganizationId = @OrganizationId
                      ,LastUpdateDate = @LastUpdateDate
                      ,LastUpdatedBy = @LastUpdatedBy
                      ,CreationDate = @CreationDate
                      ,CreatedBy = @CreatedBy
                      ,JobEntityName = @JobEntityName
                      ,JobEntiryDate = @JobEntiryDate
                      ,EntityType = @EntityType
                      ,Description = @Description
                      ,PrimaryItemId = @PrimaryItemId
                      ,PrimaryItemCode = @PrimaryItemCode
                      ,PrimaryItemModel = @PrimaryItemModel
                      ,PrimaryQuantity = @PrimaryQuantity
                      ,Segment1 = @Segment1
                      ,segment2 = @segment2
                      ,segment3 = @segment3
                      ,segment4 = @segment4
                      ,segment5 = @segment5
                      ,OpenStatus = @OpenStatus
                      ,CancelFlag = @CancelFlag
                      ,ProcessFlag = @ProcessFlag
                      ,CompletedFlag = @CompletedFlag
                      ,PoHeaderId = @PoHeaderId
                      ,PoLineId = @PoLineId
                 WHERE Id = @Id";

            db.Update(sql, Take(model));
        }
        private void Selecting_Row(object sender, EventArgs e)
        {
            MetroGrid grid = sender as MetroGrid;

            if (grid.SelectedRows.Count > 0)
            {
                List <JobEntityModel> jobs = new List <JobEntityModel>(); // grid.SelectedRows.DataBoundItem;
                foreach (DataGridViewRow item in grid.SelectedRows)
                {
                    try
                    {
                        JobEntityModel pr = (JobEntityModel)item.DataBoundItem;
                        jobs.Add(pr);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                if (jobs.Count != 0)
                {
                    _view.jobsSelected = jobs;
                }
            }
        }
Ejemplo n.º 7
0
 public JunkerJob(JobEntityModel jobEntityModel) : base(jobEntityModel)
 {
     foreach (TrashPointModel trash in TrashPoints)
     {
         IColShape trashColshape = Alt.CreateColShapeCylinder(new Position(trash.TrashPosition.X, trash.TrashPosition.Y, trash.TrashPosition.Z - 0.9f), 2f, 2f);
         trashColshape.SetData("trash:data", trash);
     }
 }
Ejemplo n.º 8
0
        public int Insert(JobEntityModel model)
        {
            string sql =
                @"INSERT INTO JobEntities
                           (OrganizationId
                           ,LastUpdateDate
                           ,LastUpdatedBy
                           ,CreationDate
                           ,CreatedBy
                           ,JobEntityName
                           ,JobEntiryDate
                           ,EntityType
                           ,Description
                           ,PrimaryItemId
                           ,PrimaryItemCode
                           ,PrimaryItemModel
                           ,PrimaryQuantity
                           ,Segment1
                           ,segment2
                           ,segment3
                           ,segment4
                           ,segment5
                           ,OpenStatus
                           ,CancelFlag
                           ,ProcessFlag
                           ,CompletedFlag
                           ,PoHeaderId
                           ,PoLineId)
                     VALUES
                           (@OrganizationId
                           ,@LastUpdateDate
                           ,@LastUpdatedBy
                           ,@CreationDate
                           ,@CreatedBy
                           ,@JobEntityName
                           ,@JobEntiryDate
                           ,@EntityType
                           ,@Description
                           ,@PrimaryItemId
                           ,@PrimaryItemCode
                           ,@PrimaryItemModel
                           ,@PrimaryQuantity
                           ,@Segment1
                           ,@segment2
                           ,@segment3
                           ,@segment4
                           ,@segment5
                           ,@OpenStatus
                           ,@CancelFlag
                           ,@ProcessFlag
                           ,@CompletedFlag
                           ,@PoHeaderId
                           ,@PoLineId)";

            return(db.Insert(sql, Take(model)));
        }
        private void New_Task(object sender, EventArgs e)
        {
            JobEntityModel job = _view.jobSelected;
            MetroGrid      grd = sender as MetroGrid;

            if (job != null)
            {
                if (job.CancelFlag)
                {
                    MessageBox.Show(string.Format("Job : {0} was Canceled."
                                                  , job.JobEntityName)
                                    , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (job.CompletedFlag)
                {
                    MessageBox.Show(string.Format("Job : {0} was Completed."
                                                  , job.JobEntityName)
                                    , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                try
                {
                    _view.bindingTasks.AddNew();
                    JobTaskModel curr = (JobTaskModel)_view.bindingTasks.Current;
                    curr.TaskNumber = (_view.bindingTasks.Count).ToString();
                    var tasksOnDay = _repository.GetTasksByDateRange(DateTime.Now.Date, DateTime.Now.Date)
                                     .Where(x => x.ReleaseFlag && (string.IsNullOrEmpty(x.MachineNoReady) ? x.MachineNo : x.MachineNoReady) == curr.MachineNo)
                                     .OrderByDescending(o => o.EndDate)
                                     .FirstOrDefault();
                    if (tasksOnDay != null)
                    {
                        curr.StartDate = tasksOnDay.EndDate;
                    }
                    else
                    {
                        curr.StartDate = DateTime.Now;
                    }

                    curr.DueDate = DateTime.Now.AddDays(1);
                    grd.Focus();
                    grd.CurrentCell = grd[12, grd.CurrentCell.RowIndex];
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void Selecting_Job(object sender, EventArgs e)
        {
            MetroGrid grid = sender as MetroGrid;

            try
            {
                JobEntityModel job = (JobEntityModel)grid.CurrentRow.DataBoundItem;
                _view.jobSelected             = job;
                _view.tasks                   = _repository.GetTasksByJobID(job.JobEntityId);
                _view.bindingTasks.DataSource = _view.tasks;
                _view.BindingTask();
            }
            catch { }
        }
Ejemplo n.º 11
0
 public void DeleteJob(JobEntityModel model)
 {
     factory.JobEntityDao.Delete(model);
 }
Ejemplo n.º 12
0
 public void UpdateJob(JobEntityModel model)
 {
     model.LastUpdateDate = DateTime.Now;
     factory.JobEntityDao.Update(model);
 }
Ejemplo n.º 13
0
 public int InsertJob(JobEntityModel model)
 {
     model.CreationDate   = DateTime.Now;
     model.LastUpdateDate = DateTime.Now;
     return(factory.JobEntityDao.Insert(model));
 }
        private void Save_Click(object sender, EventArgs e)
        {
            //CalculateLine();
            MetroGrid      grd        = sender as MetroGrid;
            JobEntityModel job        = _view.jobSelected;
            string         typeLookup = string.Empty;

            //if (!po.SubmitFlag)
            //{
            //if (string.IsNullOrEmpty(job.JobEntityName))
            //{
            //    MessageBox.Show("Job No. is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return;
            //}

            if (string.IsNullOrEmpty(job.PrimaryItemCode))
            {
                MessageBox.Show("Item No. is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (string.IsNullOrEmpty(job.PrimaryItemModel))
            {
                MessageBox.Show("Item Model is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (job.PrimaryQuantity == 0)
            {
                MessageBox.Show("Job Quantiry is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (job.JobEntityId == 0)
            {
                var jobExist = _repository.GetExistingJobNumber(job.JobEntityName);
                if (jobExist != null)
                {
                    MessageBox.Show(string.Format("Job No. '{0}' is dupplicated.", job.JobEntityName), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                job.JobEntityName = _repository.GetNewJobNumber();
                job.JobEntityId   = _repository.InsertJob(job);
            }
            else
            {
                _repository.UpdateJob(job);
            }

            foreach (DataGridViewRow dgr in grd.Rows)
            {
                JobTaskModel line = (JobTaskModel)dgr.DataBoundItem;
                line.LastUpdateDate  = DateTime.Now;
                line.LastUpdatedBy   = _view.EpiSession.User.Id;
                line.JobNumber       = job.JobEntityName;
                line.Description     = line.TaskNumber;
                line.PrimaryQuantity = 1;
                line.MachineId       = 1;

                if (line.TaskId == 0)
                {
                    line.JobId        = job.JobEntityId;
                    line.CreationDate = DateTime.Now;
                    line.CreatedBy    = _view.EpiSession.User.Id;
                    _repository.InsertTask(line);
                }
                else
                {
                    _repository.UpdateTask(line);
                }
            }

            MessageBox.Show("Save Completed.", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
            _view.jobSelected             = job;
            _view.tasks                   = _repository.GetTasksByJobID(job.JobEntityId);
            _view.bindingJobs.DataSource  = _view.jobs;
            _view.bindingTasks.DataSource = _view.tasks;
            //_view.BindingJob();
            //_view.BindingTask();
            _view.bindingJobs.Position = _view.bindingJobs.IndexOf(job);
        }
Ejemplo n.º 15
0
 public CourierJob(JobEntityModel jobEnityModel) : base(jobEnityModel)
 {
 }