Beispiel #1
0
        public IList <WorkDetail> GetWorkDetailsByOrder(int id)
        {
            IList <WorkDetail> lista;
            WorkDetail         workDetail;
            SqlCommand         cmdWorkDetail = new SqlCommand();

            cmdWorkDetail.CommandText = "getAllWorkDetailById";
            cmdWorkDetail.CommandType = System.Data.CommandType.StoredProcedure;
            cmdWorkDetail.Parameters.Add(new SqlParameter("@id", id));
            SqlConnection connection = new SqlConnection(connectionString);

            connection.Open();
            cmdWorkDetail.Connection = connection;
            SqlDataReader myReader;

            myReader = cmdWorkDetail.ExecuteReader();
            lista    = new List <WorkDetail>();

            while (myReader.Read())
            {
                workDetail = new WorkDetail();
                workDetail.IdWorkDetail = myReader.GetInt32(0);
                workDetail.Description  = myReader.GetString(1);
                lista.Add(workDetail);
            }
            myReader.Close();
            return(lista);
        }
        //[ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "ComponentSKU,ParentSKU,Work,Id,WorkNo,WorkId,ParentSKUId,ComponentSKUId,GraphSKU,GraphVer,ConsumeQty,StockQty,RequirementQty,Brand,Process,Responsibility,AltOrderProdctionDate,AltProdctionDate1,ActualProdctionDate1,AltProdctionDate2,ActualProdctionDate2,AltProdctionDate3,ActualProdctionDate3,AltProdctionDate4,ActualProdctionDate4,AltProdctionDate5,ActualProdctionDate5,ConfirmUser,Remark1,Remark2,BomComponentId,ParentBomComponentId,OrderKey,CreatedUserId,CreatedDateTime,LastEditUserId,LastEditDateTime")] WorkDetail workDetail)
        {
            if (ModelState.IsValid)
            {
                workDetail.ObjectState = ObjectState.Modified;
                _workDetailService.Update(workDetail);

                _unitOfWork.SaveChanges();
                if (Request.IsAjaxRequest())
                {
                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                DisplaySuccessMessage("Has update a WorkDetail record");
                return(RedirectToAction("Index"));
            }
            var skuRepository = _unitOfWork.Repository <SKU>();

            ViewBag.ComponentSKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", workDetail.ComponentSKUId);
            //var skuRepository = _unitOfWork.Repository<SKU>();
            ViewBag.ParentSKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", workDetail.ParentSKUId);
            var workRepository = _unitOfWork.Repository <Work>();

            ViewBag.WorkId = new SelectList(workRepository.Queryable(), "Id", "WorkNo", workDetail.WorkId);
            if (Request.IsAjaxRequest())
            {
                var modelStateErrors = String.Join("", this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors.Select(n => n.ErrorMessage)));
                return(Json(new { success = false, err = modelStateErrors }, JsonRequestBehavior.AllowGet));
            }
            DisplayErrorMessage();
            return(View(workDetail));
        }
Beispiel #3
0
        public ActionResult RateAdditionManageDetails([Bind(Include = "WorkDetailID,WorkID,RateAdditionID,Qty,Rate,Amount")] WorkDetail workDetail, Decimal?or)
        {
            var getWR = db.FirstOrDefault <Work>("Select Rate From Work Where WorkID= @0", workDetail.WorkID);

            //We have to find the total of this work record
            var WorkTotal = db.FirstOrDefault <decimal>("Select sum(Amount) from WorkDetail where workID=@0 and ItemID IS NOT NULL and LabourID IS NOT NULL", workDetail.WorkID);

            using (var transaction = db.GetTransaction())
            {
                try
                {
                    var RateAdditionRate = db.FirstOrDefault <decimal>("Select Percentage From RateAdditions where RateAdditionID = @0", workDetail.RateAdditionID);
                    workDetail.Amount = WorkTotal * (RateAdditionRate / 100);
                    workDetail.Qty    = RateAdditionRate;
                    db.Update("Work", "WorkID", new { Rate = workDetail.Amount + getWR.Rate - or }, workDetail.WorkID);
                    base.BaseSave <WorkDetail>(workDetail, workDetail.WorkDetailID > 0);
                    transaction.Complete();
                }
                catch (Exception ex)
                {
                    db.AbortTransaction();
                    throw ex;
                }
            }
            return(RedirectToAction("RateAdditionDetails", new { id = workDetail.WorkID }));
        }
