Esempio n. 1
0
        } // DeleteOneListing

        public static bool UpdateActingListImagePath(String listingId, String imagePath)
        {
            bool result = false;

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [ActiveListing] set ImagePath=@ImagePath where ListId=@ListId";

            DataFactory.AddCommandParam(cmd, "@ImagePath", DbType.String, StringUtil.GetSafeString(imagePath));
            DataFactory.AddCommandParam(cmd, "@ListId", DbType.Int32, listingId);

            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);
        }
        // Delete one message template.
        public static bool DeleteOneMessageTemplate(int templateId)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Delete * from [MessageTemplate] where TemplateId=@TemplateId;";

            DataFactory.AddCommandParam(cmd, "CategoryId", DbType.Int32, templateId);

            bool result = DataFactory.ExecuteCommandNonQuery(cmd);

            return(result);
        }
Esempio n. 3
0
        public static bool DeleteOneCategory(int categoryId)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Delete * from [Category] where CategoryId=@CategoryId or ParentCategoryId=@CategoryId;";

            DataFactory.AddCommandParam(cmd, "CategoryId", DbType.Int32, categoryId);

            bool result = DataFactory.ExecuteCommandNonQuery(cmd);

            return(result);
        }
Esempio n. 4
0
        public static bool ModifyItemSupplier(ItemSupplierType itemSupplier)
        {
            if (itemSupplier == null || itemSupplier.ItemId <= 0 || itemSupplier.SupplierId <= 0)
            {
                return(false);
            }

            if (false == CheckItemSupplierExisted(itemSupplier.ItemId, itemSupplier.SupplierId))
            {
                return(false);
            }

            bool result = false;

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [ItemSupplier] set SouringURL=@SouringURL, Price=@Price, ShippingFee=@ShippingFee"
                              + " Comment=@Comment, CreateDate=@CreateDate where ItemId=@ItemId and SupplierId=@SupplierId";

            DataFactory.AddCommandParam(cmd, "@SouringURL", DbType.String, itemSupplier.SourcingURL);
            DataFactory.AddCommandParam(cmd, "@Price", DbType.Double, itemSupplier.Price);
            DataFactory.AddCommandParam(cmd, "@ShippingFee", DbType.Double, itemSupplier.Price);
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, itemSupplier.Comment);
            DataFactory.AddCommandParam(cmd, "@CreateDate", DbType.DateTime, itemSupplier.CreatedDate.ToShortDateString());

            DataFactory.AddCommandParam(cmd, "@ItemId", DbType.Int32, itemSupplier.ItemId);
            DataFactory.AddCommandParam(cmd, "@SupplierId", DbType.Int32, itemSupplier.SupplierId);

            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);
        }
Esempio n. 5
0
        public static bool ModifyOneSourcingNote(SourcingNoteType note)
        {
            bool result = false;

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

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [SourcingNote] set SupplierId=@SupplierId, ItemSkuList=@ItemSkuList,"
                              + "ItemNumList=@ItemNumList, ItemPriceList=@ItemPriceList, ExtraFee=@ExtraFee,"
                              + "ShippingFee=@ShippingFee, TotalFee=@TotalFee, Comment=@Comment, SourcingDate=@SourcingDate where SourcingId=@SourcingId";

            DataFactory.AddCommandParam(cmd, "@SupplierId", DbType.Int32, note.SupplierId);
            DataFactory.AddCommandParam(cmd, "@ItemSkuList", DbType.String, note.ItemSkuList);
            DataFactory.AddCommandParam(cmd, "@ItemNumList", DbType.String, note.ItemNumList);
            DataFactory.AddCommandParam(cmd, "@ItemPriceList", DbType.String, note.ItemPriceList);
            DataFactory.AddCommandParam(cmd, "@ExtraFee", DbType.Double, note.ExtraFee);
            DataFactory.AddCommandParam(cmd, "@ShippingFee", DbType.Double, note.ShippingFee);
            DataFactory.AddCommandParam(cmd, "@TotalFee", DbType.Double, note.TotalFee);
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, note.Comment);
            DataFactory.AddCommandParam(cmd, "@SourcingDate", DbType.DateTime, note.SourcingDate);

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

            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);
        }
Esempio n. 6
0
        public static bool InsertOneCategory(ItemCategoryType cat)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Insert into [Category] (ParentCategoryId, CategoryName, CategorySkuPrefix) values (@ParentCategoryId, @CategoryName, @CategorySkuPrefix)";

            DataFactory.AddCommandParam(cmd, "@ParentCategoryId", DbType.Int32, cat.ParentCategoryId);
            DataFactory.AddCommandParam(cmd, "@CategoryName", DbType.String, StringUtil.GetSafeString(cat.CategoryName));
            DataFactory.AddCommandParam(cmd, "@CategorySkuPrefix", DbType.String, StringUtil.GetSafeString(cat.CategorySkuPrefix));

            bool result = DataFactory.ExecuteCommandNonQuery(cmd);

            return(result);
        }
