Пример #1
0
        public List <OrderMaster> ListMergeOrders(string invoiceGroup)
        {
            List <OrderMaster> result = new List <OrderMaster>();
            string             status = "CR";
            SpCall             spCall = new SpCall("DAT.ORDER_MASTER_MERGE_LIST");

            spCall.SetVarchar("@STATUS", status);
            spCall.SetVarchar("@INVOICE_GROUP", invoiceGroup);
            DataSet ds = db.ExecuteDataSet(spCall);

            if (ds.Tables[0].Rows.Count > 0)
            {
                ds.Tables[0].AsEnumerable().ToList().ForEach(omRow =>
                {
                    OrderMaster om = ReadOrderMaster(omRow);
                    om.OrderItems  = new List <OrderItem>();
                    ds.Tables[1].AsEnumerable().Where(itemRow =>
                                                      itemRow.Field <long>("ORDER_ID") == om.Id).ToList().ForEach(itemRow =>
                                                                                                                  om.OrderItems.Add(InitOrderItem(itemRow)));

                    ds.Tables[2].AsEnumerable().Where(logRow => logRow.Field <long>("ORDER_ID") == om.Id).ToList().ForEach(
                        logRow => om.InvoiceLog = qm.InitLog(logRow));
                    result.Add(om);
                });
            }


            return(result);
        }
Пример #2
0
        public void InsertOrder(OrderMaster orderMaster)
        {
            orderMaster.CreateDate = DateTime.Now;

            SpCall spCall = new SpCall("DAT.ORDER_MASTER_INSERT");

            spCall.SetBigInt("@ID", orderMaster.Id);
            spCall.SetBigInt("@CUSTOMER_ID", orderMaster.Customer.Id);
            spCall.SetDateTime("@ORDER_DATE", orderMaster.OrderDate);
            spCall.SetDateTime("@DELIVERY_DATE", orderMaster.DeliveryDate);
            spCall.SetVarchar("@PAYMENT_TYPE", orderMaster.PaymentType);
            spCall.SetVarchar("@NOTES", orderMaster.Notes);
            spCall.SetVarchar("@ORDER_STATUS", orderMaster.OrderStatus);
            spCall.SetDateTime("@CREATE_DATE", orderMaster.CreateDate);
            spCall.SetVarchar("@CREATE_USER", orderMaster.CreatedUser);
            spCall.SetBigInt("@SHIP_ADDRESS", orderMaster.ShippingAddressId);

            orderMaster.UpdatedUser = orderMaster.CreatedUser;
            orderMaster.UpdateDate  = orderMaster.CreateDate;
            db.ExecuteNonQuery(spCall);

            DataTable dt = PrepareOrderItemsTable(orderMaster.OrderItems);

            db.ExecuteBulkInsert(dt);
        }
Пример #3
0
        public void InsertNewItem(MaestroProductGroup productGroup)
        {
            SpCall call = new SpCall("DAT.PRODUCT_GROUP_INSERT");

            call.SetVarchar("@PRODUCT_GROUP_NAME", productGroup.Name);
            call.SetVarchar("@GROUP_DESCRIPTION", productGroup.GroupDescription);
            call.SetDateTime("@CREATE_DATE", productGroup.CreateDate);
            call.SetVarchar("@CREATE_USER", productGroup.CreatedUser);
            productGroup.Id = db.ExecuteScalar <long>(call);
        }
Пример #4
0
        public void InsertNewItem(MaestroUnitType item)
        {
            SpCall call = new SpCall("DAT.UNIT_TYPE_INSERT");

            call.SetVarchar("@UNIT_TYPE_NAME", item.Name);
            call.SetVarchar("@UNIT_TYPE_DESCRIPTION", item.Description);
            call.SetBit("@CAN_HAVE_UNITS", item.CanHaveUnits);
            call.SetDateTime("@CREATE_DATE", DateTime.Now);
            call.SetVarchar("@CREATE_USER", context.UserName);
            item.Id = db.ExecuteScalar <long>(call);
        }
