Exemplo n.º 1
0
        private void LoadItemSuppliers(int itemId)
        {
            mItemSuppliersTbl.Clear();

            DataTable dtSuppliers = ItemSupplierDAL.GetAllItemSuppliersByItemId(itemId);

            foreach (DataRow row in dtSuppliers.Rows)
            {
                int          supplierId = StringUtil.GetSafeInt(row["SupplierId"]);
                SupplierType supplier   = SupplierDAL.GetSupplierById(supplierId);
                if (supplier == null)
                {
                    continue;
                }
                DataRow rowLoc = mItemSuppliersTbl.NewRow();
                rowLoc["SupplierId"]   = supplierId;
                rowLoc["SupplierName"] = supplier.SupplierName;
                rowLoc["URL"]          = StringUtil.GetSafeString(row["SouringURL"]);
                rowLoc["Price"]        = StringUtil.GetSafeDouble(row["Price"]);
                rowLoc["ShippingFee"]  = StringUtil.GetSafeDouble(row["ShippingFee"]);
                rowLoc["Comment"]      = StringUtil.GetSafeString(row["Comment"]);
                mItemSuppliersTbl.Rows.Add(rowLoc);
            }

            this.dgvItemSuppliers.DataSource = mItemSuppliersTbl;
        }
Exemplo n.º 2
0
        private void LoadExistingSourcingNote()
        {
            if (mSourcingNote == null)
            {
                return;
            }

            SupplierType supplier = SupplierDAL.GetSupplierById(mSourcingNote.SupplierId);

            if (supplier == null)
            {
                return;
            }

            mSupplier = supplier;

            this.textBoxSupplier.Text     = supplier.SupplierName;
            this.textBoxExtraFee.Text     = mSourcingNote.ExtraFee.ToString();
            this.textBoxShippingFee.Text  = mSourcingNote.ShippingFee.ToString();
            this.textBoxTotalFee.Text     = mSourcingNote.TotalFee.ToString();
            this.textBoxComment.Text      = mSourcingNote.Comment;
            this.dateTimePickerDate.Value = mSourcingNote.SourcingDate;

            String skuListStr   = mSourcingNote.ItemSkuList;
            String numListStr   = mSourcingNote.ItemNumList;
            String priceListStr = mSourcingNote.ItemPriceList;

            String [] skuArr   = skuListStr.Split(new char[] { ',' });
            String [] numArr   = numListStr.Split(new char[] { ',' });
            String[]  priceArr = priceListStr.Split(new char[] { ',' });

            if (skuArr.Length != numArr.Length || skuArr.Length != priceArr.Length)
            {
                return;
            }

            for (int ii = 0; ii < skuArr.Length; ++ii)
            {
                String            sku  = skuArr[ii];
                InventoryItemType item = ItemDAL.GetItemBySKU(sku);
                if (item == null)
                {
                    continue;
                }

                DataRow dr = mItemsTable.NewRow();
                dr["ItemSKU"]   = sku;
                dr["ItemName"]  = item.ItemName;
                dr["ItemPrice"] = StringUtil.GetSafeDouble(priceArr[ii]);
                dr["ItemCount"] = StringUtil.GetSafeInt(numArr[ii]);

                mItemsTable.Rows.Add(dr);
            }

            this.dgvItems.DataSource = mItemsTable;
        }
Exemplo n.º 3
0
        private static DeliveryNoteType GetDeliveryNoteFromDataRow(DataRow dr)
        {
            DeliveryNoteType note = new DeliveryNoteType();

            note.DeliveryNoteId   = StringUtil.GetSafeInt(dr["DeliveryNoteId"]);
            note.DeliveryDate     = StringUtil.GetSafeDateTime(dr["DeliveryDate"]);
            note.DeliveryOrderIds = StringUtil.GetSafeString(dr["DeliveryOrderIds"]);
            note.DeliveryUser     = StringUtil.GetSafeString(dr["DeliveryUser"]);
            note.DeliveryFee      = StringUtil.GetSafeDouble(dr["DeliveryFee"]);
            note.DeliveryExtraFee = StringUtil.GetSafeDouble(dr["DeliveryExtraFee"]);
            note.DeliveryComment  = StringUtil.GetSafeString(dr["DeliveryComment"]);

            return(note);
        }