Esempio n. 7
0
        public static int InsertOneSourcingNote(SourcingNoteType note)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Insert into [SourcingNote] (SupplierId, ItemSkuList, ItemNumList,"
                              + "ItemPriceList, ExtraFee, ShippingFee, TotalFee, Comment, SourcingDate) values"
                              + "(@SupplierId, @ItemSkuList, @ItemNumList,"
                              + "@ItemPriceList, @ExtraFee, @ShippingFee, @TotalFee, @Comment, @SourcingDate)";

            DataFactory.AddCommandParam(cmd, "@SupplierId", DbType.Int32, note.SupplierId);
            DataFactory.AddCommandParam(cmd, "@ItemSkuList", DbType.String, note.ItemSkuList);
            DataFactory.AddCommandParam(cmd, "@ItemNumList", DbType.String, note.ItemNumList);
            DataFactory.AddCommandParam(cmd, "@ItemPriceList", DbType.String, note.ItemPriceList);
            DataFactory.AddCommandParam(cmd, "@ExtraFee", DbType.Double, note.ExtraFee);
            DataFactory.AddCommandParam(cmd, "@ShippingFee", DbType.Double, note.ShippingFee);
            DataFactory.AddCommandParam(cmd, "@TotalFee", DbType.Double, note.TotalFee);
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, note.Comment);
            // CAUTION: we need to convert note.SourcingDate to string otherwise we will meet with failure.
            DataFactory.AddCommandParam(cmd, "@SourcingDate", DbType.DateTime, note.SourcingDate.ToShortDateString());

            int newId = 0;

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

                IDbCommand cmdNewID = DataFactory.CreateCommand("SELECT @@IDENTITY");
                // Retrieve the Autonumber and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newId);
            }
            catch (DataException)
            {
                // Write to log here.
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(newId);
        }
        public static bool UpdateOneMessageTemplateCategory(MessageTemplateCategoryType cat)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [MessageTemplateCategory] set ParentCategoryId=@ParentCategoryId, CategoryName=@CategoryName, CategoryDescription=@CategoryDescription where CategoryId=@CategoryId";

            DataFactory.AddCommandParam(cmd, "@ParentCategoryId", DbType.Int32, cat.ParentCategoryId);
            DataFactory.AddCommandParam(cmd, "@CategoryName", DbType.String, StringUtil.GetSafeString(cat.CategoryName));
            DataFactory.AddCommandParam(cmd, "@CategoryDescription", DbType.String, StringUtil.GetSafeString(cat.CategoryDescription));
            DataFactory.AddCommandParam(cmd, "@CategoryId", DbType.Int32, StringUtil.GetSafeInt(cat.CategoryId));

            bool result = DataFactory.ExecuteCommandNonQuery(cmd);

            return(result);
        }
        public static bool ModifyOneMessageTemplate(MessageTemplateType messageTemplate)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [MessageTemplate] set TemplateCategoryId=@TemplateCategoryId, TemplateName=@TemplateName, TemplateContent=@TemplateContent where TemplateId=@TemplateId";

            DataFactory.AddCommandParam(cmd, "@TemplateCategoryId", DbType.Int32, messageTemplate.TemplateCategoryId);
            DataFactory.AddCommandParam(cmd, "@TemplateName", DbType.String, StringUtil.GetSafeString(messageTemplate.TemplateName));
            DataFactory.AddCommandParam(cmd, "@TemplateContent", DbType.String, StringUtil.GetSafeString(messageTemplate.TemplateContent));
            DataFactory.AddCommandParam(cmd, "@TemplateId", DbType.Int32, StringUtil.GetSafeInt(messageTemplate.TemplateId));

            bool result = DataFactory.ExecuteCommandNonQuery(cmd);

            return(result);
        }
Esempio n. 10
0
        public static bool ModifyOneSupplier(SupplierType supplier)
        {
            bool result = false;

            if (supplier == null || supplier.SupplierID <= 0)
            {
                return(false);
            }

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [Supplier] set SupplierName=@SupplierName, SupplierTel=@SupplierTel,"
                              + "SupplierLink1=@SupplierLink1, SupplierLink2=@SupplierLink2, SupplierLink3=@SupplierLink3,"
                              + "Comment=@Comment where SupplierId=@SupplierId";

            DataFactory.AddCommandParam(cmd, "@SupplierName", DbType.String, supplier.SupplierName);
            DataFactory.AddCommandParam(cmd, "@SupplierTel", DbType.String, supplier.SupplierTel);
            DataFactory.AddCommandParam(cmd, "@SupplierLink1", DbType.String, supplier.SupplierLink1);
            DataFactory.AddCommandParam(cmd, "@SupplierLink2", DbType.String, supplier.SupplierLink2);
            DataFactory.AddCommandParam(cmd, "@SupplierLink3", DbType.String, supplier.SupplierLink3);
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, supplier.Comment);

            DataFactory.AddCommandParam(cmd, "@SupplierId", DbType.Int32, supplier.SupplierID);

            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);
        }
Esempio n. 11
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);
        }
        // Insert one message template category.
        public static bool InsertOneMessageTemplateCategory(MessageTemplateCategoryType cat, out int newCatId)
        {
            newCatId = 0;

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Insert into [MessageTemplateCategory] (ParentCategoryId, CategoryName, CategoryDescription) values (@ParentCategoryId, @CategoryName, @CategoryDescription)";

            DataFactory.AddCommandParam(cmd, "@ParentCategoryId", DbType.Int32, cat.ParentCategoryId);
            DataFactory.AddCommandParam(cmd, "@CategoryName", DbType.String, StringUtil.GetSafeString(cat.CategoryName));
            DataFactory.AddCommandParam(cmd, "@CategoryDescription", DbType.String, StringUtil.GetSafeString(cat.CategoryDescription));

            bool result = DataFactory.ExecuteInsertCommand(cmd, out newCatId);

            return(result);
        }
Esempio n. 13
0
        // Insert one message template.
        public static bool InsertOneMessageTemplate(MessageTemplateType messageTemplate, out int newTemplateId)
        {
            newTemplateId = 0;

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Insert into [MessageTemplate] (TemplateCategoryId, TemplateName, TemplateContent) values (@TemplateCategoryId, @TemplateName, @TemplateContent)";

            DataFactory.AddCommandParam(cmd, "@TemplateCategoryId", DbType.Int32, messageTemplate.TemplateCategoryId);
            DataFactory.AddCommandParam(cmd, "@TemplateName", DbType.String, StringUtil.GetSafeString(messageTemplate.TemplateName));
            DataFactory.AddCommandParam(cmd, "@TemplateContent", DbType.String, StringUtil.GetSafeString(messageTemplate.TemplateContent));

            bool result = DataFactory.ExecuteInsertCommand(cmd, out newTemplateId);

            return(result);
        }
