예제 #1
0
        public static bool DeleteItemSupplier(ItemSupplierType itemSupplier)
        {
            bool result = false;

            String sql = string.Format("delete from [ItemSupplier] where ItemId={0} and SupplierId={1}",
                itemSupplier.ItemId, itemSupplier.SupplierId);
            DataFactory.ExecuteSql(sql);
            result = true;

            return result;
        }
예제 #2
0
        public static bool DeleteItemSupplier(ItemSupplierType itemSupplier)
        {
            bool result = false;

            String sql = string.Format("delete from [ItemSupplier] where ItemId={0} and SupplierId={1}",
                                       itemSupplier.ItemId, itemSupplier.SupplierId);

            DataFactory.ExecuteSql(sql);
            result = true;

            return(result);
        }
예제 #3
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);
        }
예제 #4
0
        public static bool AddOneItemSupplier(ItemSupplierType itemSupplier)
        {
            if (itemSupplier == null)
                return false;

            // Check if existed.
            if (CheckItemSupplierExisted(itemSupplier.ItemId, itemSupplier.SupplierId))
                return false;

            // Insert the new record.
            InsertOneItemSupplier(itemSupplier);
            return true;
        }
예제 #5
0
        public static bool AddOneItemSupplier(ItemSupplierType itemSupplier)
        {
            if (itemSupplier == null)
            {
                return(false);
            }

            // Check if existed.
            if (CheckItemSupplierExisted(itemSupplier.ItemId, itemSupplier.SupplierId))
            {
                return(false);
            }

            // Insert the new record.
            InsertOneItemSupplier(itemSupplier);
            return(true);
        }
예제 #6
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);
        }
예제 #7
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;
        }
예제 #8
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);
        }
예제 #9
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;
        }