public ActionResult <IDataPacker> SalesReportByMonth(
            int subCategoryId, string salesYear, string halfYear)
        {
            var packer = new DataPacker();

            var fromDate = DateTime.Parse(halfYear == "first" ?
                                          salesYear + "-01-01" : salesYear + "-07-01");
            var toDate = DateTime.Parse(halfYear == "first" ?
                                        salesYear + "-06-30" : salesYear + "-12-31");

            object[] yearMonth = new object[7];

            yearMonth[0] = subCategoryId;
            for (int month = 1; month < 7; month++)
            {
                yearMonth[month] = halfYear == "first" ?
                                   salesYear + string.Format("{0:00}", month)
                    : salesYear + string.Format("{0:00}", (month + 6));
            }

            var SalesReport   = _reportService.RetrieveSubCategorySalesReport(yearMonth);
            var ProductReport = _reportService.Retrieve("d_productsalesreport",
                                                        subCategoryId, fromDate, toDate);

            if (ProductReport.RowCount == 0)
            {
                return(NotFound());
            }

            packer.AddDataStore("SalesReport", SalesReport);
            packer.AddDataStore("ProductReport", ProductReport);

            return(packer);
        }
Exemplo n.º 2
0
        public ActionResult <IDataPacker> SaveSalesOrderAndDetail(IDataUnpacker unPacker)
        {
            var packer      = new DataPacker();
            var orderHeader = unPacker.GetDataStore("dw1", "d_order_header_free");
            var orderDetail = unPacker.GetDataStore("dw2", "d_order_detail_list");

            try
            {
                var saleOrderId = _saleService.SaveSalesOrderAndDetail(orderHeader,
                                                                       orderDetail);

                if (saleOrderId > 0)
                {
                    packer.AddDataStore("SalesOrderHeader",
                                        _saleService.Retrieve("d_order_header_free", saleOrderId));
                    packer.AddDataStore("SalesOrderHeader.SalesOrderDetail",
                                        _saleService.Retrieve("d_order_detail_list", saleOrderId));
                }
                packer.AddValue("Status", "Success");
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> SavePerson(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            try
            {
                var person        = unpacker.GetDataStore("dw1", "d_person");
                var personAddress = unpacker.GetDataStore("dw2", "d_address");
                var personPhone   = unpacker.GetDataStore("dw3", "d_personphone");
                var customer      = unpacker.GetDataStore("dw4", "d_customer");

                var personId = _personService.SavePerson(person, personAddress,
                                                         personPhone, customer);

                if (personId > 0)
                {
                    packer.AddDataStore("Person",
                                        _personService.Retrieve("d_person", personId));
                    packer.AddDataStore("Person.PersonAddress",
                                        _personService.Retrieve("d_businessentityaddress", personId));
                    packer.AddDataStore("Person.PersonPhone",
                                        _personService.Retrieve("d_personphone", personId));
                    packer.AddDataStore("Person.Customer",
                                        _personService.Retrieve("d_customer", personId));
                }
                packer.AddValue("Status", "Success");
            }

            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> CategorySalesReport(
            string queryFrom, string queryTo)
        {
            var packer = new DataPacker();

            var dataFrom     = DateTime.Parse(queryFrom);
            var dataTo       = DateTime.Parse(queryTo);
            var lastDataFrom = DateTime.Parse(queryFrom).AddYears(-1);
            var lastDataTo   = DateTime.Parse(queryTo).AddYears(-1);

            var CategoryReport = _reportService.Retrieve("d_categorysalesreport_d",
                                                         dataFrom, dataTo);

            if (CategoryReport.RowCount == 0)
            {
                return(NotFound());
            }

            packer.AddDataStore("Category.SalesReport", CategoryReport);

            packer.AddDataStore("Category.LastYearSalesReport",
                                _reportService.Retrieve("d_categorysalesreport_d",
                                                        lastDataFrom, lastDataTo));

            return(packer);
        }
        public ActionResult <IDataPacker> Savechanges(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            var status      = "Success";
            int?intPersonId = 0;

            try
            {
                var personAddress = unpacker.GetDataStore("dw1", "d_businessentityaddress");
                var personPhone   = unpacker.GetDataStore("dw2", "d_personphone");
                var customer      = unpacker.GetDataStore("dw3", "d_customer");

                if (personAddress.RowCount > 0)
                {
                    status      = _personService.Update(true, personAddress);
                    intPersonId = personAddress.GetItem <int?>(0, "businessentityid");
                }

                if (personPhone.RowCount > 0 && status == "Success")
                {
                    status      = _personService.Update(true, personPhone);
                    intPersonId = personPhone.GetItem <int?>(0, "businessentityid");
                }

                if (customer.RowCount > 0 && status == "Success")
                {
                    status      = _personService.Update(true, customer);
                    intPersonId = customer.GetItem <int?>(0, "personid");
                }

                if (status == "Success")
                {
                    packer.AddDataStore("Person",
                                        _personService.Retrieve("d_person", intPersonId));
                    packer.AddDataStore("Person.PersonAddress",
                                        _personService.Retrieve("d_businessentityaddress", intPersonId));
                    packer.AddDataStore("Person.PersonPhone",
                                        _personService.Retrieve("d_personphone", intPersonId));
                    packer.AddDataStore("Person.Customer",
                                        _personService.Retrieve("d_customer", intPersonId));
                }

                packer.AddValue("Status", status);
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> WinOpen()
        {
            var packer = new DataPacker();
            int cateId = 0;

            var category    = _reportService.Retrieve("d_dddw_category");
            var subCategory = _reportService.Retrieve("d_subcategory", cateId);

            if (category.RowCount == 0 || subCategory.RowCount == 0)
            {
                return(NotFound());
            }

            packer.AddDataStore("Category", category);
            packer.AddDataStore("SubCategory", subCategory, true);

            return(packer);
        }
        public ActionResult <IDataPacker> Retrieve(string dwname, int id)
        {
            var packer = new DataPacker();

            try
            {
                switch (dwname)
                {
                case "d_subcategory":
                    packer.AddDataStore("SubCategory",
                                        _productService.Retrieve("d_subcategory_list", id), true);

                    break;

                case "d_product":
                    packer.AddDataStore("Product",
                                        _productService.Retrieve("d_product", id));

                    packer.AddDataStore("dddwSubCategory",
                                        _productService.Retrieve("d_subcategory_list", id));

                    break;

                case "d_history_price":
                    packer.AddDataStore("HistoryPrice",
                                        _productService.Retrieve("d_history_price", id));
                    packer.AddDataStore("dddwProduct",
                                        _productService.Retrieve("d_dddw_product"));

                    if (_productService.retrieveProductPhote(id, out string photoname,
                                                             out byte[] largePhoto))
                    {
                        packer.AddValue("photo", largePhoto);
                        packer.AddValue("photoname", photoname);
                    }
                    else
                    {
                        packer.AddValue("photo", "");
                        packer.AddValue("photoname", "");
                    }

                    break;
                }
            }
        public ActionResult <IDataPacker> WinOpen()
        {
            var packer    = new DataPacker();
            int intCateId = 0;

            var productCate = _productService.Retrieve("d_dddw_category");

            if (productCate.RowCount > 0)
            {
                intCateId = productCate.GetItem <int>(0, "productcategoryid");
            }

            packer.AddValue("CateId", intCateId.ToString());
            packer.AddDataStore("Category", productCate);
            packer.AddDataStore("SubCategory",
                                _productService.Retrieve("d_subcategory_list", intCateId), true);
            packer.AddDataStore("Units", _productService.Retrieve("d_dddw_unit"));

            return(packer);
        }
        public ActionResult <IDataPacker> WinOpen()
        {
            var packer = new DataPacker();

            try
            {
                packer.AddDataStore("Address",
                                    _personService.Retrieve("d_dddw_address"));
                packer.AddDataStore("AddressType",
                                    _personService.Retrieve("d_dddw_addresstype"));
                packer.AddDataStore("PhonenumberType",
                                    _personService.Retrieve("d_dddw_phonenumbertype"));
                packer.AddDataStore("CustomerTerritory",
                                    _personService.Retrieve("d_dddw_territory"));
                packer.AddDataStore("Store",
                                    _personService.Retrieve("d_dddw_store"));
                packer.AddDataStore("Person",
                                    _personService.Retrieve("d_person_list", "IN"));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> RetrievePersonByKey(int personId)
        {
            var packer = new DataPacker();

            try
            {
                packer.AddDataStore("Person",
                                    _personService.Retrieve("d_person", personId));
                packer.AddDataStore("Person.PersonAddress",
                                    _personService.Retrieve("d_businessentityaddress", personId));
                packer.AddDataStore("Person.PersonPhone",
                                    _personService.Retrieve("d_personphone", personId));
                packer.AddDataStore("Person.Customer",
                                    _personService.Retrieve("d_customer", personId));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
Exemplo n.º 11
0
        public ActionResult <IDataPacker> RetrieveSaleOrderDetail(
            int salesOrderId, int customerId)
        {
            var packer = new DataPacker();

            try
            {
                packer.AddDataStore("SalesOrderDetail",
                                    _saleService.Retrieve("d_order_detail_list", salesOrderId));

                packer.AddDataStore("DddwAddress",
                                    _saleService.Retrieve("d_dddw_customer_address", customerId));

                packer.AddDataStore("DddwCreditcard",
                                    _saleService.Retrieve("d_dddw_customer_creditcard", customerId));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
Exemplo n.º 12
0
        public ActionResult <IDataPacker> RetrieveDropdownModel(string modelName, int CodeId)
        {
            var packer = new DataPacker();

            try
            {
                switch (modelName)
                {
                case "Customer":
                    packer.AddDataStore("DddwAddress",
                                        _saleService.Retrieve("d_dddw_customer_address", CodeId));
                    packer.AddDataStore("DddwCreditcard",
                                        _saleService.Retrieve("d_dddw_customer_creditcard", CodeId));
                    break;
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
Exemplo n.º 13
0
        public ActionResult <IDataPacker> WinOpen()
        {
            var packer = new DataPacker();

            try
            {
                packer.AddDataStore("Customer",
                                    _saleService.Retrieve("d_dddw_customer_individual"));
                packer.AddDataStore("SalesPerson",
                                    _saleService.Retrieve("d_dddw_salesperson"));
                packer.AddDataStore("SalesTerritory",
                                    _saleService.Retrieve("d_dddw_salesterritory"));
                packer.AddDataStore("ShipMethod",
                                    _saleService.Retrieve("d_dddw_shipmethod"));
                packer.AddDataStore("OrderProduct",
                                    _saleService.Retrieve("d_dddw_order_production"));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> WinOpen()
        {
            var packer = new DataPacker();

            var stateProvince = _addressService.Retrieve("d_dddw_stateprovince");

            if (stateProvince.RowCount == 0)
            {
                return(NotFound());
            }

            packer.AddDataStore("StateProvince", stateProvince);

            return(packer);
        }
        public ActionResult <IDataPacker> RetrieveAddress(int provinceId, string city)
        {
            var packer = new DataPacker();

            if (city == "$")
            {
                city = "%";
            }

            var addressData = _addressService.Retrieve("d_address", provinceId, city);

            if (addressData.RowCount == 0)
            {
                return(NotFound());
            }

            packer.AddDataStore("Address", addressData);

            return(packer);
        }
Exemplo n.º 16
0
        public ActionResult <IDataPacker> RetrieveSaleOrderList(
            int customerId, string dateFrom, string dateTo)
        {
            var packer   = new DataPacker();
            var fromDate = DateTime.Parse(dateFrom);
            var toDate   = DateTime.Parse(dateTo);

            try
            {
                packer.AddDataStore("SalesOrderHeader",
                                    _saleService.Retrieve("d_order_header_grid",
                                                          fromDate, toDate, customerId));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> SaveChanges(IDataUnpacker unpacker)
        {
            string status = String.Empty;

            var packer = new DataPacker();

            var detail = unpacker.GetDataStore("dw1");

            try
            {
                status = _addressService.Update(detail);
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            packer.AddDataStore("Address", detail);
            packer.AddValue("Status", status);

            return(packer);
        }
Exemplo n.º 18
0
        public ActionResult <IDataPacker> SaveChanges(IDataUnpacker unpacker)
        {
            string status    = "Success";
            var    packer    = new DataPacker();
            var    modelname = unpacker.GetValue <string>("arm1");

            try
            {
                switch (modelname)
                {
                case "SaleOrderHeader":
                    var orderHeader = unpacker.GetDataStore("dw1", "d_order_header_free");
                    status = _saleService.Update(true, orderHeader);

                    packer.AddDataStore("SalesOrderHeader", orderHeader);

                    break;

                case "SaleOrderDetail":
                    var orderDetail = unpacker.GetDataStore("dw1", "d_order_detail_list");
                    status = _saleService.Update(true, orderDetail);

                    packer.AddValue("SaleOrderDetail.SalesOrderDetail",
                                    orderDetail.RowCount);

                    break;
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            packer.AddValue("Status", status);

            return(packer);
        }