Exemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(amountTxt.Text))
            {
                amountTxt.BackColor = Color.Red;
                return;
            }
            if (string.IsNullOrEmpty(itemTxt.Text))
            {
                itemTxt.BackColor = Color.Red;
                return;
            }
            if (!string.IsNullOrEmpty(existingID))
            {
                if (MessageBox.Show("YES or No?", "Are you sure you want to update the current existing information  ? ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    Labor j = new Labor(existingID, Convert.ToDateTime(dateTxt.Text).Year.ToString(), Convert.ToInt32(weekLbl.Text), startLbl.Text, endLbl.Text, itemTxt.Text, Convert.ToDouble(amountTxt.Text), month);
                    DBConnect.Update(j, existingID);
                    existingID = "";
                }
                return;
            }
            existingID = "";

            string ID = Guid.NewGuid().ToString();
            Labor  i  = new Labor(ID, Convert.ToDateTime(dateTxt.Text).Year.ToString(), Convert.ToInt32(weekLbl.Text), startLbl.Text, endLbl.Text, itemTxt.Text, Convert.ToDouble(amountTxt.Text), month);

            DBConnect.Insert(i);
            MessageBox.Show("Information Saved ");
            itemTxt.Text   = "";
            amountTxt.Text = "";
            autocomplete();
        }
Exemplo n.º 2
0
        public async Task <Labor> GetCurrentLabor()
        {
            generalParameter = await LoadGeneralParameter();

            if (generalParameter != null)
            {
                this.Description    = this.Description?.Trim();
                this.EstimationTime = ValidateInteger(this.EstimationTime);
                this.WorkedTime     = ValidateInteger(this.WorkedTime);
                var mainModel = MainViewModel.GetInstance();
                var oLabor    = new Labor();
                oLabor.LaborId = this.LaborId;
                //Se captura el valor del cuadro de texto de horas estimadas
                oLabor.EstimationTime = obtenerHoras(this.EstimationMin, (int)this.EstimationTime);
                oLabor.LastUpDate     = DateTime.Now;
                DateTime fechaInicio      = this.StartDate;
                string   fechaInicioLabor = fechaInicio.Year + "-" + fechaInicio.Month + "-" + fechaInicio.Day + " " + fechaInicio.Hour + ":" + fechaInicio.Minute + ":" + fechaInicio.Second;
                oLabor.StartDate      = Convert.ToDateTime(fechaInicioLabor);
                oLabor.LastUpdateUser = mainModel.CurrentUser.UserCode;
                //Se captura el valor del cuadro de texto de horas estimadas
                oLabor.WorkedTime = obtenerHoras(this.WorkedMin, (int)this.WorkedTime);
                //Detalle de la labor
                oLabor.Description = this.Description;
                oLabor.Task        = new Models.Task()
                {
                    TaskId = mainModel.TaskSelected
                };
                oLabor.Resource             = mainModel.CurrentUser;
                oLabor.GeneralParameterDays = obtenerDiasHabilesRegistro();
                DateTime fechaActual = DateTime.Now;
                oLabor.EndDate = fechaActual.AddDays(oLabor.GeneralParameterDays * -1);
                return(oLabor);
            }
            return(null);
        }
Exemplo n.º 3
0
 private void itemTxt_Leave(object sender, EventArgs e)
 {
     try
     {
         amountTxt.Text = Labor.List("SELECT * from labor WHERE department='" + itemTxt.Text + "' AND week = '" + weekLbl.Text + "' AND date = '" + Convert.ToDateTime(dateTxt.Text).Year.ToString() + "'").First().Amount.ToString();
     }
     catch (Exception y)
     {
         // Helper.Exceptions(y.Message, "on adding inventory auto fill the category list selected item");
     }
     try
     {
         month = Labor.List("SELECT * from labor WHERE department='" + itemTxt.Text + "' AND week = '" + weekLbl.Text + "' AND date = '" + Convert.ToDateTime(dateTxt.Text).Year.ToString() + "'").First().Month;
     }
     catch (Exception y)
     {
         // Helper.Exceptions(y.Message, "on adding inventory auto fill the category list selected item");
     }
     try
     {
         existingID = Labor.List("SELECT * from labor WHERE department='" + itemTxt.Text + "' AND week = '" + weekLbl.Text + "' AND date = '" + Convert.ToDateTime(dateTxt.Text).Year.ToString() + "'").First().Id.ToString();
     }
     catch (Exception y)
     {
         // Helper.Exceptions(y.Message, "on adding inventory auto fill the category list selected item");
     }
 }
Exemplo n.º 4
0
        public static void AddLabor(Labor model)
        {
            var db = new RoyalFinishingDataContext();

            db.Labors.InsertOnSubmit(model);
            db.SubmitChanges();
        }