Beispiel #4
0
        public OperationResult AddTasks(ItemsViewModel items)
        {
            var result = new OperationResult();

            try
            {
                ToDoModel  context    = new ToDoModel();
                var        repository = new ToDoRepository <WorkDetail>(context);
                WorkDetail entity     = new WorkDetail()
                {
                    WorkContent    = items.WorkContent,
                    Important      = items.IsImportant ? "Y" : "N",
                    Complete       = items.Completed ? "Y" : "N",
                    CreationDate   = DateTime.Now,
                    PlanDate       = items.PlanedDate,
                    LastUpdateDate = DateTime.Now
                };

                repository.Create(entity);
                context.SaveChanges();
                result.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                result.IsSuccessful = false;
                result.exception    = ex;
            }

            return(result);
        }
        public async Task <ActionResult> OnPostWork(string title, string location, string company, DateTime start, DateTime end, string summary)
        {
            this.Error = null;
            if (string.IsNullOrEmpty(title))
            {
                this.Error = "Work Title can't be empty.";
            }

            if (string.IsNullOrEmpty(location))
            {
                this.Error = "Work Location can't be empty.";
            }

            if (string.IsNullOrEmpty(company))
            {
                this.Error = "Project Company can't be empty.";
            }

            if (start.Equals(DateTime.MinValue))
            {
                this.Error = "Start Date is invalid.";
            }

            if (!DateTime.MinValue.Equals(end) && end.CompareTo(start) < 0)
            {
                this.Error = "End Date cannot be after Start Date.";
            }

            if (string.IsNullOrEmpty(summary))
            {
                this.Error = "Work summary can't be empty.";
            }

            if (!string.IsNullOrEmpty(this.Error))
            {
                return(OnGet());
            }

            this.CurrentUser = this.GetUser(HttpContext.User.Identity.Name);
            WorkDetail workDetail = new WorkDetail()
            {
                Company   = company,
                Location  = location,
                Title     = title,
                StartDate = start,
                Summary   = summary
            };

            if (!DateTime.MinValue.Equals(end))
            {
                workDetail.EndDate = end;
            }

            this.CurrentUser.WorkDetails.Add(workDetail);
            await _context.SaveChangesAsync();

            return(Redirect("~/details"));
        }
        /// <summary>
        /// Function to save work detail.
        /// </summary>
        /// <param name="workDetail">work detail information</param>
        /// <param name="applicationType">Application type</param>
        public void InsertOrUpdate(WorkDetail workDetail, ApplicationType applicationType)
        {
            if (workDetail == null)
            {
                throw new ArgumentNullException(WorkDetailConst);
            }

            workDetail.Date = workDetail.Date.Date;
            workDetail.ApplicationID = (byte)applicationType;
            this.timesheetRepository.InsertOrUpdate(workDetail);
            this.unitOfWork.Save();
        }
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            WorkDetail workDetail = _workDetailService.Find(id);

            _workDetailService.Delete(workDetail);
            _unitOfWork.SaveChanges();
            if (Request.IsAjaxRequest())
            {
                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            DisplaySuccessMessage("Has delete a WorkDetail record");
            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// Inserts the specified work detail.
        /// </summary>
        /// <param name="workDetail">The work detail.</param>
        /// <param name="applicationType">Type of the application.</param>
        /// <returns>The total timesheet hours</returns>
        public decimal Insert(WorkDetail workDetail, ApplicationType applicationType)
        {
            if (workDetail == null)
            {
                throw new ArgumentNullException(WorkDetailConst);
            }

            workDetail.Date = workDetail.Date.Date;
            workDetail.ApplicationID = (byte)applicationType;
            var result = this.timesheetRepository.Insert(workDetail);
            this.unitOfWork.Save();

            return result;
        }
        // GET: WorkDetails/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WorkDetail workDetail = _workDetailService.Find(id);

            if (workDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(workDetail));
        }
        // GET: WorkDetails/Create
        public ActionResult Create()
        {
            WorkDetail workDetail = new WorkDetail();
            //set default value
            var skuRepository = _unitOfWork.Repository <SKU>();

            ViewBag.ComponentSKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku");
            //var skuRepository = _unitOfWork.Repository<SKU>();
            ViewBag.ParentSKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku");
            var workRepository = _unitOfWork.Repository <Work>();

            ViewBag.WorkId = new SelectList(workRepository.Queryable(), "Id", "WorkNo");
            return(View(workDetail));
        }
        /// <summary>
        /// Function to save work details.
        /// </summary>
        /// <param name="workDetail">work detail information</param>
        public void InsertOrUpdate(WorkDetail workDetail)
        {
            if (workDetail == null)
            {
                throw new ArgumentNullException(WorkDetailConstant);
            }

            if (workDetail.WorkDetailID == default(int))
            {
                this.unitOfWork.Context.Entry(workDetail).State = EntityState.Added;
            }
            else
            {
                this.unitOfWork.Context.Entry(workDetail).State = EntityState.Modified;
            }
        }