Esempio n. 14
0
        public static bool ModifyOneItemStockInNote(ItemStockInNoteType note)
        {
            bool result = false;

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

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [ItemStockInNote] set ItemSKU=@ItemSKU, ItemTitle=@ItemTitle, SourcingNoteId=@SourcingNoteId, "
                              + "StockInNum=@StockInNum, StockInDate=@StockInDate, Comment=@Comment where NoteId=@NoteId";

            DataFactory.AddCommandParam(cmd, "@ItemSKU", DbType.String, note.ItemSKU);
            DataFactory.AddCommandParam(cmd, "@ItemTitle", DbType.String, note.ItemTitle);
            DataFactory.AddCommandParam(cmd, "@SourcingNoteId", DbType.String, note.SourcingNoteId);
            DataFactory.AddCommandParam(cmd, "@StockInNum", DbType.Int32, note.StockInNum);
            DataFactory.AddCommandParam(cmd, "@StockInDate", DbType.DateTime, note.StockInDate);
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, note.Comment);

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

            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);
        }
Esempio n. 15
0
        public static int InsertOneSupplier(SupplierType supplier)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Insert into [Supplier] (SupplierName, SupplierTel, SupplierLink1,"
                              + "SupplierLink2, SupplierLink3, Comment) values"
                              + "(@SupplierName, @SupplierTel, @SupplierLink1,"
                              + "@SupplierLink2, @SupplierLink3, @Comment)";

            DataFactory.AddCommandParam(cmd, "@SupplierName", DbType.String, supplier.SupplierName);
            DataFactory.AddCommandParam(cmd, "@SupplierTel", DbType.String, supplier.SupplierTel);
            DataFactory.AddCommandParam(cmd, "@SupplierLink1", DbType.String, supplier.SupplierLink1);
            DataFactory.AddCommandParam(cmd, "@SupplierLink2", DbType.String, supplier.SupplierLink2);
            DataFactory.AddCommandParam(cmd, "@SupplierLink3", DbType.String, supplier.SupplierLink3);
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, supplier.Comment);

            int newId = 0;

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

                IDbCommand cmdNewID = DataFactory.CreateCommand("SELECT @@IDENTITY");
                // Retrieve the Autonumber and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newId);
            }
            catch (DataException)
            {
                // Write to log here.
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(newId);
        }
Esempio n. 16
0
        public static int InsertOneDeliveryNote(DeliveryNoteType di)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Insert into [DeliveryNote] (DeliveryDate, DeliveryOrderIds, DeliveryUser,"
                              + "DeliveryFee, DeliveryExtraFee, DeliveryComment) values"
                              + "(@DeliveryDate, @DeliveryOrderIds, @DeliveryUser,"
                              + "@DeliveryFee, @DeliveryExtraFee, @DeliveryComment)";

            DataFactory.AddCommandParam(cmd, "@DeliveryDate", DbType.DateTime, di.DeliveryDate.ToShortDateString());
            DataFactory.AddCommandParam(cmd, "@DeliveryOrderIds", DbType.String, di.DeliveryOrderIds);
            DataFactory.AddCommandParam(cmd, "@DeliveryUser", DbType.String, di.DeliveryUser);
            DataFactory.AddCommandParam(cmd, "@DeliveryFee", DbType.Double, di.DeliveryFee);
            DataFactory.AddCommandParam(cmd, "@DeliveryExtraFee", DbType.Double, di.DeliveryExtraFee);
            DataFactory.AddCommandParam(cmd, "@DeliveryComment", DbType.String, di.DeliveryComment);

            int newId = 0;

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

                IDbCommand cmdNewID = DataFactory.CreateCommand("SELECT @@IDENTITY");
                // Retrieve the Autonumber and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newId);
            }
            catch (DataException)
            {
                // Write to log here.
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(newId);
        }
Esempio n. 17
0
        public static int InsertOneItemStockInNote(ItemStockInNoteType note)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Insert into [ItemStockInNote] (ItemSKU, ItemTitle, SourcingNoteId, StockInNum, StockInDate, Comment) values"
                              + "(@ItemSKU, @ItemTitle, @SourcingNoteId, @StockInNum, @StockInDate, @Comment)";

            DataFactory.AddCommandParam(cmd, "@ItemSKU", DbType.String, note.ItemSKU);
            DataFactory.AddCommandParam(cmd, "@ItemTitle", DbType.String, note.ItemTitle);
            DataFactory.AddCommandParam(cmd, "@SourcingNoteId", DbType.String, note.SourcingNoteId);
            DataFactory.AddCommandParam(cmd, "@StockInNum", DbType.Int32, note.StockInNum);
            DataFactory.AddCommandParam(cmd, "@StockInDate", DbType.DateTime, note.StockInDate.ToShortDateString());
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, note.Comment);

            int newId = 0;

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

                IDbCommand cmdNewID = DataFactory.CreateCommand("SELECT @@IDENTITY");
                // Retrieve the Autonumber and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newId);
            }
            catch (DataException)
            {
                // Write to log here.
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(newId);
        }
Esempio n. 18
0
        public static bool ModifyItemNote(InventoryItemType item)
        {
            bool result = false;

            // Delete and insert one
            if (item == null || item.ItemId < 0)
            {
                return(false);
            }

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [Item] set ItemNote=@ItemNote where ItemId=@ItemId";

            DataFactory.AddCommandParam(cmd, "@ItemNote", DbType.String, StringUtil.GetSafeString(item.ItemNote));
            DataFactory.AddCommandParam(cmd, "@ItemId", DbType.Int32, item.ItemId);

            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);
        }