Exemplo n.º 4
0
        // Returns null if no record corresponds to itemID;
        public static EbayActiveListingType GetOneActiveListing(String itemID)
        {
            if (itemID == null || itemID.Trim().Length == 0)
            {
                return(null);
            }

            String sql_getOneActiveListing = String.Format("select * from [ActiveListing] where ItemID='{0}'", itemID);

            DataTable dt = DataFactory.ExecuteSqlReturnTable(sql_getOneActiveListing);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            DataRow dr = dt.Rows[0];
            EbayActiveListingType activeListing = new EbayActiveListingType();

            activeListing.ListId            = StringUtil.GetSafeInt(dr["ListId"]);
            activeListing.SellerName        = StringUtil.GetSafeString(dr["SellerName"]);
            activeListing.ItemID            = itemID;
            activeListing.Title             = StringUtil.GetSafeString(dr["Title"]);
            activeListing.ListingType       = StringUtil.GetSafeString(dr["ListingType"]);
            activeListing.GalleryURL        = StringUtil.GetSafeString(dr["GalleryURL"]);
            activeListing.QuantityBid       = StringUtil.GetSafeInt(dr["QuantityBid"]);
            activeListing.MaxBid            = StringUtil.GetSafeDouble(dr["MaxBid"]);
            activeListing.StartPrice        = StringUtil.GetSafeDouble(dr["StartPrice"]);
            activeListing.BuyItNowPrice     = StringUtil.GetSafeDouble(dr["BuyItNowPrice"]);
            activeListing.CurrencyID        = StringUtil.GetSafeString(dr["CurrencyID"]);
            activeListing.StartTime         = StringUtil.GetSafeDateTime(dr["StartTime"]);
            activeListing.EndTime           = StringUtil.GetSafeDateTime(dr["EndTime"]);
            activeListing.ViewItemURL       = StringUtil.GetSafeString(dr["ViewItemURL"]);
            activeListing.ListDuration      = StringUtil.GetSafeInt(dr["ListDuration"]);
            activeListing.PrivateListing    = StringUtil.GetSafeBool(dr["PrivateListing"]);
            activeListing.Quantity          = StringUtil.GetSafeInt(dr["Quantity"]);
            activeListing.QuantityAvailable = StringUtil.GetSafeInt(dr["QuantityAvailable"]);
            activeListing.SellingStatus     = StringUtil.GetSafeString(dr["SellingStatus"]);
            activeListing.SKU          = StringUtil.GetSafeString(dr["SKU"]);
            activeListing.TimeLeft     = StringUtil.GetSafeString(dr["TimeLeft"]);
            activeListing.WatchCount   = StringUtil.GetSafeInt(dr["WatchCount"]);
            activeListing.BidCount     = StringUtil.GetSafeInt(dr["BidCount"]);
            activeListing.BidderCount  = StringUtil.GetSafeInt(dr["BidCount"]);
            activeListing.CurrentPrice = StringUtil.GetSafeDouble(dr["BidCount"]);
            activeListing.FVF          = StringUtil.GetSafeDouble(dr["BidCount"]);
            activeListing.ImagePath    = StringUtil.GetSafeString(dr["ImagePath"]);

            return(activeListing);
        }
