Exemplo n.º 1
0
        public IQueryable <View_StocktakeDetails> QueryRequestDetails(View_StocktakeDetails condition, DateTime?dateStart, DateTime?dateEnd)
        {
            StocktakeDetailBLL bll = new StocktakeDetailBLL();

            //condition.ReadyForCount = true;
            return(bll.QueryDetails(condition, dateStart, dateEnd));
        }
Exemplo n.º 2
0
        public void UpdateRequest(NewStocktakeRequest request, List <int> removedDetailsList, List <View_StocktakeDetails> changedDetails)
        {
            StocktakeDetailBLL bll = new StocktakeDetailBLL(Context);

            List <View_StocktakeDetails> detailsList = bll.QueryDetails(new View_StocktakeDetails {
                RequestID = request.RequestID
            }, null, null).ToList();

            //removed items
            for (int i = detailsList.Count - 1; i >= 0; i--)
            {
                if (removedDetailsList.Contains(detailsList[i].PartID.Value))
                {
                    detailsList.RemoveAt(i);
                }
            }
            //changed items
            foreach (var item in changedDetails)
            {
                View_StocktakeDetails detail = detailsList.Find(d => d.PartID == item.PartID);
                if (detail != null)
                {
                    detail.StocktakeType  = item.StocktakeType;
                    detail.Priority       = item.Priority;
                    detail.NotifyComments = item.NotifyComments;
                    detail.DetailsDesc    = item.DetailsDesc;
                }
                else
                {
                    detailsList.Add(item);
                }
            }

            if (detailsList != null)
            {
                request.Details = detailsList.Select(d => new NewStocktakeDetails {
                    PartID = d.PartID.ToString(), StocktakePriority = d.Priority.Value, Description = d.DetailsDesc, StocktakeTypeID = d.StocktakeType.Value
                }).ToList();
            }
            Type[]        types  = new Type[] { typeof(NewStocktakeDetails) };
            XmlSerializer xs     = new XmlSerializer(typeof(NewStocktakeRequest), types);
            string        reqStr = string.Empty;

            using (StringWriter sw = new StringWriter())
            {
                xs.Serialize(sw, request);
                reqStr = sw.ToString();
            }
            DbParameter paramXml = Context.CreateDbParameter("Request", System.Data.DbType.Xml, reqStr, ParameterDirection.Input);

            Context.ExecuteNonQuery("sp_UpdateRequest", CommandType.StoredProcedure, paramXml);
        }