Esempio n. 19
0
        private static bool InsertOneItemSupplier(ItemSupplierType itemSupplier)
        {
            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Insert into [ItemSupplier](ItemId, SupplierId, SouringURL,Price, ShippingFee, Comment, CreateDate) values"
                              + "(@ItemId, @SupplierId, @SouringURL,@Price,@ShippingFee, @Comment, @CreateDate)";

            DataFactory.AddCommandParam(cmd, "@ItemId", DbType.Int32, itemSupplier.ItemId);
            DataFactory.AddCommandParam(cmd, "@SupplierId", DbType.Int32, itemSupplier.SupplierId);
            DataFactory.AddCommandParam(cmd, "@SouringURL", DbType.String, itemSupplier.SourcingURL);
            DataFactory.AddCommandParam(cmd, "@Price", DbType.Double, itemSupplier.Price);
            DataFactory.AddCommandParam(cmd, "@ShippingFee", DbType.Double, itemSupplier.ShippingFee);
            DataFactory.AddCommandParam(cmd, "@Comment", DbType.String, itemSupplier.Comment);
            DataFactory.AddCommandParam(cmd, "@CreateDate", DbType.DateTime, itemSupplier.CreatedDate.ToShortDateString());

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

            return(true);
        }
Esempio n. 20
0
        }   // ExecuteSql

        public static bool ExecuteInsertCommand(IDbCommand cmd, out int newId)
        {
            newId = 0;
            bool result = false;

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

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

                // Retrieve the Autonumber and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newId);
                result = newId > 0;
            }
            catch (DataException ex)
            {
                // Write to log here.
                Logger.WriteSystemLog(string.Format("Error : {0}", ex.Message));
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(result);
        }