Exemplo n.º 5
0
        public static bool ModifyOneDeliveryNote(DeliveryNoteType note)
        {
            bool result = false;

            if (note == null || note.DeliveryNoteId <= 0)
            {
                return(false);
            }

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [DeliveryNote] set DeliveryDate=@DeliveryDate, DeliveryOrderIds=@DeliveryOrderIds,"
                              + "DeliveryUser=@DeliveryUser, DeliveryFee=@DeliveryFee, DeliveryExtraFee=@DeliveryExtraFee, DeliveryComment=@DeliveryComment"
                              + " where DeliveryNoteId=@DeliveryNoteId";

            DataFactory.AddCommandParam(cmd, "@DeliveryDate", DbType.DateTime, StringUtil.GetSafeDateTime(note.DeliveryDate));
            DataFactory.AddCommandParam(cmd, "@DeliveryOrderIds", DbType.String, StringUtil.GetSafeString(note.DeliveryOrderIds));
            DataFactory.AddCommandParam(cmd, "@DeliveryUser", DbType.String, StringUtil.GetSafeString(note.DeliveryUser));
            DataFactory.AddCommandParam(cmd, "@DeliveryFee", DbType.Double, StringUtil.GetSafeDouble(note.DeliveryFee));
            DataFactory.AddCommandParam(cmd, "@DeliveryExtraFee", DbType.Double, StringUtil.GetSafeDouble(note.DeliveryExtraFee));
            DataFactory.AddCommandParam(cmd, "@DeliveryComment", DbType.String, StringUtil.GetSafeString(note.DeliveryComment));

            DataFactory.AddCommandParam(cmd, "@DeliveryNoteId", DbType.Int32, note.DeliveryNoteId);

            try
            {
                if (DataFactory.DbConnection.State == ConnectionState.Closed)
                {
                    DataFactory.DbConnection.Open();
                }
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (DataException)
            {
                // Write to log here.
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(result);
        }
Exemplo n.º 6
0
        private static SourcingNoteType GetSourcingNoteFromDataRow(DataRow dr)
        {
            SourcingNoteType note = new SourcingNoteType();

            note.SourcingId    = StringUtil.GetSafeInt(dr["SourcingId"]);
            note.SupplierId    = StringUtil.GetSafeInt(dr["SupplierId"]);
            note.ItemSkuList   = StringUtil.GetSafeString(dr["ItemSkuList"]);
            note.ItemNumList   = StringUtil.GetSafeString(dr["ItemNumList"]);
            note.ItemPriceList = StringUtil.GetSafeString(dr["ItemPriceList"]);
            note.ExtraFee      = StringUtil.GetSafeDouble(dr["ExtraFee"]);
            note.ShippingFee   = StringUtil.GetSafeDouble(dr["ShippingFee"]);
            note.TotalFee      = StringUtil.GetSafeDouble(dr["TotalFee"]);
            note.Comment       = StringUtil.GetSafeString(dr["Comment"]);
            note.SourcingDate  = StringUtil.GetSafeDateTime(dr["SourcingDate"]);
            return(note);
        }
Exemplo n.º 7
0
        private void buttonSaveItemSupplier_Click(object sender, EventArgs e)
        {
            List <ItemSupplierType> itemSupplierList = new List <ItemSupplierType>();

            int itemId = GetSelectedItemId();

            if (itemId <= 0)
            {
                return;
            }

            // Delete all suppliers for this item.
            ItemSupplierDAL.DeleteItemSuppliers(itemId);

            foreach (DataGridViewRow row in dgvItemSuppliers.Rows)
            {
                int    supplierId  = StringUtil.GetSafeInt(row.Cells[SupplierIdIndex].Value);
                String URL         = StringUtil.GetSafeString(row.Cells[URLIndex].Value);
                Double price       = StringUtil.GetSafeDouble(row.Cells[PriceIndex].Value);
                Double shippingFee = StringUtil.GetSafeDouble(row.Cells[ShippingFeeIndex].Value);
                String comment     = StringUtil.GetSafeString(row.Cells[CommentIndex].Value);

                if (supplierId <= 0 || URL == "")
                {
                    continue;
                }

                ItemSupplierType itemSupplier = new ItemSupplierType();
                itemSupplier.ItemId      = itemId;
                itemSupplier.SupplierId  = supplierId;
                itemSupplier.SourcingURL = URL;
                itemSupplier.Price       = price;
                itemSupplier.ShippingFee = shippingFee;
                itemSupplier.Comment     = comment;
                itemSupplier.CreatedDate = DateTime.Now;

                itemSupplierList.Add(itemSupplier);
            }

            foreach (ItemSupplierType itemSupplier in itemSupplierList)
            {
                ItemSupplierDAL.AddOneItemSupplier(itemSupplier);
            }

            MessageBox.Show("保存供应商信息成功", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 8
0
        //
        // GetMyeBaySelling
        //  Use this call to return information from the All Selling section of the authenticated user's My eBay account.
        //      http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetMyeBaySelling.html
        //

        public static List <EbayActiveListingType> GetMyActiveListing(AccountType account)
        {
            if (account.SellerApiContext == null)
            {
                Logger.WriteSystemLog("Invalid API context in GetMyActiveListing.");
                return(null);
            }

            GetMyeBaySellingCall getMyeBaySellingApiCall = new GetMyeBaySellingCall(account.SellerApiContext);

            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll };
            getMyeBaySellingApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            getMyeBaySellingApiCall.SellingSummary         = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.SellingSummary.Include = true;

            getMyeBaySellingApiCall.ActiveList              = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.ActiveList.Include      = true;
            getMyeBaySellingApiCall.ActiveList.IncludeNotes = true;
            //getMyeBaySellingApiCall.ActiveList.ListingType = ListingTypeCodeType.FixedPriceItem;
            getMyeBaySellingApiCall.ActiveList.Pagination = new PaginationType();
            getMyeBaySellingApiCall.ActiveList.Pagination.EntriesPerPage = 25; // max 200 default 25
            getMyeBaySellingApiCall.ActiveList.Pagination.PageNumber     = 1;



            //getMyeBaySellingApiCall.BidList = new ItemListCustomizationType();
            //getMyeBaySellingApiCall.BidList.Include = true;
            //getMyeBaySellingApiCall.BidList.Pagination = new PaginationType();
            //getMyeBaySellingApiCall.BidList.Pagination.EntriesPerPage = 25;
            //getMyeBaySellingApiCall.BidList.Pagination.PageNumber = 1;

            getMyeBaySellingApiCall.GetMyeBaySelling();

            AmountType amountLimitRemaining   = getMyeBaySellingApiCall.Summary.AmountLimitRemaining;
            long       quantityLimitRemaining = getMyeBaySellingApiCall.Summary.QuantityLimitRemaining;

            PaginatedItemArrayType paginatedItemArray = getMyeBaySellingApiCall.ActiveListReturn;

            if (paginatedItemArray == null || paginatedItemArray.ItemArray == null)
            {
                return(null);
            }

            List <EbayActiveListingType> activeListings = new List <EbayActiveListingType>();

            foreach (ItemType item in paginatedItemArray.ItemArray)
            {
                EbayActiveListingType activeListing = new EbayActiveListingType();
                activeListing.ListId     = 0; // to be set
                activeListing.SellerName = account.ebayAccount;
                activeListing.ItemID     = StringUtil.GetSafeString(item.ItemID);
                activeListing.Title      = StringUtil.GetSafeString(item.Title);
                if (item.ListingTypeSpecified)
                {
                    if (ListingTypeCodeType.FixedPriceItem == item.ListingType)
                    {
                        activeListing.ListingType = "FixedPriceItem";
                    }
                    else if (ListingTypeCodeType.Auction == item.ListingType ||
                             ListingTypeCodeType.Chinese == item.ListingType)
                    {
                        activeListing.ListingType = "Auction";
                    }
                    else
                    {
                        activeListing.ListingType = "Unknown";
                    }
                }
                else
                {
                    activeListing.ListingType = "Unknown";
                }
                if (item.PictureDetails != null)
                {
                    activeListing.GalleryURL = StringUtil.GetSafeString(item.PictureDetails.GalleryURL);
                }
                else
                {
                    activeListing.GalleryURL = "";
                }

                if (item.BiddingDetails != null)
                {
                    activeListing.QuantityBid = StringUtil.GetSafeInt(item.BiddingDetails.QuantityBid);
                    if (item.BiddingDetails.MaxBid != null)
                    {
                        activeListing.MaxBid = StringUtil.GetSafeDouble(item.BiddingDetails.MaxBid.Value);
                    }
                    else
                    {
                        activeListing.MaxBid = 0.0;
                    }
                }
                else
                {
                    activeListing.QuantityBid = 0;
                    activeListing.MaxBid      = 0.0;
                }

                if (item.StartPrice != null)
                {
                    activeListing.StartPrice = StringUtil.GetSafeDouble(item.StartPrice.Value);
                }
                else
                {
                    activeListing.StartPrice = 0.0;
                }


                if (item.BuyItNowPrice != null)
                {
                    activeListing.BuyItNowPrice = StringUtil.GetSafeDouble(item.BuyItNowPrice.Value);
                    activeListing.CurrencyID    = StringUtil.GetSafeString(item.BuyItNowPrice.currencyID);
                }
                else
                {
                    activeListing.BuyItNowPrice = 0.0;
                    activeListing.CurrencyID    = "";
                }

                if (item.ListingDetails != null)
                {
                    activeListing.StartTime   = StringUtil.GetSafeDateTime(item.ListingDetails.StartTime);
                    activeListing.EndTime     = StringUtil.GetSafeDateTime(item.ListingDetails.EndTime);
                    activeListing.ViewItemURL = StringUtil.GetSafeString(item.ListingDetails.ViewItemURL);
                }

                activeListing.ListDuration      = StringUtil.GetSafeInt(StringUtil.GetSafeListDurationDays(item.ListingDuration));
                activeListing.PrivateListing    = StringUtil.GetSafeBool(item.PrivateListing);
                activeListing.Quantity          = StringUtil.GetSafeInt(item.Quantity);
                activeListing.QuantityAvailable = StringUtil.GetSafeInt(item.QuantityAvailable);
                if (item.SellingStatus != null)
                {
                    if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Active)
                    {
                        activeListing.SellingStatus = "Active";
                    }
                    else if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Completed)
                    {
                        activeListing.SellingStatus = "Completed";
                    }
                    else if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Ended)
                    {
                        activeListing.SellingStatus = "Ended";
                    }
                    else
                    {
                        activeListing.SellingStatus = "Unknown";
                    }

                    if (item.SellingStatus.BidCountSpecified)
                    {
                        activeListing.BidCount = item.SellingStatus.BidCount;
                    }
                    else
                    {
                        activeListing.BidCount = 0;
                    }

                    if (item.SellingStatus.BidderCountSpecified)
                    {
                        activeListing.BidderCount = (int)item.SellingStatus.BidderCount;
                    }
                    else
                    {
                        activeListing.BidderCount = 0;
                    }

                    if (item.SellingStatus.CurrentPrice != null)
                    {
                        activeListing.CurrentPrice = item.SellingStatus.CurrentPrice.Value;
                    }
                    else
                    {
                        activeListing.CurrentPrice = 0.0;
                    }
                }
                else
                {
                    activeListing.SellingStatus = "Unknown";
                }
                activeListing.SKU        = StringUtil.GetSafeString(item.SKU);
                activeListing.TimeLeft   = StringUtil.GetSafeString(item.TimeLeft);
                activeListing.WatchCount = StringUtil.GetSafeInt(item.WatchCount);

                activeListings.Add(activeListing);
            }

            Logger.WriteSystemLog(string.Format("Successfully called GetMyActiveListing, returns {0} entries", activeListings.Count));
            return(activeListings);
        } // GetMyActiveListing