Пример #5
0
        public void Update(MaestroProductGroup productGroup)
        {
            SpCall call = new SpCall("DAT.PRODUCT_GROUP_UPDATE");

            call.SetBigInt("@ID", productGroup.Id);
            call.SetVarchar("@PRODUCT_GROUP_NAME", productGroup.Name);
            call.SetVarchar("@GROUP_DESCRIPTION", productGroup.GroupDescription);
            call.SetDateTime("@UPDATE_DATE", DateTime.Now);
            call.SetVarchar("@UPDATE_USER", context.UserName);

            db.ExecuteNonQuery(call);
        }
Пример #6
0
        protected override void Update()
        {
            MaestroUnit item = (MaestroUnit)request.TransactionEntityList[0];

            Context.TransactionObject = item;
            SpCall call = new SpCall("DAT.UNIT_UPDATE");

            call.SetBigInt("@ID", item.Id);
            call.SetBigInt("@UNIT_TYPE_ID", item.UnitType.Id);
            call.SetVarchar("@UNIT_NAME", item.Name);
            call.SetVarchar("@QB_UNIT", item.QuickBooksUnit);
            call.SetDateTime("@UPDATE_DATE", DateTime.Now);
            call.SetVarchar("@UPDATE_USER", Context.UserName);
            db.ExecuteNonQuery(call);
        }
Пример #7
0
        protected override void New()
        {
            MaestroRegion region = (MaestroRegion)request.TransactionEntityList[0];

            SpCall call = new SpCall("DAT.REGION_INSERT");

            call.SetVarchar("@POSTAL_CODE", region.PostalCode);
            call.SetVarchar("@REGION_NAME", region.Name);
            call.SetVarchar("@REGION_DESCRIPTION", region.Description);
            call.SetVarchar("@GREATER_REGION", region.GreaterRegion);
            call.SetDateTime("@CREATE_DATE", DateTime.Now);
            call.SetVarchar("@CREATE_USER", Context.UserName);
            region.Id = db.ExecuteScalar <long>(call);

            response.TransactionResult = region;
        }
        public static void InsertCacheRegistryInfo(CacheRegistryInfo cacheRegistryInfo)
        {
            SpCall sp = new SpCall("CACHE.CACHE_REGISTRY_INSERT");

            sp.SetVarchar("@GLOBAL_CACHE_NAME", cacheRegistryInfo.CacheId);
            sp.SetVarchar("@CACHE_ID", cacheRegistryInfo.CacheId);
            sp.SetVarchar("@APPLICATION_CODE", "MAESTRO");
            sp.SetVarchar("@CACHE_HOST_NAME", cacheRegistryInfo.HostName);
            sp.SetDateTime("@UPDATE_DATE", DateTime.Now);
            sp.SetVarchar("@RECORD_STATUS", "A");

            using (Database db = new Database())
            {
                db.ExecuteNonQuery(sp);
            }
        }
Пример #9
0
        protected override void Update()
        {
            MaestroRegion region = (MaestroRegion)request.TransactionEntityList[0];

            SpCall call = new SpCall("DAT.REGION_UPDATE");

            call.SetBigInt("@ID", region.Id);
            call.SetVarchar("@POSTAL_CODE", region.PostalCode);
            call.SetVarchar("@REGION_NAME", region.Name);
            call.SetVarchar("@REGION_DESCRIPTION", region.Description);
            call.SetVarchar("@GREATER_REGION", region.GreaterRegion);
            call.SetDateTime("@UPDATE_DATE", DateTime.Now);
            call.SetVarchar("@UPDATE_USER", Context.UserName);
            db.ExecuteNonQuery(call);
            Context.TransactionObject = region;
            RegionCache.Instance.Reload(true);
        }
Пример #10
0
        void UpdateOrderInternal(OrderMaster orderMaster, bool cleanItems)
        {
            orderMaster.UpdateDate = DateTime.Now;

            SpCall spCall = new SpCall("DAT.ORDER_MASTER_UPDATE");

            spCall.SetBigInt("@ID", orderMaster.Id);
            spCall.SetBigInt("@CUSTOMER_ID", orderMaster.Customer.Id);
            spCall.SetDateTime("@ORDER_DATE", orderMaster.OrderDate);
            spCall.SetDateTime("@DELIVERY_DATE", orderMaster.DeliveryDate);
            spCall.SetVarchar("@PAYMENT_TYPE", orderMaster.PaymentType);
            spCall.SetVarchar("@NOTES", orderMaster.Notes);
            spCall.SetVarchar("@ORDER_STATUS", orderMaster.OrderStatus);
            spCall.SetDateTime("@UPDATE_DATE", orderMaster.UpdateDate);
            spCall.SetVarchar("@UPDATE_USER", orderMaster.UpdatedUser);
            spCall.SetBit("@CLEAN_ORDERITEMS", cleanItems);
            spCall.SetBigInt("@SHIP_ADDRESS", orderMaster.ShippingAddressId);
            db.ExecuteNonQuery(spCall);
        }
