Exemplo n.º 1
0
        public void Put(RetailSO parmSo)
        {
            /// response JSON
            ///
            /// {
            ///    "RecId": "5637147579",
            ///    "Pool": "WARDROBE"
            /// }

            EntityKey[]   entitykey  = new EntityKey[1];
            AxdSalesDaily axdSoDaily = new AxdSalesDaily();

            try
            {
                var callContext = new CallContext()
                {
                    MessageId   = Guid.NewGuid().ToString(),
                    LogonAsUser = string.Format(@"{0}\{1}", UserAccount.Domain, UserAccount.Username),
                    Language    = "en-us"
                };

                using (var client = new SalesDailyServiceClient())
                {
                    client.ClientCredentials.Windows.ClientCredential.Domain   = UserAccount.Domain;
                    client.ClientCredentials.Windows.ClientCredential.UserName = UserAccount.Username;
                    client.ClientCredentials.Windows.ClientCredential.Password = UserAccount.Password;
                    axdSoDaily = client.read(callContext, Critera.read(parmSo.RecId));
                }

                string duedate     = parmSo.DueDate.ToShortDateString();
                string confirmdate = parmSo.ConfirmDate.ToShortDateString();
                string orderDate   = parmSo.Date.ToShortDateString();

                using (var client = new SalesDailyServiceClient())
                {
                    AxdEntity_StmSalesSoDaily soDailyEntity = axdSoDaily.StmSalesSoDaily[0];
                    var axdSODaily2 = new AxdSalesDaily()
                    {
                        ClearNilFieldsOnUpdate          = axdSoDaily.ClearNilFieldsOnUpdate,
                        ClearNilFieldsOnUpdateSpecified = true,
                        DocPurpose          = axdSoDaily.DocPurpose,
                        DocPurposeSpecified = true,
                        SenderId            = axdSoDaily.SenderId
                    };


                    var soDailyEntityNew = new AxdEntity_StmSalesSoDaily();
                    soDailyEntityNew._DocumentHash  = soDailyEntity._DocumentHash; ///for update method
                    soDailyEntityNew.RecId          = Convert.ToInt64(parmSo.RecId);
                    soDailyEntityNew.RecIdSpecified = true;
                    if (duedate != "01/01/1900" && duedate != "01/01/0544")//(soDaily.DueDate != DateTime.MinValue)
                    {
                        soDailyEntityNew.DueDate          = DateTime.ParseExact(duedate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        soDailyEntityNew.DueDateSpecified = true;
                    }

                    if (parmSo.ConfirmDate != DateTime.MinValue)
                    {
                        soDailyEntityNew.ConfirmDate          = DateTime.ParseExact(confirmdate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        soDailyEntityNew.ConfirmDateSpecified = true;
                    }

                    if (orderDate != "01/01/1900" && orderDate != "01/01/0544") //(soDaily.Date != DateTime.MinValue)
                    {
                        soDailyEntityNew.SalesDate = DateTime.ParseExact(orderDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        soDailyEntityNew.SalesDate = soDailyEntity.SalesDate;
                    }

                    soDailyEntityNew.SalesDateSpecified   = true;
                    soDailyEntityNew.SalesPoolId          = parmSo.Pool;// string.IsNullOrEmpty(soDaily.Pool) ? soDailyEntity.SalesPoolId : soDaily.Pool;
                    soDailyEntityNew.PurchId              = parmSo.PurchId;
                    soDailyEntityNew.SalesId              = parmSo.SalesId;
                    soDailyEntityNew.SalesName            = parmSo.CustName;
                    soDailyEntityNew.SalesQty             = Convert.ToDecimal(parmSo.Qty);    // string.IsNullOrEmpty(soDaily.Qty.ToString()) ? Convert.ToDecimal(soDailyEntity.SalesQty) : Convert.ToDecimal(soDaily.Qty);
                    soDailyEntityNew.SalesQtySpecified    = true;
                    soDailyEntityNew.StmStoreId           = parmSo.StoreId;                   //string.IsNullOrEmpty(soDaily.StoreId) ? soDailyEntity.StmStoreId : soDaily.StoreId;
                    soDailyEntityNew.SalesAmount          = Convert.ToDecimal(parmSo.Amount); // Convert.ToDecimal(soDaily.Amount) == soDailyEntity.SalesAmount ? Convert.ToDecimal(soDailyEntity.SalesAmount) : Convert.ToDecimal(soDaily.Amount);
                    soDailyEntityNew.SalesAmountSpecified = true;

                    axdSODaily2.StmSalesSoDaily = new AxdEntity_StmSalesSoDaily[1] {
                        soDailyEntityNew
                    };

                    client.ClientCredentials.Windows.ClientCredential.Domain   = UserAccount.Domain;
                    client.ClientCredentials.Windows.ClientCredential.UserName = UserAccount.Username;
                    client.ClientCredentials.Windows.ClientCredential.Password = UserAccount.Password;
                    client.update(callContext, Critera.read(parmSo.RecId), axdSODaily2);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public void Post(RetailSO parmSo)
        {
            #region Create sales daily
            EntityKey[] entitykey = new EntityKey[1];

            var callContext = new CallContext()
            {
                MessageId   = Guid.NewGuid().ToString(),
                LogonAsUser = string.Format(@"{0}\{1}", UserAccount.Domain, UserAccount.Username),
                Language    = "en-us"
            };

            string duedate     = parmSo.DueDate.ToShortDateString();
            string confirmdate = parmSo.ConfirmDate.ToShortDateString();
            string orderDate   = parmSo.Date.ToShortDateString();

            AxdEntity_StmSalesSoDaily order = new AxdEntity_StmSalesSoDaily();
            if (parmSo.DueDate != DateTime.MinValue)
            {
                order.DueDate          = DateTime.ParseExact(duedate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                order.DueDateSpecified = true;
            }
            if (parmSo.ConfirmDate != DateTime.MinValue)
            {
                order.ConfirmDate          = DateTime.ParseExact(confirmdate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                order.ConfirmDateSpecified = true;
            }
            if (parmSo.Date != DateTime.MinValue)
            {
                order.SalesDate          = DateTime.ParseExact(orderDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                order.SalesDateSpecified = true;
            }

            //order.SalesDate = DateTime.Now;
            //order.SalesDateSpecified = true;
            order.StmStoreId = parmSo.StoreId;
            order.SalesId    = parmSo.SalesId;
            order.SalesName  = parmSo.CustName;
            order.PurchId    = parmSo.PurchId;

            order.SalesPoolId          = parmSo.Pool;
            order.SalesQty             = Convert.ToDecimal(parmSo.Qty);
            order.SalesQtySpecified    = true;
            order.SalesAmount          = Convert.ToDecimal(parmSo.Amount);
            order.SalesAmountSpecified = true;

            var orderList = new AxdSalesDaily()
            {
                StmSalesSoDaily = new AxdEntity_StmSalesSoDaily[1] {
                    order
                }
            };

            using (var client = new SalesDailyServiceClient())
            {
                client.ClientCredentials.Windows.ClientCredential.Domain   = UserAccount.Domain;
                client.ClientCredentials.Windows.ClientCredential.UserName = UserAccount.Username;
                client.ClientCredentials.Windows.ClientCredential.Password = UserAccount.Password;
                entitykey = client.create(callContext, orderList);
            }

            long refRecId = Convert.ToInt64(entitykey[0].KeyData[0].Value);

            #region Create Log
            RetailSOLog.Create(refRecId, parmSo.CreateBy);
            #endregion

            #endregion
        }