Exemplo n.º 9
0
        public static bool InsertOneActiveListing(EbayActiveListingType activeListing)
        {
            EbayActiveListingType existedActiveListing = GetOneActiveListing(activeListing.ItemID);

            if (existedActiveListing != null)
            {
                Logger.WriteSystemLog(string.Format("Active listing with itemId={0} alreay exists.", activeListing.ItemID));
                return(false);
            }

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"insert into [ActiveListing] (ItemID, SellerName, Title, ListingType, GalleryURL, QuantityBid,MaxBid,"
                              + "StartPrice, BuyItNowPrice, CurrencyID, StartTime, EndTime, ViewItemURL, ListDuration, PrivateListing,"
                              + "Quantity, QuantityAvailable, SellingStatus, SKU, TimeLeft, WatchCount, BidCount, BidderCount, CurrentPrice, FVF, ImagePath) values ("
                              + "@ItemID, @SellerName, @Title, @ListingType, @GalleryURL, @QuantityBid, @MaxBid, @StartPrice, @BuyItNowPrice,"
                              + "@CurrencyID, @StartTime, @EndTime, @ViewItemURL, @ListDuration, @PrivateListing,"
                              + "@Quantity, @QuantityAvailable, @SellingStatus, @SKU, @TimeLeft, @WatchCount, @BidCount, @BidderCount, @CurrentPrice, @FVF, @ImagePath)";

            DataFactory.AddCommandParam(cmd, "@ItemID", DbType.String, StringUtil.GetSafeString(activeListing.ItemID));
            DataFactory.AddCommandParam(cmd, "@SellerName", DbType.String, StringUtil.GetSafeString(activeListing.SellerName));
            DataFactory.AddCommandParam(cmd, "@Title", DbType.String, StringUtil.GetSafeString(activeListing.Title));
            DataFactory.AddCommandParam(cmd, "@ListingType", DbType.String, StringUtil.GetSafeString(activeListing.ListingType));
            DataFactory.AddCommandParam(cmd, "@GalleryURL", DbType.String, StringUtil.GetSafeString(activeListing.GalleryURL));
            DataFactory.AddCommandParam(cmd, "@QuantityBid", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityBid));

            DataFactory.AddCommandParam(cmd, "@MaxBid", DbType.Double, StringUtil.GetSafeDouble(activeListing.MaxBid));
            DataFactory.AddCommandParam(cmd, "@StartPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.StartPrice));
            DataFactory.AddCommandParam(cmd, "@BuyItNowPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.BuyItNowPrice));
            DataFactory.AddCommandParam(cmd, "@CurrencyID", DbType.String, StringUtil.GetSafeString(activeListing.CurrencyID));
            DataFactory.AddCommandParam(cmd, "@StartTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.StartTime));

            DataFactory.AddCommandParam(cmd, "@EndTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.EndTime));
            DataFactory.AddCommandParam(cmd, "@ViewItemURL", DbType.String, StringUtil.GetSafeString(activeListing.ViewItemURL));
            DataFactory.AddCommandParam(cmd, "@ListDuration", DbType.Int32, StringUtil.GetSafeInt(activeListing.ListDuration));
            DataFactory.AddCommandParam(cmd, "@PrivateListing", DbType.Boolean, StringUtil.GetSafeBool(activeListing.PrivateListing));
            DataFactory.AddCommandParam(cmd, "@Quantity", DbType.Int32, StringUtil.GetSafeInt(activeListing.Quantity));

            DataFactory.AddCommandParam(cmd, "@QuantityAvailable", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityAvailable));
            DataFactory.AddCommandParam(cmd, "@SellingStatus", DbType.String, StringUtil.GetSafeString(activeListing.SellingStatus));
            DataFactory.AddCommandParam(cmd, "@SKU", DbType.String, StringUtil.GetSafeString(activeListing.SKU));
            DataFactory.AddCommandParam(cmd, "@TimeLeft", DbType.String, StringUtil.GetSafeString(activeListing.TimeLeft));
            DataFactory.AddCommandParam(cmd, "@WatchCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.WatchCount));

            DataFactory.AddCommandParam(cmd, "@BidCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidCount));
            DataFactory.AddCommandParam(cmd, "@BidderCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidderCount));
            DataFactory.AddCommandParam(cmd, "@CurrentPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.CurrentPrice));
            DataFactory.AddCommandParam(cmd, "@FVF", DbType.Double, StringUtil.GetSafeDouble(activeListing.FVF));
            DataFactory.AddCommandParam(cmd, "@ImagePath", DbType.String, StringUtil.GetSafeString(activeListing.ImagePath));

            bool result    = false;
            int  newItemId = 0;

            try
            {
                if (DataFactory.DbConnection.State == ConnectionState.Closed)
                {
                    DataFactory.DbConnection.Open();
                }
                cmd.ExecuteNonQuery();

                IDbCommand cmdNewID = DataFactory.CreateCommand("SELECT @@IDENTITY");

                // Retrieve the Auto number and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newItemId);
                result = newItemId > 0;
            }
            catch (DataException ex)
            {
                // Write to log here.
                Logger.WriteSystemLog(string.Format("Error inserting new active listing, itemID={0}, errorMsg={1}",
                                                    activeListing.ItemID, ex.Message));
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(result);
        }   // InsertOneActiveListing
Exemplo n.º 10
0
        public static bool UpdateOneActiveListing(int listId, EbayActiveListingType activeListing)
        {
            bool result = false;

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [ActiveListing] set ItemID=@ItemID, Title=@Title, ListingType=@ListingType,"
                              + "GalleryURL=@GalleryURL, QuantityBid=@QuantityBid, MaxBid=@MaxBid, StartPrice=@StartPrice,"
                              + "BuyItNowPrice=@BuyItNowPrice, CurrencyID=@CurrencyID, StartTime=@StartTime, EndTime=@EndTime,"
                              + "ViewItemURL=@ViewItemURL, ListDuration=@ListDuration, PrivateListing=@PrivateListing,"
                              + "Quantity=@Quantity, QuantityAvailable=@QuantityAvailable, SellingStatus=@SellingStatus,"
                              + "SKU=@SKU, TimeLeft=@TimeLeft, WatchCount=@WatchCount, BidCount=@BidCount, BidderCount=@BidderCount,"
                              + "CurrentPrice=@CurrentPrice, FVF=@FVF, ImagePath=@ImagePath where ListId=@ListId";

            DataFactory.AddCommandParam(cmd, "@ItemID", DbType.String, StringUtil.GetSafeString(activeListing.ItemID));
            DataFactory.AddCommandParam(cmd, "@Title", DbType.String, StringUtil.GetSafeString(activeListing.Title));
            DataFactory.AddCommandParam(cmd, "@ListingType", DbType.String, StringUtil.GetSafeString(activeListing.ListingType));
            DataFactory.AddCommandParam(cmd, "@GalleryURL", DbType.String, StringUtil.GetSafeString(activeListing.GalleryURL));
            DataFactory.AddCommandParam(cmd, "@QuantityBid", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityBid));

            DataFactory.AddCommandParam(cmd, "@MaxBid", DbType.Double, StringUtil.GetSafeDouble(activeListing.MaxBid));
            DataFactory.AddCommandParam(cmd, "@StartPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.StartPrice));
            DataFactory.AddCommandParam(cmd, "@BuyItNowPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.BuyItNowPrice));
            DataFactory.AddCommandParam(cmd, "@CurrencyID", DbType.String, StringUtil.GetSafeString(activeListing.CurrencyID));
            DataFactory.AddCommandParam(cmd, "@StartTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.StartTime));

            DataFactory.AddCommandParam(cmd, "@EndTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.EndTime));
            DataFactory.AddCommandParam(cmd, "@ViewItemURL", DbType.String, StringUtil.GetSafeString(activeListing.ViewItemURL));
            DataFactory.AddCommandParam(cmd, "@ListDuration", DbType.Int32, StringUtil.GetSafeInt(activeListing.ListDuration));
            DataFactory.AddCommandParam(cmd, "@PrivateListing", DbType.Boolean, StringUtil.GetSafeBool(activeListing.PrivateListing));
            DataFactory.AddCommandParam(cmd, "@Quantity", DbType.Int32, StringUtil.GetSafeInt(activeListing.Quantity));

            DataFactory.AddCommandParam(cmd, "@QuantityAvailable", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityAvailable));
            DataFactory.AddCommandParam(cmd, "@SellingStatus", DbType.String, StringUtil.GetSafeString(activeListing.SellingStatus));
            DataFactory.AddCommandParam(cmd, "@SKU", DbType.String, StringUtil.GetSafeString(activeListing.SKU));
            DataFactory.AddCommandParam(cmd, "@TimeLeft", DbType.String, StringUtil.GetSafeString(activeListing.TimeLeft));
            DataFactory.AddCommandParam(cmd, "@WatchCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.WatchCount));

            DataFactory.AddCommandParam(cmd, "@BidCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidCount));
            DataFactory.AddCommandParam(cmd, "@BidderCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidderCount));
            DataFactory.AddCommandParam(cmd, "@CurrentPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.CurrentPrice));
            DataFactory.AddCommandParam(cmd, "@FVF", DbType.Double, StringUtil.GetSafeDouble(activeListing.FVF));
            DataFactory.AddCommandParam(cmd, "@ImagePath", DbType.String, StringUtil.GetSafeString(activeListing.ImagePath));

            DataFactory.AddCommandParam(cmd, "@ListId", DbType.Int32, listId);

            try
            {
                if (DataFactory.DbConnection.State == ConnectionState.Closed)
                {
                    DataFactory.DbConnection.Open();
                }
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (DataException)
            {
                // Write to log here.
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(result);
        }
Exemplo n.º 11
0
        private SourcingNoteType GetSourcingNoteFromUI(out double totalFee)
        {
            totalFee = 0.0;

            SourcingNoteType note = new SourcingNoteType();

            if (mSupplier == null)
            {
                MessageBox.Show("未选中任何供应商", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            DateTime date = dateTimePickerDate.Value;

            String skuList   = "";
            String priceList = "";
            String countList = "";

            bool first = true;

            foreach (DataGridViewRow row in this.dgvItems.Rows)
            {
                String sku   = StringUtil.GetSafeString(row.Cells[SKUColIndex].Value);
                Double price = StringUtil.GetSafeDouble(row.Cells[ItemPriceColIndex].Value);
                int    count = StringUtil.GetSafeInt(row.Cells[ItemCountColIndex].Value);

                InventoryItemType item = ItemDAL.GetItemBySKU(sku);
                if (item == null)
                {
                    continue;
                }

                if (count == 0)
                {
                    continue;
                }

                totalFee += count * price;

                if (first)
                {
                    skuList   = sku;
                    priceList = price.ToString();
                    countList = count.ToString();
                    first     = false;
                }
                else
                {
                    skuList   += "," + sku;
                    priceList += "," + price.ToString();
                    countList += "," + count.ToString();
                }
            }

            double extraFee = 0.0;

            if (!Double.TryParse(this.textBoxExtraFee.Text, out extraFee))
            {
                MessageBox.Show("其他费用必须是小数", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }


            double shippingFee = 0.0;

            if (!Double.TryParse(this.textBoxShippingFee.Text, out shippingFee))
            {
                MessageBox.Show("运费必须是小数", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            totalFee += extraFee;
            totalFee += shippingFee;

            note.SupplierId    = mSupplier.SupplierID;
            note.SourcingDate  = date;
            note.ItemSkuList   = skuList;
            note.ItemNumList   = countList;
            note.ItemPriceList = priceList;
            note.ExtraFee      = extraFee;
            note.ShippingFee   = shippingFee;
            note.TotalFee      = totalFee;
            note.Comment       = this.textBoxComment.Text;

            if (mEditMode == EditMode.EditExisting)
            {
                note.SourcingId = mSourcingNote.SourcingId;
            }

            return(note);
        }
Exemplo n.º 12
0
        private InventoryItemType GetItemInfoFromUI(bool isInsert)
        {
            InventoryItemType item = new InventoryItemType();

            TreeNode node = this.treeViewCategories.SelectedNode;

            if (node == null)
            {
                MessageBox.Show("请选择商品类别");
                return(null);
            }

            if (isInsert)
            {
                if (node.Tag.GetType() != typeof(ItemCategoryType))
                {
                    MessageBox.Show("请选择商品类别");
                    return(null);
                }

                ItemCategoryType category = (ItemCategoryType)node.Tag;
                if (category == null)
                {
                    MessageBox.Show("请选择商品类别");
                    return(null);
                }

                item.CategoryId = category.CategoryId;
                if (item.CategoryId <= 0)
                {
                    MessageBox.Show("请选择商品类别");
                    return(null);
                }
            }
            else
            {
                // modify
                if (node.Tag.GetType() != typeof(ItemCompactInfo))
                {
                    MessageBox.Show("请选择商品");
                    return(null);
                }
            }

            item.ItemName = this.textBoxItemName.Text;
            if (item.ItemName == "")
            {
                MessageBox.Show("请输入商品名");
                return(null);
            }

            item.ItemSKU = this.textBoxItemSKU.Text;
            if (item.ItemSKU == "")
            {
                MessageBox.Show("请输入商品SKU");
                return(null);
            }

            if (this.textBoxItemImagePath.Text.Trim() == "")
            {
                if (isInsert)
                {
                    MessageBox.Show("请选择商品图片");
                    return(null);
                }
            }
            else
            {
                string imagePath = this.textBoxItemImagePath.Text.Trim();
                if (File.Exists(imagePath) == false)
                {
                    MessageBox.Show("商品图片路径错误.");
                    return(null);
                }

                //FileStream fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
                //byte[] buffer = new byte[fs.Length];
                //fs.Read(buffer, 0, buffer.Length);
                //fs.Close();
                //item.ItemImage = buffer;
                item.ItemImagePath = imagePath;
            }

            if (this.textBoxItemStockShreshold.Text == "")
            {
                MessageBox.Show("商品库存警戒值错误");
                return(null);
            }

            item.ItemStockShresholdNum = Int32.Parse(this.textBoxItemStockShreshold.Text.Trim());

            string itemStockStr = this.textBoxItemStock.Text;

            if (itemStockStr.Trim() == "")
            {
                MessageBox.Show("商品库存值错误");
                return(null);
            }

            item.ItemStockNum = StringUtil.GetSafeInt(itemStockStr);

            //item.ItemSourcingInfo = this.textBoxItemSourcingInfo.Text;

            //item.ItemSourcingURL = this.textBoxSourcingURL.Text;

            //string itemCostStr = this.textBoxItemCost.Text.Trim();
            //if (itemCostStr == "")
            //{
            //    MessageBox.Show("商品成本值错误");
            //    return null;
            //}
            //item.ItemCost = StringUtil.GetSafeDouble(itemCostStr);

            string itemWeightStr = this.textBoxItemWeight.Text.Trim();

            if (itemWeightStr == "")
            {
                MessageBox.Show("商品重量值错误");
                return(null);
            }
            item.ItemWeight = StringUtil.GetSafeDouble(itemWeightStr);

            item.ItemCustomName = this.textBoxCustomName.Text.Trim();

            string itemCustomWeightStr = this.textBoxItemCustomWeight.Text.Trim();

            if (itemCustomWeightStr == "")
            {
                item.ItemCustomWeight = 0.0;
            }
            else
            {
                item.ItemCustomWeight = StringUtil.GetSafeDouble(itemCustomWeightStr);
            }

            string itemCustomCostStr = this.textBoxItemCustomValue.Text.Trim();

            if (itemCustomCostStr == "")
            {
                item.ItemCustomCost = 0.0;
            }
            else
            {
                item.ItemCustomCost = StringUtil.GetSafeDouble(itemCustomCostStr);
            }

            item.ItemAddDateTime = DateTime.Now;

            // IsGroupItem
            item.IsGroupItem = false;
            item.SubItemSKUs = "";

            return(item);
        }
Exemplo n.º 13
0
        private static EbayTransactionType GetTransactionTypeFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }

            EbayTransactionType trans = new EbayTransactionType();

            trans.TransactionId     = StringUtil.GetSafeInt(dr["TransactionId"]);
            trans.SellerName        = StringUtil.GetSafeString(dr["SellerName"]);
            trans.OrderId           = StringUtil.GetSafeString(dr["OrderId"]);
            trans.OrderLineItemId   = StringUtil.GetSafeString(dr["OrderLineItemId"]);
            trans.EbayTransactionId = StringUtil.GetSafeString(dr["EbayTransactionId"]);
            trans.EbayRecordId      = StringUtil.GetSafeInt(dr["EbayRecordId"]);

            trans.BuyerId              = StringUtil.GetSafeString(dr["BuyerId"]);
            trans.BuyerRating          = StringUtil.GetSafeInt(dr["BuyerRating"]);
            trans.BuyerCountryEbayCode = StringUtil.GetSafeString(dr["BuyerCountryEbayCode"]);
            trans.BuyerCountry4PXCode  = StringUtil.GetSafeString(dr["BuyerCountry4PXCode"]);
            trans.BuyerCountry         = StringUtil.GetSafeString(dr["BuyerCountry"]);
            trans.BuyerCompanyName     = StringUtil.GetSafeString(dr["BuyerCompanyName"]);
            trans.BuyerName            = StringUtil.GetSafeString(dr["BuyerName"]);
            trans.BuyerStateOrProvince = StringUtil.GetSafeString(dr["BuyerStateOrProvince"]);
            trans.BuyerCity            = StringUtil.GetSafeString(dr["BuyerCity"]);
            trans.BuyerTel             = StringUtil.GetSafeString(dr["BuyerTel"]);
            trans.BuyerMail            = StringUtil.GetSafeString(dr["BuyerMail"]);
            trans.BuyerPostalCode      = StringUtil.GetSafeString(dr["BuyerPostalCode"]);
            trans.BuyerAddress         = StringUtil.GetSafeString(dr["BuyerAddress"]);
            trans.BuyerAddressCompact  = StringUtil.GetSafeString(dr["BuyerAddressCompact"]);
            trans.BuyerAddressLine1    = StringUtil.GetSafeString(dr["BuyerAddressLine1"]);
            trans.BuyerAddressLine2    = StringUtil.GetSafeString(dr["BuyerAddressLine2"]);
            trans.BuyerPayPal          = StringUtil.GetSafeString(dr["BuyerPayPal"]);

            trans.ItemId       = StringUtil.GetSafeString(dr["ItemId"]);
            trans.ItemTitle    = StringUtil.GetSafeString(dr["ItemTitle"]);
            trans.ItemSKU      = StringUtil.GetSafeString(dr["ItemSKU"]);
            trans.ItemPrice    = StringUtil.GetSafeDouble(dr["ItemPrice"]);
            trans.SaleQuantity = StringUtil.GetSafeInt(dr["SaleQuantity"]);
            trans.TotalPrice   = StringUtil.GetSafeDouble(dr["TotalPrice"]);
            trans.CurrencyId   = StringUtil.GetSafeString(dr["CurrencyId"]);

            trans.SaleDate    = StringUtil.GetSafeDateTime(dr["SaleDate"]);
            trans.SaleDateCN  = StringUtil.GetSafeDateTime(dr["SaleDateCN"]);
            trans.IsPaid      = StringUtil.GetSafeBool(dr["IsPaid"]);
            trans.PaidDate    = StringUtil.GetSafeDateTime(dr["PaidDate"]);
            trans.IsShipped   = StringUtil.GetSafeBool(dr["IsShipped"]);
            trans.ShippedDate = StringUtil.GetSafeDateTime(dr["ShippedDate"]);

            trans.ShippingServiceCode = StringUtil.GetSafeString(dr["ShippingServiceCode"]);
            trans.ShippingService     = StringUtil.GetSafeString(dr["ShippingService"]);
            trans.ShippingTrackingNo  = StringUtil.GetSafeString(dr["ShippingTrackingNo"]);
            trans.ShippingCost        = StringUtil.GetSafeDouble(dr["ShippingCost"]);
            trans.FinalValueFee       = StringUtil.GetSafeDouble(dr["FinalValueFee"]);
            trans.PayPalFee           = StringUtil.GetSafeDouble(dr["PayPalFee"]);

            trans.IsReceived             = StringUtil.GetSafeBool(dr["IsReceived"]);
            trans.IsBuyerLeftFeedback    = StringUtil.GetSafeBool(dr["IsBuyerLeftFeedback"]);
            trans.IsSellerLeftFeedback   = StringUtil.GetSafeBool(dr["IsSellerLeftFeedback"]);
            trans.IsNeedAttention        = StringUtil.GetSafeBool(dr["IsNeedAttention"]);
            trans.MessageStatus          = (TransactionMessageStatus)StringUtil.GetSafeInt(dr["MessageStatus"]);
            trans.IsContactedBuyer       = StringUtil.GetSafeBool(dr["IsContactedBuyer"]);
            trans.LastContactedBuyerDate = StringUtil.GetSafeDateTime(dr["LastContactedBuyerDate"]);
            trans.IsResendReplacement    = StringUtil.GetSafeBool(dr["IsResendReplacement"]);
            trans.UserComment            = StringUtil.GetSafeString(dr["UserComment"]);

            trans.IsDelivered    = StringUtil.GetSafeBool(dr["IsDelivered"]);
            trans.DeliveryNoteId = StringUtil.GetSafeInt(dr["DeliveryNoteId"]);

            return(trans);
        } // GetTransactionTypeFromDataRow