Exemplo n.º 5
0
        public ActionResult Edit([Bind(Include = "Id_labor,Name")] Labor labor)
        {
            ViewBag.Id_ExtAttr = new SelectList(db.ExtendedAttributes, "Id_ExtAttr", "Name", labor.Id_ExtAttr);

            if (labor.Name == null)
            {
                ModelState.AddModelError("", "Debe indicar un nombre para la labor");
            }
            if (ModelState.IsValid)
            {
                try
                {
                    var id_ExtAttr = db.Labors.Where(x => x.Id_labor == labor.Id_labor).Select(x => x.Id_ExtAttr).FirstOrDefault();
                    labor.Id_ExtAttr      = id_ExtAttr;
                    db.Entry(labor).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index", new { updated = true }));
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", "Algo salio mal, intente nuevamente");

                    return(View(labor));
                }
            }
            return(View(labor));
        }
        /// <summary>
        /// Pauses timer
        /// </summary>
        public Task PauseAsync()
        {
            if (activeAssignment == null || timerEntry == null)
            {
                return(Task.Factory.StartNew(delegate { }));
            }

            IsBusy    = true;
            Recording = false;

            var labor = new Labor {
                Type         = LaborType.Hourly,
                AssignmentId = activeAssignment.Id,
                Description  = "Time entered automatically at: " + DateTime.Now.ToShortTimeString(),
                Hours        = (DateTime.Now - timerEntry.Date),
            };

            return(service
                   .SaveLaborAsync(labor)
                   .ContinueWith(service.DeleteTimerEntryAsync(timerEntry))
                   .ContinueOnCurrentThread(_ => {
                CurrentHours = TimeSpan.Zero;
                IsBusy = false;
            }));
        }