Пример #11
0
        protected override void BackUp()
        {
            string guid = Guid.NewGuid().ToString();
            SpCall call = new SpCall("BCK.BACK_UP_CUSTOMER");

            call.SetVarchar("@BATCH_ID", guid);
            call.SetDateTime("@BATCH_DATE", DateTime.Now);
            db.ExecuteNonQuery(call);
            response.TransactionResult = guid;
            response.ResultMessage     = string.Format("Backup created with batch id `{0}`", guid) + Environment.NewLine;
        }
Пример #12
0
        public List <TransactionLog> List(TransactionLogQuery logQuery)
        {
            List <TransactionLog> result = new List <TransactionLog>();

            SpCall call = new SpCall("COR.TRANSACTION_LOG_LIST");

            call.SetBigInt("@ID", logQuery.Id);
            call.SetVarchar("@TRAN_CODE", logQuery.TransactionCode);
            call.SetVarchar("@TRANSACTION_STATUS", logQuery.Status);
            call.SetDateTime("@BEGIN_DATE", logQuery.BeginDate);
            call.SetDateTime("@END_DATE", logQuery.EndDate);
            call.SetVarchar("@CREATE_USER", logQuery.User);

            using (SqlReader reader = db.ExecuteReader(call))
            {
                while (reader.Read())
                {
                    TransactionLog log = new TransactionLog()
                    {
                        Id              = reader.GetInt64("ID"),
                        CreateDate      = reader.GetDateTime("CREATE_DATE"),
                        CreatedUser     = reader.GetString("CREATE_USER"),
                        Log             = reader.GetValue <byte[]>("TRANSACTION_LOG"),
                        LogJson         = reader.GetString("TRANSACTION_JSON"),
                        RecordStatus    = reader.GetString("RECORD_STATUS"),
                        Status          = reader.GetString("TRANSACTION_STATUS"),
                        TransactionCode = reader.GetString("TRAN_CODE"),
                        LogObjectId     = reader.GetInt64("TRANSACTION_OBJECT_ID"),
                        ActionType      = reader.GetString("ACTION_TYPE"),
                        RequestType     = reader.GetString("REQUEST_TYPE"),
                        UpdateDate      = reader.GetDateTime("UPDATE_DATE"),
                        UpdatedUser     = reader.GetString("UPDATE_USER"),
                        Duration        = reader.GetInt32("DURATION")
                    };
                    SetDisplayProperties(log);
                    result.Add(log);
                }
            }

            return(result);
        }
Пример #13
0
        void DeleteOrderItem(OrderItem item)
        {
            item.UpdateDate  = DateTime.Now;
            item.UpdatedUser = context.UserName;

            SpCall spCall = new SpCall("DAT.ORDER_ITEM_DELETE");

            spCall.SetBigInt("@ID", item.Id);
            spCall.SetDateTime("@UPDATE_DATE", item.UpdateDate);
            spCall.SetVarchar("@UPDATE_USER", context.UserName);
            db.ExecuteNonQuery(spCall);
        }
        protected override void Delete()
        {
            long id = ValidateEntityIdFromDataExtension();

            Context.TransactionObject = CustomerProductUnitCache.Instance[id];
            SpCall spCall = new SpCall("DAT.CUSTOMER_PRODUCT_UNIT_DELETE");

            spCall.SetBigInt("@ID", id);
            spCall.SetDateTime("@UPDATE_DATE", DateTime.Now);
            spCall.SetVarchar("@UPDATE_USER", Context.UserName);
            db.ExecuteNonQuery(spCall);
        }