Beispiel #12
0
        public void GenerateWorkDetail(WorkGeneratorViewModel viewmodel)
        {
            var orderdetail   = this._orderdetailservice.Queryable().Include(x => x.Order).Where(x => x.Id == viewmodel.OrderDetailId).First();
            var work          = this.Queryable().Where(x => x.Id == viewmodel.WorkId).First();
            var bomcomponents = this._bomservice.Queryable().Include(x => x.ParentComponent).Include(x => x.SKU).Where(x => viewmodel.WorkingBomComponents.Contains(x.Id)).ToList();
            var list          = new List <WorkDetail>();

            foreach (var bom in bomcomponents)
            {
                WorkDetail item = new WorkDetail();
                item.WorkId   = work.Id;
                item.WorkNo   = work.WorkNo;
                item.StockQty = 0;
                item.AltOrderProdctionDate = orderdetail.Order.OrderDate;
                item.AltProdctionDate1     = orderdetail.Order.OrderDate;
                item.AltProdctionDate2     = orderdetail.Order.OrderDate;
                item.AltProdctionDate3     = orderdetail.Order.OrderDate;
                item.AltProdctionDate4     = orderdetail.Order.OrderDate;
                item.AltProdctionDate5     = orderdetail.Order.OrderDate;
                item.BomComponentId        = bom.Id;
                item.ParentBomComponentId  = bom.ParentComponentId;
                item.ComponentSKUId        = bom.SKUId;
                item.ConsumeQty            = bom.ConsumeQty;
                item.GraphSKU       = bom.GraphSKU;
                item.GraphVer       = "";
                item.OrderKey       = orderdetail.OrderKey;
                item.ParentSKUId    = bom.ParentComponent.SKUId;
                item.Remark1        = bom.Remark1;
                item.Remark2        = bom.Remark2;
                item.RequirementQty = orderdetail.Qty * bom.ConsumeQty;
                item.StockQty       = 0;
                item.ProductionQty  = orderdetail.Qty * bom.ConsumeQty;
                item.DoingQty       = 0;
                item.FinishedQty    = 0;

                var exists = _workdetailservice.Queryable().Where(x => x.WorkId == work.Id && x.ComponentSKUId == bom.SKUId && x.ParentSKUId == bom.ParentComponent.SKUId).Any();
                if (!exists)
                {
                    list.Add(item);
                }
            }
            this._workdetailservice.InsertRange(list);
        }
