public void CreateLine(RetailSOLine soDaily)
        {
            EntityKey[] entitykey = new EntityKey[1];
            if (!string.IsNullOrEmpty(soDaily.Series))
            {
                string orderDate = soDaily.Date.ToShortDateString();

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

                var lineEntity = new AxdEntity_StmSalesSoDailyLine();

                lineEntity.Series = soDaily.Series;
                lineEntity.Model  = soDaily.Model;
                lineEntity.Sink   = soDaily.Sink;

                if (soDaily.Date != DateTime.MinValue)
                {
                    lineEntity.SalesDate          = DateTime.ParseExact(orderDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    lineEntity.SalesDateSpecified = true;
                }

                //lineEntity.SalesDate = orderDate;
                //lineEntity.SalesDateSpecified = true;
                lineEntity.StmStoreId = soDaily.Top;//ใช้เก็บข้อมูล Top แทน
                //lineEntity.SalesPoolId = soDaily.Pool;
                lineEntity.SalesQty                 = Convert.ToDecimal(soDaily.Qty);
                lineEntity.SalesQtySpecified        = true;
                lineEntity.SalesAmount              = Convert.ToDecimal(soDaily.Amount);
                lineEntity.SalesAmountSpecified     = true;
                lineEntity.SalesOrderDaily          = Convert.ToInt64(soDaily.RecIdHeader);
                lineEntity.SalesOrderDailySpecified = true;

                var soLine = new AxdSTMSODailyLine()
                {
                    StmSalesSoDailyLine = new AxdEntity_StmSalesSoDailyLine[1] {
                        lineEntity
                    }
                };

                using (var client = new STMSODailyLineServiceClient())
                {
                    client.ClientCredentials.Windows.ClientCredential.Domain   = UserAccount.Domain;
                    client.ClientCredentials.Windows.ClientCredential.UserName = UserAccount.Username;
                    client.ClientCredentials.Windows.ClientCredential.Password = UserAccount.Password;
                    entitykey = client.create(callContextLine, soLine);
                }

                long refRecId = Convert.ToInt64(entitykey[0].KeyData[0].Value);
                RetailSOLog.Create(refRecId, soDaily.CreateBy);
            }
        }
Ejemplo 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
        }