Esempio n. 21
0
        private static bool UpdateOneTransactionInternal(int transId, EbayTransactionType trans)
        {
            bool result = false;

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [Transaction] set SellerName=@SellerName, OrderId=@OrderId, OrderLineItemId=@OrderLineItemId, EbayTransactionId=@EbayTransactionId, EbayRecordId=@EbayRecordId, BuyerId=@BuyerId, BuyerRating=@BuyerRating,"
                              + "BuyerCountryEbayCode=@BuyerCountryEbayCode, BuyerCountry4PXCode=@BuyerCountry4PXCode,"
                              + "BuyerCountry=@BuyerCountry, BuyerCompanyName=@BuyerCompanyName, BuyerName=@BuyerName, BuyerStateOrProvince=@BuyerStateOrProvince, BuyerCity=@BuyerCity,"
                              + "BuyerTel=@BuyerTel, BuyerMail=@BuyerMail, BuyerPostalCode=@BuyerPostalCode, BuyerAddress=@BuyerAddress, BuyerAddressCompact=@BuyerAddressCompact, BuyerAddressLine1=@BuyerAddressLine1, BuyerAddressLine2=@BuyerAddressLine2, "
                              + "BuyerPayPal=@BuyerPayPal,ItemId=@ItemId, ItemTitle=@ItemTitle, ItemSKU=@ItemSKU, ItemPrice=@ItemPrice, SaleQuantity=@SaleQuantity, SalePrice=@SalePrice, TotalPrice=@TotalPrice, CurrencyId=@CurrencyId,"
                              + "SaleDate=@SaleDate, SaleDateCN=@SaleDateCN, IsPaid=@IsPaid, PaidDate=@PaidDate, IsShipped=@IsShipped, ShippedDate=@ShippedDate, ShippingServiceCode=@ShippingServiceCode, ShippingService=@ShippingService, ShippingTrackingNo=@ShippingTrackingNo, ShippingCost=@ShippingCost, FinalValueFee=@FinalValueFee, PayPalFee=@PayPalFee,"
                              + "IsReceived=@IsReceived, IsBuyerLeftFeedback=@IsBuyerLeftFeedback, IsSellerLeftFeedback=@IsSellerLeftFeedback, IsNeedAttention=@IsNeedAttention, MessageStatus=@MessageStatus, IsContactedBuyer=@IsContactedBuyer,"
                              + "LastContactedBuyerDate=@LastContactedBuyerDate, IsResendReplacement=@IsResendReplacement, UserComment=@UserComment where TransactionId=@TransactionId";

            DataFactory.AddCommandParam(cmd, "@SellerName", DbType.String, trans.SellerName);
            DataFactory.AddCommandParam(cmd, "@OrderId", DbType.String, trans.OrderId);
            DataFactory.AddCommandParam(cmd, "@OrderLineItemId", DbType.String, trans.OrderLineItemId);
            DataFactory.AddCommandParam(cmd, "@EbayTransactionId", DbType.String, trans.EbayTransactionId);
            DataFactory.AddCommandParam(cmd, "@EbayRecordId", DbType.Int32, trans.EbayRecordId);
            DataFactory.AddCommandParam(cmd, "@BuyerId", DbType.String, trans.BuyerId);
            DataFactory.AddCommandParam(cmd, "@BuyerRating", DbType.Int32, trans.BuyerRating);

            DataFactory.AddCommandParam(cmd, "@BuyerCountryEbayCode", DbType.String, trans.BuyerCountryEbayCode);
            DataFactory.AddCommandParam(cmd, "@BuyerCountry4PXCode", DbType.String, trans.BuyerCountry4PXCode);
            DataFactory.AddCommandParam(cmd, "@BuyerCountry", DbType.String, trans.BuyerCountry);
            DataFactory.AddCommandParam(cmd, "@BuyerCompanyName", DbType.String, trans.BuyerCompanyName);
            DataFactory.AddCommandParam(cmd, "@BuyerName", DbType.String, trans.BuyerName);

            DataFactory.AddCommandParam(cmd, "@BuyerStateOrProvince", DbType.String, trans.BuyerStateOrProvince);
            DataFactory.AddCommandParam(cmd, "@BuyerCity", DbType.String, trans.BuyerCity);
            DataFactory.AddCommandParam(cmd, "@BuyerTel", DbType.String, trans.BuyerTel);
            DataFactory.AddCommandParam(cmd, "@BuyerMail", DbType.String, trans.BuyerMail);
            DataFactory.AddCommandParam(cmd, "@BuyerPostalCode", DbType.String, trans.BuyerPostalCode);

            DataFactory.AddCommandParam(cmd, "@BuyerAddress", DbType.String, trans.BuyerAddress);
            DataFactory.AddCommandParam(cmd, "@BuyerAddressCompact", DbType.String, trans.BuyerAddressCompact);
            DataFactory.AddCommandParam(cmd, "@BuyerAddressLine1", DbType.String, trans.BuyerAddressLine1);
            DataFactory.AddCommandParam(cmd, "@BuyerAddressLine2", DbType.String, trans.BuyerAddressLine2);
            DataFactory.AddCommandParam(cmd, "@BuyerPayPal", DbType.String, trans.BuyerPayPal);
            DataFactory.AddCommandParam(cmd, "@ItemId", DbType.String, trans.ItemId);
            DataFactory.AddCommandParam(cmd, "@ItemTitle", DbType.String, trans.ItemTitle);

            DataFactory.AddCommandParam(cmd, "@ItemSKU", DbType.String, trans.ItemSKU);
            DataFactory.AddCommandParam(cmd, "@ItemPrice", DbType.Double, trans.ItemPrice);
            DataFactory.AddCommandParam(cmd, "@SaleQuantity", DbType.Int32, trans.SaleQuantity);
            DataFactory.AddCommandParam(cmd, "@SalePrice", DbType.Double, trans.SalePrice);
            DataFactory.AddCommandParam(cmd, "@TotalPrice", DbType.Double, trans.TotalPrice);

            DataFactory.AddCommandParam(cmd, "@CurrencyId", DbType.String, trans.CurrencyId);
            DataFactory.AddCommandParam(cmd, "@SaleDate", DbType.DateTime, trans.SaleDate.ToString());
            DataFactory.AddCommandParam(cmd, "@SaleDateCN", DbType.DateTime, StringUtil.GetSafeDateTime(trans.SaleDateCN));
            DataFactory.AddCommandParam(cmd, "@IsPaid", DbType.Boolean, trans.IsPaid);
            DataFactory.AddCommandParam(cmd, "@PaidDate", DbType.DateTime, trans.PaidDate.ToString());
            DataFactory.AddCommandParam(cmd, "@IsShipped", DbType.Boolean, trans.IsShipped);

            DataFactory.AddCommandParam(cmd, "@ShippedDate", DbType.DateTime, StringUtil.GetSafeDateTime(trans.ShippedDate).ToString());
            DataFactory.AddCommandParam(cmd, "@ShippingServiceCode", DbType.String, trans.ShippingServiceCode);
            DataFactory.AddCommandParam(cmd, "@ShippingService", DbType.String, trans.ShippingService);
            DataFactory.AddCommandParam(cmd, "@ShippingTrackingNo", DbType.String, trans.ShippingTrackingNo);
            DataFactory.AddCommandParam(cmd, "@ShippingCost", DbType.Double, trans.ShippingCost);
            DataFactory.AddCommandParam(cmd, "@FinalValueFee", DbType.Double, trans.FinalValueFee);
            DataFactory.AddCommandParam(cmd, "@PayPalFee", DbType.Double, trans.PayPalFee);

            DataFactory.AddCommandParam(cmd, "@IsReceived", DbType.Boolean, trans.IsReceived);
            DataFactory.AddCommandParam(cmd, "@IsBuyerLeftFeedback", DbType.Boolean, trans.IsBuyerLeftFeedback);
            DataFactory.AddCommandParam(cmd, "@IsSellerLeftFeedback", DbType.Boolean, trans.IsSellerLeftFeedback);
            DataFactory.AddCommandParam(cmd, "@IsNeedAttention", DbType.Boolean, trans.IsNeedAttention);
            DataFactory.AddCommandParam(cmd, "@MessageStatus", DbType.Int32, trans.MessageStatus);

            DataFactory.AddCommandParam(cmd, "@IsContactedBuyer", DbType.Boolean, trans.IsContactedBuyer);
            DataFactory.AddCommandParam(cmd, "@LastContactedBuyerDate", DbType.DateTime, trans.LastContactedBuyerDate.ToString());
            DataFactory.AddCommandParam(cmd, "@IsResendReplacement", DbType.Boolean, trans.IsResendReplacement);
            DataFactory.AddCommandParam(cmd, "@UserComment", DbType.String, trans.UserComment);

            DataFactory.AddCommandParam(cmd, "@TransactionId", DbType.String, transId);

            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);
        }