Beispiel #13
0
        public WorkDetail UpdateWorkDetail(int workDetailId, WorkDetail workDetail)
        {
            SqlCommand cmdWorkDetail = new SqlCommand();

            cmdWorkDetail.CommandText = "update_work_detail";
            cmdWorkDetail.CommandType = System.Data.CommandType.StoredProcedure;
            cmdWorkDetail.Parameters.Add(new SqlParameter("@work_detail_id", workDetailId));
            cmdWorkDetail.Parameters.Add(new SqlParameter("@products_price", workDetail.ProductsPrice));
            cmdWorkDetail.Parameters.Add(new SqlParameter("@description", workDetail.Description));
            cmdWorkDetail.Parameters.Add(new SqlParameter("@work_order_id", workDetail.WorkOrderId));

            SqlConnection  connection  = new SqlConnection(connectionString);
            SqlTransaction transaction = null;

            try
            {
                connection.Open();
                transaction = connection.BeginTransaction();
                cmdWorkDetail.Connection  = connection;
                cmdWorkDetail.Transaction = transaction;
                cmdWorkDetail.ExecuteNonQuery();
                transaction.Commit();
            }
            catch (SqlException ex)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                throw ex;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
            return(workDetail);
        }
        // GET: WorkDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WorkDetail workDetail = _workDetailService.Find(id);

            if (workDetail == null)
            {
                return(HttpNotFound());
            }
            var skuRepository = _unitOfWork.Repository <SKU>();

            ViewBag.ComponentSKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", workDetail.ComponentSKUId);
            //var skuRepository = _unitOfWork.Repository<SKU>();
            ViewBag.ParentSKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", workDetail.ParentSKUId);
            var workRepository = _unitOfWork.Repository <Work>();

            ViewBag.WorkId = new SelectList(workRepository.Queryable(), "Id", "WorkNo", workDetail.WorkId);
            return(View(workDetail));
        }
Beispiel #15
0
        public void InsertarDetalleTrabajo(WorkDetail workDetail)
        {
            SqlCommand cmdProduct = new SqlCommand();

            cmdProduct.CommandText = "Proyecto2Mechanical_insertWorkDetail";
            cmdProduct.CommandType = System.Data.CommandType.StoredProcedure;
            cmdProduct.Parameters.Add(new SqlParameter("@price", workDetail.Price));
            cmdProduct.Parameters.Add(new SqlParameter("@description", workDetail.Description));
            cmdProduct.Parameters.Add(new SqlParameter("@id_work_order", workDetail.WorkOrder.IdWorkOrder));
            SqlConnection  connection  = new SqlConnection(connectionString);
            SqlTransaction transaction = null;

            try
            {
                connection.Open();
                transaction            = connection.BeginTransaction();
                cmdProduct.Connection  = connection;
                cmdProduct.Transaction = transaction;
                cmdProduct.ExecuteNonQuery();
                transaction.Commit();
            }

            catch (SqlException ex)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                throw ex;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }//finally
        }
Beispiel #16
0
        public List <WorkDetail> GetWorkDetails(int workOrderId)
        {
            String         sqlSelect    = "select work_detail_id, products_price, description, work_order_id from work_detail where work_order_id='" + workOrderId + "';";
            SqlDataAdapter daWorkDetail = new SqlDataAdapter(sqlSelect, new SqlConnection(connectionString));
            //daUser.SelectCommand.CommandType = CommandType.StoredProcedure;
            DataSet dsWorkDetail = new DataSet();

            daWorkDetail.Fill(dsWorkDetail, "work_detail");

            Dictionary <int, WorkDetail> dictionary = new Dictionary <int, WorkDetail>();
            WorkDetail workDetail = null;

            foreach (DataRow row in dsWorkDetail.Tables["work_detail"].Rows)
            {
                int workDetailId = Int32.Parse(row["work_detail_id"].ToString());
                if (dictionary.ContainsKey(workDetailId) == false)
                {
                    List <RequiredProduct> products = new List <RequiredProduct>();
                    String sqlProduct = "select required_product_id, material, quantity, price, work_detail_id from required_product where work_detail_id='" + workDetailId + "';";

                    SqlDataAdapter daRequiredProduct = new SqlDataAdapter(sqlProduct, new SqlConnection(connectionString));
                    DataSet        dsRequiredProduct = new DataSet();
                    daRequiredProduct.Fill(dsRequiredProduct, "required_product");
                    RequiredProduct requiredProduct = null;

                    foreach (DataRow rowProduct in dsRequiredProduct.Tables["required_product"].Rows)
                    {
                        int requiredProductId = Int32.Parse(rowProduct["required_product_id"].ToString());
                        requiredProduct = new RequiredProduct(requiredProductId, rowProduct["material"].ToString(), Int32.Parse(rowProduct["quantity"].ToString()), float.Parse(rowProduct["price"].ToString()), Int32.Parse(rowProduct["work_detail_id"].ToString()));
                        products.Add(requiredProduct);
                    }

                    workDetail = new WorkDetail(workDetailId, float.Parse(row["products_price"].ToString()), row["description"].ToString(), Int32.Parse(row["work_order_id"].ToString()), products);
                    dictionary.Add(workDetailId, workDetail);
                }
            }
            return(dictionary.Values.ToList <WorkDetail>());
        }