Exemplo n.º 7
0
 public string Post([FromBody] Labor labor)
 {
     //Create
     db.Labor.Add(labor);
     db.SaveChanges();
     return(JsonConvert.SerializeObject(labor));
 }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Name, Id_ExtAttr")] Labor labor)
        {
            ViewBag.Id_ExtAttr = new SelectList(db.ExtendedAttributes, "Id_ExtAttr", "Name", labor.Id_ExtAttr);


            if (labor.Name == null)
            {
                ModelState.AddModelError("", "Debe seleccionar un nombre para la labor ");
            }
            //if (labor.Id_ExtAttr == null)
            //{
            //    ModelState.AddModelError("", "Debe seleccionar un valor para el atributo extendido ");
            //}
            if (ModelState.IsValid)
            {
                try
                {
                    db.Labors.Add(labor);
                    db.SaveChanges();
                    return(RedirectToAction("Index", new { added = true }));
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", "Algo salio mal, intente nuevamente");
                    return(View(labor));
                }
            }



            return(View(labor));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Edit(int id, [Bind("LaborId,Quantity,Description,LaborCost")] Labor labor)
        {
            if (id != labor.LaborId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(labor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LaborExists(labor.LaborId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(labor));
        }
Exemplo n.º 10
0
        // GET: Labors/Create
        public ActionResult Create(int workOrderId)
        {
            Labor labor = new Labor();

            labor.WorkOrderId = workOrderId;
            return(PartialView("_Create", labor));
        }
Exemplo n.º 11
0
        public LaborDto Add(LaborDto dto)
        {
            Labor labor = Map(dto);

            _context.Labors.Add(labor);
            _context.SaveChanges();
            return(Map(labor));
        }
Exemplo n.º 12
0
        // GET: Labors/Create
        public ActionResult Create(int workOrderId)
        {
            Labor labor = new Labor();

            labor.WorkOrderId   = workOrderId;
            ViewBag.WorkOrderId = new SelectList(db.WorkOrders, "WorkOrderId", "Description", labor.WorkOrderId);
            return(PartialView("_Create", labor));
        }
Exemplo n.º 13
0
        public LaborDto Delete(long id)
        {
            Labor labor = _context.Labors.FirstOrDefault(x => x.Id == id);

            _context.Labors.Remove(labor);
            _context.SaveChanges();
            return(Map(labor));
        }
 /// <summary>
 /// Deletes a labor entry
 /// </summary>
 public Task DeleteLaborAsync(Assignment assignment, Labor labor)
 {
     return(service.DeleteLaborAsync(labor)
            .ContinueWith(t => {
         laborHours.Remove(labor);
         CalculateHours(assignment);
     }));
 }
Exemplo n.º 15
0
        public LaborDto Update(LaborDto dto)
        {
            Labor labor = Map(dto);

            _context.Labors.Update(labor);
            _context.SaveChanges();
            return(Map(labor));
        }
Exemplo n.º 16
0
        public ActionResult DeleteConfirmed(int id)
        {
            Labor labor = db.Labors.Find(id);

            db.Labors.Remove(labor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 17
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Labor labor = await _applicationDbContext.Labors.FindAsync(id);

            _applicationDbContext.Labors.Remove(labor);
            await _applicationDbContext.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 18
0
        public static void ExtractSubMain()
        {
            var         Joao         = new Employee(50);
            ServiceItem s1           = new Labor(5, Joao);
            ServiceItem s2           = new RawMaterial(15, 10);
            var         TotalService = s1.GetTotalPrice() + s2.GetTotalPrice();

            Console.WriteLine(TotalService);
        }
Exemplo n.º 19
0
        public void Execute(object parameter)
        {
            Labor Labor = new Labor();

            Labor.DataContext   = new LaborVM(WorkOrderDetailVM);
            Labor.ShowInTaskbar = false;
            //Labor.Owner = ((App)Application.Current).MainWindow;
            Labor.ShowDialog();
        }
Exemplo n.º 20
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Labor labor = await db.Labors.FindAsync(id);

            db.Labors.Remove(labor);
            await db.SaveChangesAsync();

            return(Json(new { success = true })); //RedirectToAction("Index");
        }
Exemplo n.º 21
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Labor labor = await context.Labors.FindAsync(id);

            context.Labors.Remove(labor);
            await context.SaveChangesAsync();

            return(Json(new { success = true }));
        }
Exemplo n.º 22
0
 public ActionResult Edit([Bind(Include = "idLabor,nombre,precio")] Labor labor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(labor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(labor));
 }
Exemplo n.º 23
0
        public void ClearLaborRelations()
        {
            // remove this job from all related labors
            foreach (var labor in Labor)
            {
                labor.Jobs.Remove(this);
            }

            // then clear labors
            Labor.Clear();
        }
Exemplo n.º 24
0
        public ActionResult Create([Bind(Include = "idLabor,nombre,precio")] Labor labor)
        {
            if (ModelState.IsValid)
            {
                db.Labors.Add(labor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(labor));
        }
Exemplo n.º 25
0
 public ActionResult Edit([Bind(Include = "Lab_id,Lab_name,Lab_OrgId,Lab_status,Ph_no,address,LastName,RoleID,Password,Email")] Labor labor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(labor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Lab_OrgId = new SelectList(db.Organizations, "org_id", "org_name", labor.Lab_OrgId);
     return(View(labor));
 }
Exemplo n.º 26
0
        public async Task <IActionResult> Create([Bind("LaborId,Quantity,Description,LaborCost")] Labor labor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(labor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(labor));
        }
Exemplo n.º 27
0
 public ActionResult Edit([Bind(Include = "LaborID,QuestID,Title,Description,Location")] Labor labor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(labor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.QuestID = new SelectList(db.Quests, "QuestID", "Title", labor.QuestID);
     return(View(labor));
 }
Exemplo n.º 28
0
        public async Task <ActionResult> Edit([Bind(Include = "LaborId,WorkOrderId,ServiceItemCode,ServiceItemName,LaborHours,Rate,Notes,PercentComplete")] Labor labor)
        {
            if (ModelState.IsValid)
            {
                _applicationDbContext.Entry(labor).State = EntityState.Modified;
                await _applicationDbContext.SaveChangesAsync();

                return(Json(new { success = true }));
            }
            return(PartialView("_Edit", labor));
        }
Exemplo n.º 29
0
        public async Task <ActionResult> Create([Bind(Include = "LaborId,WorkOrderId,ServiceItemCode,ServiceItemName,LaborHours,Rate,PercentComplete,Notes")] Labor labor)
        {
            if (ModelState.IsValid)
            {
                context.Labors.Add(labor);
                await context.SaveChangesAsync();

                return(Json(new { success = true }));
            }

            return(PartialView("_Create", labor));
        }
Exemplo n.º 30
0
        public async Task <ActionResult> Edit([Bind(Include = "LaborId,WorkOrderId,ServiceItemCode,ServiceItemName,LaborHours,Rate,ExtendedPrice,Notes")] Labor labor)
        {
            if (ModelState.IsValid)
            {
                _applicationDbContext.Entry(labor).State = EntityState.Modified;
                await _applicationDbContext.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.WorkOrderId = new SelectList(_applicationDbContext.WorkOrders, "WorkOrderId", "Description", labor.WorkOrderId);
            return(View(labor));
        }
Exemplo n.º 31
0
 //public static string GetServiceTotal(IEnumerable<ServiceTotal> serviceList)
 //{
 //    decimal total = (from s in serviceList select s.Total).Sum();
 //    return total.ToString("C2");
 //}
 //public static string GetServiceCount(IEnumerable<ServiceTotal> serviceList)
 //{
 //    int total = (from s in serviceList select s.Cars).Sum();
 //    return total.ToString();
 //}
 public static string GetInvoiceId(Labor l)
 {
     return l.Invoice.Id.ToString();
 }