Esempio n. 22
0
        public static int InsertOneItem(InventoryItemType item)
        {
            string itemSKU = item.ItemSKU;

            if (itemSKU == null || itemSKU.Trim() == "")
            {
                return(-1);
            }

            // We should ensure the item SKU is unique, this is our bottom line!!!
            InventoryItemType existedItemWithSameSKU = GetItemBySKU(itemSKU);

            if (existedItemWithSameSKU != null)
            {
                return(-1);
            }

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Insert into [Item] (CategoryId, ItemName, ItemSKU, ItemImagePath,"
                              + " ItemStockShresholdNum, ItemStockNum, ItemSourcingInfo, ItemCost, ItemWeight, "
                              + " ItemCustomName, ItemCustomWeight, ItemCustomCost, ItemAddDateTime, "
                              + " IsGroupItem, SubItemSKUs, ItemSourcingURL, ItemDispatchTips, ItemNote) values ("
                              + " @CategoryId, @ItemName, @ItemSKU, @ItemImagePath, "
                              + " @ItemStockShresholdNum, @ItemStockNum, @ItemSourcingInfo, @ItemCost, @ItemWeight, "
                              + " @ItemCustomName, @ItemCustomWeight, @ItemCustomCost, @ItemAddDateTime, "
                              + " @IsGroupItem, @SubItemSKUs, @ItemSourcingURL, @ItemDispatchTips, @ItemNote)";

            DataFactory.AddCommandParam(cmd, "@CategoryId", DbType.Int32, item.CategoryId);
            DataFactory.AddCommandParam(cmd, "@ItemName", DbType.String, GetDefaultValue(item.ItemName));

            DataFactory.AddCommandParam(cmd, "@ItemSKU", DbType.Int32, GetDefaultValue(item.ItemSKU));
            DataFactory.AddCommandParam(cmd, "@ItemImagePath", DbType.String, item.ItemImagePath);

            DataFactory.AddCommandParam(cmd, "@ItemStockShresholdNum", DbType.Int32, item.ItemStockShresholdNum);
            DataFactory.AddCommandParam(cmd, "@ItemStockNum", DbType.Int32, item.ItemStockNum);

            DataFactory.AddCommandParam(cmd, "@ItemSourcingInfo", DbType.String, GetDefaultValue(item.ItemSourcingInfo));
            DataFactory.AddCommandParam(cmd, "@ItemCost", DbType.Double, item.ItemCost);

            DataFactory.AddCommandParam(cmd, "@ItemWeight", DbType.Double, item.ItemWeight);
            DataFactory.AddCommandParam(cmd, "@ItemCustomName", DbType.String, GetDefaultValue(item.ItemCustomName));

            DataFactory.AddCommandParam(cmd, "@ItemCustomWeight", DbType.Double, item.ItemCustomWeight);
            DataFactory.AddCommandParam(cmd, "@ItemCustomCost", DbType.Double, item.ItemCustomCost);

            DataFactory.AddCommandParam(cmd, "@ItemAddDateTime", DbType.DateTime, item.ItemAddDateTime.ToString());

            DataFactory.AddCommandParam(cmd, "@IsGroupItem", DbType.Boolean, item.IsGroupItem);
            DataFactory.AddCommandParam(cmd, "@SubItemSKUs", DbType.String, GetDefaultValue(item.SubItemSKUs));

            DataFactory.AddCommandParam(cmd, "@ItemSourcingURL", DbType.String, StringUtil.GetSafeString(item.ItemSourcingURL));
            DataFactory.AddCommandParam(cmd, "@ItemDispatchTips", DbType.String, "");
            DataFactory.AddCommandParam(cmd, "@ItemNote", DbType.String, StringUtil.GetSafeString(item.ItemNote));

            int newItemId = 0;

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

                IDbCommand cmdNewID = DataFactory.CreateCommand("SELECT @@IDENTITY");
                // Retrieve the Autonumber and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newItemId);
            }
            catch (DataException)
            {
                // Write to log here.
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(newItemId);
        }
Esempio n. 23
0
        public static bool ModifyOneItem(InventoryItemType item)
        {
            bool result = false;

            // Delete and insert one
            if (item == null || item.ItemId < 0)
            {
                return(false);
            }

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [Item] set CategoryId=@CategoryId, ItemName=@ItemName, ItemSKU=@ItemSKU, ItemImagePath=@ItemImagePath,"
                              + " ItemStockShresholdNum=@ItemStockShresholdNum, ItemStockNum=@ItemStockNum, ItemSourcingInfo=@ItemSourcingInfo, ItemCost=@ItemCost, ItemWeight=@ItemWeight, "
                              + " ItemCustomName=@ItemCustomName, ItemCustomWeight=@ItemCustomWeight, ItemCustomCost=@ItemCustomCost, ItemAddDateTime=@ItemAddDateTime, "
                              + " IsGroupItem=@IsGroupItem, SubItemSKUs=@SubItemSKUs, ItemSourcingURL=@ItemSourcingURL, ItemDispatchTips=@ItemDispatchTips, ItemNote=@ItemNote where ItemId=@ItemId";

            DataFactory.AddCommandParam(cmd, "@CategoryId", DbType.Int32, item.CategoryId);
            DataFactory.AddCommandParam(cmd, "@ItemName", DbType.String, GetDefaultValue(item.ItemName));

            DataFactory.AddCommandParam(cmd, "@ItemSKU", DbType.String, StringUtil.GetSafeString(item.ItemSKU));
            DataFactory.AddCommandParam(cmd, "@ItemImagePath", DbType.String, item.ItemImagePath);

            DataFactory.AddCommandParam(cmd, "@ItemStockShresholdNum", DbType.Int32, item.ItemStockShresholdNum);
            DataFactory.AddCommandParam(cmd, "@ItemStockNum", DbType.Int32, item.ItemStockNum);

            DataFactory.AddCommandParam(cmd, "@ItemSourcingInfo", DbType.String, GetDefaultValue(item.ItemSourcingInfo));
            DataFactory.AddCommandParam(cmd, "@ItemCost", DbType.Double, item.ItemCost);

            DataFactory.AddCommandParam(cmd, "@ItemWeight", DbType.Double, item.ItemWeight);
            DataFactory.AddCommandParam(cmd, "@ItemCustomName", DbType.String, GetDefaultValue(item.ItemCustomName));

            DataFactory.AddCommandParam(cmd, "@ItemCustomWeight", DbType.Double, item.ItemCustomWeight);
            DataFactory.AddCommandParam(cmd, "@ItemCustomCost", DbType.Double, item.ItemCustomCost);

            DataFactory.AddCommandParam(cmd, "@ItemAddDateTime", DbType.DateTime, item.ItemAddDateTime.ToString());

            DataFactory.AddCommandParam(cmd, "@IsGroupItem", DbType.Boolean, item.IsGroupItem);
            DataFactory.AddCommandParam(cmd, "@SubItemSKUs", DbType.String, GetDefaultValue(item.SubItemSKUs));

            DataFactory.AddCommandParam(cmd, "@ItemSourcingURL", DbType.String, StringUtil.GetSafeString(item.ItemSourcingURL));
            DataFactory.AddCommandParam(cmd, "@ItemDispatchTips", DbType.String, "");
            DataFactory.AddCommandParam(cmd, "@ItemNote", DbType.String, StringUtil.GetSafeString(item.ItemNote));

            DataFactory.AddCommandParam(cmd, "@ItemId", DbType.Int32, item.ItemId);

            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);
        }   // ModifyOneItem