Beispiel #17
0
        public ActionResult LabourManageDetails([Bind(Include = "WorkDetailID,WorkID,LabourID,Qty,Rate,Amount")] WorkDetail workDetail, Decimal?or)
        {
            var getWR = db.FirstOrDefault <Work>("Select Rate From Work Where WorkID= @0", workDetail.WorkID);

            using (var transaction = db.GetTransaction())
            {
                try
                {
                    var labourRate = db.FirstOrDefault <decimal>("Select Rate From Labour where LabourID = @0", workDetail.LabourID);
                    workDetail.Amount = workDetail.Qty * labourRate;
                    db.Update("Work", "WorkID", new { Rate = workDetail.Amount + getWR.Rate - or }, workDetail.WorkID);
                    base.BaseSave <WorkDetail>(workDetail, workDetail.WorkDetailID > 0);
                    RefreshWorkAdditions(workDetail.WorkID.Value, workDetail.Amount.Value);
                    transaction.Complete();
                }
                catch (Exception ex)
                {
                    db.AbortTransaction();
                    throw ex;
                }
            }
            return(RedirectToAction("LabourDetails", new { id = workDetail.WorkID }));
        }
Beispiel #18
0
        public ActionResult Details([Bind(Include = "WorkDetailID,WorkID,UnitID,Rate,ItemID,Qty,Amount")] WorkDetail workDetail)
        {
            using (var transaction = db.GetTransaction())
            {
                try
                {
                    var getWR       = db.FirstOrDefault <decimal>("Select Rate From Work Where WorkID= @0", workDetail.WorkID);
                    var getItemRate = db.FirstOrDefault <decimal>("Select Rate From Item Where ItemID = @0", workDetail.ItemID);

                    workDetail.Amount = workDetail.Qty * getItemRate;
                    base.BaseSave <WorkDetail>(workDetail, workDetail.WorkDetailID > 0);
                    db.Update("Work", "WorkID", new { Rate = workDetail.Amount + getWR }, workDetail.WorkID);
                    RefreshWorkAdditions(workDetail.WorkID.Value, workDetail.Amount.Value);
                    transaction.Complete();
                }

                catch (Exception ex)
                {
                    db.AbortTransaction();
                    throw ex;
                }
            }
            return(RedirectToAction("Details", new { id = workDetail.WorkID }));
        }
        /// <summary>
        /// Retrieves the work detail.
        /// </summary>
        /// <returns>returns RetrieveWorkDetail</returns>
        private WorkDetail RetrieveWorkDetail()
        {
            var workdetail = new WorkDetail
            {
                Date = this.currentDate,
                ProjectID = Convert.ToInt32(this.projectComboBox.SelectedValue, CultureInfo.CurrentCulture),
                CategoryID = Convert.ToInt32(this.workCategoryComboBox.SelectedValue, CultureInfo.CurrentCulture),
                HoursReported = Convert.ToDecimal(this.hoursTextBox.Text, CultureInfo.CurrentCulture),
                Description = this.descriptionTextBox.Text,
                ClientDependencyFlag = this.isClientDependencyCombBox.IsChecked != null && (bool)this.isClientDependencyCombBox.IsChecked
            };

            workdetail.DeveloperID = this.developer.DeveloperID;

            if (this.Features.Count > 1)
            {
                workdetail.FeatureID = Convert.ToInt32(this.featureComboBox.SelectedValue, CultureInfo.CurrentCulture);
            }

            return workdetail;
        }
