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 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);
        }