Esempio n. 24
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
Esempio n. 25
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);
        }
Esempio n. 26
0
        // Private to prevent misuse, use public InsertOrUpdateOneTransaction instead!!!!!!!
        private static bool InsertOneTransaction(EbayTransactionType trans)
        {
            if (trans.IsValid() == false)
            {
                return(false);
            }

            EbayTransactionType transLoc = EbayTransactionDAL.GetOneTransaction(trans.OrderLineItemId);

            if (transLoc != null)
            {
                Logger.WriteSystemLog(string.Format("Transaction already existed in database: userId={0}, itemTitle={1}",
                                                    trans.BuyerId, trans.ItemTitle));
                return(false);
            }

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"insert into [Transaction] (SellerName, OrderId, OrderLineItemId, EbayTransactionId, EbayRecordId, BuyerId, BuyerRating,"
                              + "BuyerCountryEbayCode, BuyerCountry4PXCode,"
                              + "BuyerCountry, BuyerCompanyName, BuyerName, BuyerStateOrProvince, BuyerCity,"
                              + "BuyerTel, BuyerMail, BuyerPostalCode, BuyerAddress, BuyerAddressCompact, BuyerAddressLine1, BuyerAddressLine2,"
                              + "BuyerPayPal,ItemId, ItemTitle, ItemSKU, ItemPrice, SaleQuantity, SalePrice, TotalPrice, CurrencyId,"
                              + "SaleDate, SaleDateCN, IsPaid, PaidDate, IsShipped, ShippedDate, ShippingServiceCode, ShippingService, ShippingTrackingNo, ShippingCost, FinalValueFee, PayPalFee,"
                              + "IsReceived, IsBuyerLeftFeedback, IsSellerLeftFeedback, IsNeedAttention, MessageStatus, IsContactedBuyer,"
                              + "LastContactedBuyerDate, IsResendReplacement, UserComment) values ("
                              + "@SellerName, @OrderId, @OrderLineItemId, @EbayTransactionId, @EbayRecordId, @BuyerId, @BuyerRating,"
                              + "@BuyerCountryEbayCode, @BuyerCountry4PXCode,"
                              + "@BuyerCountry, @BuyerCompanyName, @BuyerName, @BuyerStateOrProvince, @BuyerCity,"
                              + "@BuyerTel, @BuyerMail, @BuyerPostalCode, @BuyerAddress, @BuyerAddressCompact, @BuyerAddressLine1, @BuyerAddressLine2,"
                              + "@BuyerPayPal, @ItemId, @ItemTitle, @ItemSKU, @ItemPrice, @SaleQuantity, @SalePrice, @TotalPrice, @CurrencyId,"
                              + "@SaleDate, @SaleDateCN, @IsPaid, @PaidDate, @IsShipped, @ShippedDate, @ShippingServiceCode, @ShippingService, @ShippingTrackingNo, @ShippingCost, @FinalValueFee, @PayPalFee,"
                              + "@IsReceived, @IsBuyerLeftFeedback, @IsSellerLeftFeedback, @IsNeedAttention, @MessageStatus, @IsContactedBuyer,"
                              + "@LastContactedBuyerDate, @IsResendReplacement, @UserComment)";

            DataFactory.AddCommandParam(cmd, "@SellerName", DbType.String, trans.SellerName);
            DataFactory.AddCommandParam(cmd, "@OrderId", DbType.String, trans.OrderId);
            DataFactory.AddCommandParam(cmd, "@OrderLineItemId", DbType.String, trans.OrderLineItemId);
            DataFactory.AddCommandParam(cmd, "@EbayTransactionId", DbType.String, trans.EbayTransactionId);
            DataFactory.AddCommandParam(cmd, "@EbayRecordId", DbType.Int32, trans.EbayRecordId);
            DataFactory.AddCommandParam(cmd, "@BuyerId", DbType.String, trans.BuyerId);
            DataFactory.AddCommandParam(cmd, "@BuyerRating", DbType.Int32, trans.BuyerRating);

            DataFactory.AddCommandParam(cmd, "@BuyerCountryEbayCode", DbType.String, StringUtil.GetSafeString(trans.BuyerCountryEbayCode));
            DataFactory.AddCommandParam(cmd, "@BuyerCountry4PXCode", DbType.String, StringUtil.GetSafeString(trans.BuyerCountry4PXCode));
            DataFactory.AddCommandParam(cmd, "@BuyerCountry", DbType.String, StringUtil.GetSafeString(trans.BuyerCountry));
            DataFactory.AddCommandParam(cmd, "@BuyerCompanyName", DbType.String, StringUtil.GetSafeString(trans.BuyerCompanyName));
            DataFactory.AddCommandParam(cmd, "@BuyerName", DbType.String, trans.BuyerName);

            DataFactory.AddCommandParam(cmd, "@BuyerStateOrProvince", DbType.String, trans.BuyerStateOrProvince);
            DataFactory.AddCommandParam(cmd, "@BuyerCity", DbType.String, trans.BuyerCity);
            DataFactory.AddCommandParam(cmd, "@BuyerTel", DbType.String, StringUtil.GetSafeString(trans.BuyerTel));
            DataFactory.AddCommandParam(cmd, "@BuyerMail", DbType.String, StringUtil.GetSafeString(trans.BuyerMail));
            DataFactory.AddCommandParam(cmd, "@BuyerPostalCode", DbType.String, StringUtil.GetSafeString(trans.BuyerPostalCode));

            DataFactory.AddCommandParam(cmd, "@BuyerAddress", DbType.String, StringUtil.GetSafeString(trans.BuyerAddress));
            DataFactory.AddCommandParam(cmd, "@BuyerAddressCompact", DbType.String, StringUtil.GetSafeString(trans.BuyerAddressCompact));
            DataFactory.AddCommandParam(cmd, "@BuyerAddressLine1", DbType.String, StringUtil.GetSafeString(trans.BuyerAddressLine1));
            DataFactory.AddCommandParam(cmd, "@BuyerAddressLine2", DbType.String, StringUtil.GetSafeString(trans.BuyerAddressLine2));
            DataFactory.AddCommandParam(cmd, "@BuyerPayPal", DbType.String, StringUtil.GetSafeString(trans.BuyerPayPal));
            DataFactory.AddCommandParam(cmd, "@ItemId", DbType.String, StringUtil.GetSafeString(trans.ItemId));
            DataFactory.AddCommandParam(cmd, "@ItemTitle", DbType.String, StringUtil.GetSafeString(trans.ItemTitle));

            DataFactory.AddCommandParam(cmd, "@ItemSKU", DbType.String, StringUtil.GetSafeString(trans.ItemSKU));
            DataFactory.AddCommandParam(cmd, "@ItemPrice", DbType.Double, trans.ItemPrice);
            DataFactory.AddCommandParam(cmd, "@SaleQuantity", DbType.Int32, trans.SaleQuantity);
            DataFactory.AddCommandParam(cmd, "@SalePrice", DbType.Double, trans.SalePrice);
            DataFactory.AddCommandParam(cmd, "@TotalPrice", DbType.Double, trans.TotalPrice);

            DataFactory.AddCommandParam(cmd, "@CurrencyId", DbType.String, StringUtil.GetSafeString(trans.CurrencyId));
            DataFactory.AddCommandParam(cmd, "@SaleDate", DbType.Date, StringUtil.GetSafeDateTime(trans.SaleDate).ToString());
            DataFactory.AddCommandParam(cmd, "@SaleDateCN", DbType.Date, StringUtil.GetSafeDateTime(trans.SaleDateCN).ToString());
            DataFactory.AddCommandParam(cmd, "@IsPaid", DbType.Boolean, trans.IsPaid);
            DataFactory.AddCommandParam(cmd, "@PaidDate", DbType.Date, StringUtil.GetSafeDateTime(trans.PaidDate).ToString());
            DataFactory.AddCommandParam(cmd, "@IsShipped", DbType.Boolean, trans.IsShipped);

            DataFactory.AddCommandParam(cmd, "@ShippedDate", DbType.Date, StringUtil.GetSafeDateTime(trans.ShippedDate).ToString());
            DataFactory.AddCommandParam(cmd, "@ShippingServiceCode", DbType.String, trans.ShippingServiceCode);
            DataFactory.AddCommandParam(cmd, "@ShippingService", DbType.String, trans.ShippingService);
            DataFactory.AddCommandParam(cmd, "@ShippingTrackingNo", DbType.String, trans.ShippingTrackingNo);

            DataFactory.AddCommandParam(cmd, "@ShippingCost", DbType.Double, trans.ShippingCost);
            DataFactory.AddCommandParam(cmd, "@FinalValueFee", DbType.Double, trans.FinalValueFee);
            DataFactory.AddCommandParam(cmd, "@PayPalFee", DbType.Double, trans.PayPalFee);

            DataFactory.AddCommandParam(cmd, "@IsReceived", DbType.Boolean, trans.IsReceived);
            DataFactory.AddCommandParam(cmd, "@IsBuyerLeftFeedback", DbType.Boolean, trans.IsBuyerLeftFeedback);
            DataFactory.AddCommandParam(cmd, "@IsSellerLeftFeedback", DbType.Boolean, trans.IsSellerLeftFeedback);
            DataFactory.AddCommandParam(cmd, "@IsNeedAttention", DbType.Boolean, trans.IsNeedAttention);
            DataFactory.AddCommandParam(cmd, "@MessageStatus", DbType.Int32, trans.MessageStatus);
            DataFactory.AddCommandParam(cmd, "@IsContactedBuyer", DbType.Boolean, trans.IsContactedBuyer);

            DataFactory.AddCommandParam(cmd, "@LastContactedBuyerDate", DbType.Date, StringUtil.GetSafeDateTime(trans.LastContactedBuyerDate).ToString());
            DataFactory.AddCommandParam(cmd, "@IsResendReplacement", DbType.Boolean, trans.IsResendReplacement);
            DataFactory.AddCommandParam(cmd, "@UserComment", DbType.String, StringUtil.GetSafeString(trans.UserComment));

            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 Autonumber 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 : {0}", ex.Message));
                trans.dump();
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(result);
        }   // InsertOneTransaction