Beispiel #20
0
        public void Post([FromBody] WorkDetail workDetail)
        {
            WorkDetailData workDetailData = new WorkDetailData(configuration.GetConnectionString("MechanicalContext").ToString());

            workDetailData.InsertarDetalleTrabajo(workDetail);
        }
Beispiel #21
0
        public static async Task <TemplateFile> Create(AzureFileController azureFileController, User user, string documentLink, Dictionary <string, List <object> > subsetDetails)
        {
            var valuesToFill = new Content(
                new FieldContent("Initials", user.FirstName.ToCharArray()[0].ToString() + user.LastName.ToCharArray()[0].ToString()),
                new FieldContent("FirstName", user.FirstName),
                new FieldContent("LastName", user.LastName),
                new FieldContent("Email", user.UserInfo?.FirstOrDefault()?.AltEmail ?? user.Email),
                new TableContent("EducationTable"),
                new TableContent("CertTable"),
                new TableContent("WorkTable"),
                new TableContent("ProjectTable"),
                new TableContent("SkillTable"));

            subsetDetails["Edu"].ForEach(obj =>
            {
                EducationDetail detail = (EducationDetail)obj;
                valuesToFill
                .Tables
                .FirstOrDefault(table => table.Name.Equals("EducationTable"))
                .AddRow(new FieldContent("SchoolName", detail.SchoolName),
                        new FieldContent("Achievement", detail.Achievement),
                        new FieldContent("Degree", detail.Degree),
                        new FieldContent("EndDate", detail.EndDateTentative ? "Current" : detail.EndDate?.ToShortDateString()),
                        new FieldContent("StartDate", detail.StartDate.ToShortDateString()),
                        new FieldContent("GPA", detail.GPA.ToString()));
            });

            subsetDetails["Cert"].ForEach(obj =>
            {
                CertDetail detail = (CertDetail)obj;
                valuesToFill
                .Tables
                .FirstOrDefault(table => table.Name.Equals("CertTable"))
                .AddRow(new FieldContent("Issuer", detail.Issuer),
                        new FieldContent("Name", detail.Name),
                        new FieldContent("DateAchieved", detail.DateAchieved.ToShortDateString()));
            });

            subsetDetails["Work"].ForEach(obj =>
            {
                WorkDetail detail = (WorkDetail)obj;
                valuesToFill
                .Tables
                .FirstOrDefault(table => table.Name.Equals("WorkTable"))
                .AddRow(new FieldContent("Company", detail.Company),
                        new FieldContent("Location", detail.Location),
                        new FieldContent("Summary", detail.Summary),
                        new FieldContent("EndDate", detail.EndDateTentative ? "Current" : detail.EndDate?.ToShortDateString()),
                        new FieldContent("StartDate", detail.StartDate.ToShortDateString()),
                        new FieldContent("Title", detail.Title.ToString()));

                // TODO add bullets
            });

            subsetDetails["Project"].ForEach(obj =>
            {
                ProjectDetail detail = (ProjectDetail)obj;
                valuesToFill
                .Tables
                .FirstOrDefault(table => table.Name.Equals("ProjectTable"))
                .AddRow(new FieldContent("Company", detail.Company),
                        new FieldContent("Supervisor", detail.Supervisor),
                        new FieldContent("Summary", detail.Summary),
                        new FieldContent("EndDate", detail.EndDateTentative ? "Current" : detail.EndDate?.ToShortDateString()),
                        new FieldContent("StartDate", detail.StartDate.ToShortDateString()),
                        new FieldContent("Title", detail.Title.ToString()));
            });

            subsetDetails["Skill"].ForEach(obj =>
            {
                SkillDetail detail = (SkillDetail)obj;
                valuesToFill
                .Tables
                .FirstOrDefault(table => table.Name.Equals("SkillTable"))
                .AddRow(new FieldContent("Class", detail.Class),
                        new FieldContent("Name", detail.Name),
                        new FieldContent("Level", detail.Level));
            });

            if (user.UserInfo.Any())
            {
                UserInfo info = user.UserInfo.FirstOrDefault();

                if (!string.IsNullOrEmpty(info.NameExt))
                {
                    valuesToFill.Fields.Add(new FieldContent("NameExt", info.NameExt));
                }

                if (!string.IsNullOrEmpty(info.Summary))
                {
                    valuesToFill.Fields.Add(new FieldContent("Summary", info.Summary));
                }

                if (!string.IsNullOrEmpty(info.PhoneNumber))
                {
                    valuesToFill.Fields.Add(new FieldContent("Phone", info.PhoneNumber));
                }

                if (!string.IsNullOrEmpty(info.Website))
                {
                    valuesToFill.Fields.Add(new FieldContent("Website", info.Website));
                }
            }

            string str = await azureFileController.GetFile(FileType.Templates, documentLink);

            using (var outputDocument = new TemplateProcessor(str).SetRemoveContentControls(true).SetNoticeAboutErrors(false))
            {
                outputDocument.FillContent(valuesToFill);
                outputDocument.SaveChanges();
            }

            return(new TemplateFile()
            {
                LocalFile = str
            });
        }
        public Report getReport(int idWorkOrder)
        {
            Report        report = new Report();
            VehicleDetail vehicleDetail;

            SqlCommand cmdReport = new SqlCommand();

            cmdReport.CommandText = "ReporteGeneral";
            cmdReport.CommandType = System.Data.CommandType.StoredProcedure;
            cmdReport.Parameters.Add(new SqlParameter("@idOrdenTrabajo", idWorkOrder));
            SqlConnection connection = new SqlConnection(connectionString);

            connection.Open();
            cmdReport.Connection = connection;
            SqlDataReader myReader;

            myReader = cmdReport.ExecuteReader();

            //Primer conjunto de resultados
            while (myReader.Read())
            {
                if (report.WorkOrder.Vehicle.VehicleId == null)
                {
                    report.WorkOrder.Vehicle.VehicleId    = myReader.GetString(0);
                    report.WorkOrder.Vehicle.Color        = myReader.GetString(1);
                    report.WorkOrder.Vehicle.Brand        = myReader.GetString(2);
                    report.WorkOrder.Vehicle.Style        = myReader.GetString(3);
                    report.WorkOrder.Vehicle.Year         = myReader.GetInt32(4).ToString();
                    report.WorkOrder.Vehicle.Power        = myReader.GetString(5);
                    report.WorkOrder.Vehicle.Displacement = myReader.GetString(6);
                    report.WorkOrder.Vehicle.Capacity     = myReader.GetInt32(7);
                    report.WorkOrder.Vehicle.Weight       = myReader.GetInt32(8);
                    report.WorkOrder.Vehicle.ChasisNumber = myReader.GetString(9);
                    report.WorkOrder.Vehicle.MotorNumber  = myReader.GetString(10);
                }
                vehicleDetail = new VehicleDetail();
                vehicleDetail.IdVehicleDetail        = myReader.GetInt32(11);
                vehicleDetail.Quantity               = myReader.GetInt32(12);
                vehicleDetail.Observations           = myReader.GetString(13);
                vehicleDetail.TypeDetail.Description = myReader.GetString(14);
                vehicleDetail.Condition.Description  = myReader.GetString(15);

                report.VehicleDetailList.Add(vehicleDetail);
            }

            //Avanzo a segundo conjunto de resultados
            myReader.NextResult();
            //Segundo conjunto de resultados
            WorkDetail workDetail;
            Product    product;

            while (myReader.Read())
            {
                product    = new Product();
                workDetail = new WorkDetail();
                if (report.WorkOrder.IdWorkOrder == 0)
                {
                    report.WorkOrder.IdWorkOrder  = myReader.GetInt32(0);
                    report.WorkOrder.Description  = myReader.GetString(1);
                    report.WorkOrder.DeliveryDate = myReader.GetDateTime(2);
                    report.WorkOrder.TotalPrice   = myReader.GetFloat(3);
                    //brinco 4 que es id client
                    //brinco 5 que es id vehicle, ya se insertó en reader anterior.
                }
                workDetail.IdWorkDetail = myReader.GetInt32(6);
                workDetail.Price        = myReader.GetFloat(7);
                workDetail.Description  = myReader.GetString(8);
                report.WorkDetailList.Add(workDetail);

                product.IdProduct = myReader.GetInt32(9);
                product.Name      = myReader.GetString(10);
                product.Quantity  = myReader.GetInt32(11);
                product.Price     = myReader.GetFloat(12);
                report.ProductList.Add(product);
            }

            //Avanzo a tercer conjunto de resultados
            myReader.NextResult();
            //Tercer conjunto de resultados

            while (myReader.Read())
            {
                report.WorkOrder.Client.IdClient    = myReader.GetString(0);
                report.WorkOrder.Client.ClientName  = myReader.GetString(1);
                report.WorkOrder.Client.LastName    = myReader.GetString(2);
                report.WorkOrder.Client.PhoneNumber = myReader.GetString(3);
                report.WorkOrder.Client.Address     = myReader.GetString(4);
                report.WorkOrder.Client.Email       = myReader.GetString(5);
            }

            return(report);
        }
        /// <summary>
        /// Function to delete work detail information.
        /// </summary>
        /// <param name="id">work detail id</param>
        public void Delete(int id)
        {
            var workDetail = new WorkDetail
            {
                WorkDetailID = id
            };

            this.unitOfWork.Context.Entry(workDetail).State = EntityState.Deleted;
        }
 public WorkDetail Put(int id, [FromBody] WorkDetail value)
 {
     return(this.workDetailData.UpdateWorkDetail(id, value));
 }
 public WorkDetail Post([FromBody] WorkDetail value)
 {
     return(this.workDetailData.InsertWorkDetail(value));
 }
 /// <summary>
 /// Inserts the or update.
 /// </summary>
 /// <param name="workDetail">The work detail.</param>
 /// <returns>The total timesheet hours</returns>
 public decimal Insert(WorkDetail workDetail)
 {
     this.InsertOrUpdate(workDetail);
     this.unitOfWork.Context.SaveChanges();
     return this.RetrieveTimesheetHours(workDetail.DeveloperID, workDetail.Date);
 }
