Ejemplo n.º 1
0
        public int AddSalesOrder(SalesOrder salesorderEntity)

        {
            int result = -1;

            if (salesorderEntity != null)
            {
                _context.SalesOrders.Add(salesorderEntity);
                _context.SaveChanges();
                result = salesorderEntity.SalesOrderId;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public bool UpdateQuotationorder(SalesQuotation Quotation, IList <SalesQuotationItems> QuotationItemList, ref string ErrorMessage)
        {
            ErrorMessage = string.Empty;
            try
            {
                ordercontext.Entry(Quotation).State = EntityState.Modified;
                ordercontext.SaveChanges();

                foreach (var model1 in QuotationItemList)
                {
                    if (model1.IsDummy == 1)
                    {
                        ordercontext.Entry(model1).State = EntityState.Deleted;
                        ordercontext.SaveChanges();
                    }
                    else
                    {
                        if (model1.Sales_QtnItems_Id == 0)
                        {
                            model1.Sales_Qtn_Id = Quotation.Sales_Qtn_Id;
                            ordercontext.salesquotationitem.Add(model1);
                            ordercontext.SaveChanges();
                        }
                        else
                        {
                            ordercontext1.salesquotationitem.Attach(model1);
                            ordercontext1.Entry(model1).State = EntityState.Modified;
                            //goodscontext.SaveChanges();
                        }
                        ordercontext1.SaveChanges();
                    }
                }

                return(true);
            }
            //catch (Exception ex)
            //{
            //    ExceptionHandler.LogException(ex);
            //    ErrorMessage = ex.Message;
            //    return false;
            //}
            catch (DbEntityValidationException dbEx)
            {
                var errorList = new List <string>();

                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        errorList.Add(String.Format("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage));
                    }
                }
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool AddNewQuotation(SalesOrder salesorder, IList <SalesOrderItems> orderItemList, ref string ErrorMessage)
        {
            ErrorMessage = string.Empty;
            try
            {
                // findid(id);
                ordercontext.salesorder.Add(salesorder);

                ordercontext.SaveChanges();

                int currentId = salesorder.Sales_Order_Id;

                for (int i = 0; i < orderItemList.Count; i++)
                {
                    orderItemList[i].Sales_Order_Id = currentId;
                }

                ordercontext.salesorderitem.AddRange(orderItemList);

                ordercontext.SaveChanges();

                return(true);
            }

            catch (DbEntityValidationException dbEx)
            {
                var errorList = new List <string>();

                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        errorList.Add(String.Format("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage));
                    }
                }
                return(false);
            }
            //catch (Exception ex)
            //{
            //    ExceptionHandler.LogException(ex);
            //    ErrorMessage = ex.Message;
            //    return false;
            //}
        }