Beispiel #27
0
        public WorkDetail InsertWorkDetail(WorkDetail workDetail)
        {
            SqlCommand cmdWorkOrder = new SqlCommand();

            cmdWorkOrder.CommandText = "insert_work_detail";
            cmdWorkOrder.CommandType = System.Data.CommandType.StoredProcedure;
            cmdWorkOrder.Parameters.Add(new SqlParameter("@description", workDetail.Description));
            cmdWorkOrder.Parameters.Add(new SqlParameter("@work_order_id", workDetail.WorkOrderId));

            SqlCommand cmdRequiredProduct = new SqlCommand();

            cmdRequiredProduct.CommandText = "insert_required_product";
            cmdRequiredProduct.CommandType = System.Data.CommandType.StoredProcedure;

            SqlConnection  connection  = new SqlConnection(connectionString);
            SqlTransaction transaction = null;

            try
            {
                connection.Open();
                transaction = connection.BeginTransaction();

                cmdWorkOrder.Connection        = connection;
                cmdWorkOrder.Transaction       = transaction;
                cmdRequiredProduct.Connection  = connection;
                cmdRequiredProduct.Transaction = transaction;

                int wordDetailId = Int32.Parse(cmdWorkOrder.ExecuteScalar().ToString());
                workDetail.WorkDetailId = wordDetailId;

                List <RequiredProduct> products = workDetail.Products;

                foreach (RequiredProduct requiredProduct in products)
                {
                    cmdRequiredProduct.Parameters.Add(new SqlParameter("@material", requiredProduct.Material));
                    cmdRequiredProduct.Parameters.Add(new SqlParameter("@quantity", requiredProduct.Quantity));
                    cmdRequiredProduct.Parameters.Add(new SqlParameter("@price", requiredProduct.Price));
                    cmdRequiredProduct.Parameters.Add(new SqlParameter("@work_detail_id", wordDetailId));

                    cmdRequiredProduct.ExecuteNonQuery();
                    cmdRequiredProduct.Parameters.Clear();
                }

                transaction.Commit();
            }
            catch (SqlException ex)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                throw ex;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
            return(workDetail);
        }