// ZHI_TODO
        private void ToolStripMenuItemDel_Click(object sender, EventArgs e)
        {
            List <String> tranIds = new List <String>();

            DataGridViewSelectedRowCollection selectedRows = this.dataGridViewTransactions.SelectedRows;

            foreach (DataGridViewRow row in selectedRows)
            {
                tranIds.Add(row.Cells[0].Value.ToString());
            }

            // Remove this rows from the datatable.
            DataTable dtUpdated = mDtTransactions.Clone();

            foreach (DataRow dr in mDtTransactions.Rows)
            {
                String tranIdLoc = StringUtil.GetSafeString(dr["TransactionId"]);
                if (-1 == tranIds.IndexOf(tranIdLoc))
                {
                    dtUpdated.Rows.Add(dr.ItemArray);
                }
            }

            mDtTransactions = dtUpdated;
            dataGridViewTransactions.DataSource = mDtTransactions;
        }
Example #2
0
        private void LoadAllItems()
        {
            DataTable dtItems = ItemDAL.GetAllItems();

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

            foreach (DataRow dr in dtItems.Rows)
            {
                int    itemId    = StringUtil.GetSafeInt(dr["ItemId"]);
                int    itemCatId = StringUtil.GetSafeInt(dr["CategoryId"]);
                string itemName  = StringUtil.GetSafeString(dr["ItemName"]);
                string itemSKU   = StringUtil.GetSafeString(dr["ItemSKU"]);

                ItemCompactInfo itemInfo = new ItemCompactInfo(itemId, itemCatId, itemName, itemSKU);
                TreeNode        itemNode = new TreeNode();
                itemNode.Text = string.Format("[{0}] {1}", itemSKU, itemName);
                itemNode.Tag  = itemInfo;
                itemNode.Name = itemSKU;

                TreeNode[] nodes = this.treeViewCategories.Nodes.Find(itemCatId.ToString(), true);
                if (nodes.Length == 1)
                {
                    nodes[0].Nodes.Add(itemNode);
                }
            }
        }
Example #3
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;
        }
        // Get transactions for a specified order id.
        //  Note that for single line item, only one transaction for an order.
        //  For multiple line items, they are multiple transactions for an order.
        public static List <EbayTransactionType> GetOrderTransactions(String orderId)
        {
            String    sql_getOneTransaction = "select * from [Transaction] where OrderId='" + orderId + "'";
            DataTable dt = DataFactory.ExecuteSqlReturnTable(sql_getOneTransaction);

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

            List <EbayTransactionType> trans = new List <EbayTransactionType>();

            foreach (DataRow row in dt.Rows)
            {
                EbayTransactionType tran = new EbayTransactionType();
                tran.OrderId           = orderId;
                tran.EbayTransactionId = StringUtil.GetSafeString(row["EbayTransactionId"]);
                tran.OrderLineItemId   = StringUtil.GetSafeString(row["OrderLineItemId"]);
                // ZHI_TODO:

                trans.Add(tran);
            }

            return(trans);
        }
Example #5
0
        void DgvData_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewColumn col = this.pagedDgvSupplier.DgvData.Columns[e.ColumnIndex];

            if (col.GetType() == typeof(DataGridViewLinkColumn))
            {
                String link = StringUtil.GetSafeString(this.pagedDgvSupplier.DgvData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
                System.Diagnostics.Process.Start(link);
            }
        }
        private void ModifyDeliveryNote()
        {
            if (mEditMode != EditMode.EditExisting)
            {
                return;
            }

            // tranIds will be like "2264,2265,2266"
            String tranIds  = "";
            bool   firstRow = true;

            foreach (DataRow dr in mDtTransactions.Rows)
            {
                String tranIdLoc = StringUtil.GetSafeString(dr["TransactionId"]);
                if (tranIdLoc == null || tranIdLoc == "")
                {
                    continue;
                }

                if (!firstRow)
                {
                    tranIds += ",";
                }
                else
                {
                    firstRow = false;
                }

                tranIds += tranIdLoc;
            }

            double fee      = 0.0;
            double extraFee = 0.0;

            Double.TryParse(textBoxFee.Text, out fee);
            Double.TryParse(textBoxExtraFee.Text, out extraFee);

            mDeliveryNote.DeliveryOrderIds = tranIds;
            mDeliveryNote.DeliveryFee      = fee;
            mDeliveryNote.DeliveryExtraFee = extraFee;
            mDeliveryNote.DeliveryComment  = textBoxComment.Text;

            bool result = DeliveryNoteDAL.ModifyOneDeliveryNote(mDeliveryNote);

            if (result)
            {
                Modified = true;
                MessageBox.Show("修改发货单成功", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("修改发货单失败", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #7
0
        private void treeViewCategories_AfterSelect(object sender, TreeViewEventArgs e)
        {
            this.buttonDelItem.Enabled = false;

            int itemId = GetSelectedItemId();

            if (itemId <= 0)
            {
                return;
            }

            DataTable dtItem = ItemDAL.GetItemTableById(itemId);

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

            DataRow dr = dtItem.Rows[0];

            this.textBoxItemName.Text           = StringUtil.GetSafeString(dr["ItemName"]);
            this.textBoxItemSKU.Text            = StringUtil.GetSafeString(dr["ItemSKU"]);
            this.textBoxItemStockShreshold.Text = StringUtil.GetSafeString(dr["ItemStockShresholdNum"]);
            this.textBoxItemStock.Text          = StringUtil.GetSafeString(dr["ItemStockNum"]);
            //this.textBoxItemSourcingInfo.Text = StringUtil.GetSafeString(dr["ItemSourcingInfo"]);
            //this.textBoxSourcingURL.Text = StringUtil.GetSafeString(dr["ItemSourcingURL"]);
            //this.textBoxItemCost.Text = StringUtil.GetSafeString(dr["ItemCost"]);
            this.textBoxItemWeight.Text       = StringUtil.GetSafeString(dr["ItemWeight"]);
            this.textBoxCustomName.Text       = StringUtil.GetSafeString(dr["ItemCustomName"]);
            this.textBoxItemCustomWeight.Text = StringUtil.GetSafeString(dr["ItemCustomWeight"]);
            this.textBoxItemCustomValue.Text  = StringUtil.GetSafeString(dr["ItemCustomCost"]);

            String imagePath = StringUtil.GetSafeString(dr["ItemImagePath"]);

            this.pictureBoxItemPic.Image   = null;
            this.textBoxItemImagePath.Text = "";
            if (File.Exists(imagePath))
            {
                Image rawImage = Image.FromFile(imagePath);
                if (rawImage != null)
                {
                    int   width  = this.pictureBoxItemPic.Width;
                    int   height = this.pictureBoxItemPic.Height;
                    Image image  = ResizeImg(rawImage, width, height);
                    this.pictureBoxItemPic.Image = image;
                }
                this.textBoxItemImagePath.Text = imagePath;
            }

            LoadItemSuppliers(itemId);

            this.buttonDelItem.Enabled      = true;
            this.buttonAddOrModifyItem.Text = "完成修改";
        }
        private bool IsTransactionAlreadyAdded(String tranId)
        {
            foreach (DataRow dr in mDtTransactions.Rows)
            {
                if (StringUtil.GetSafeString(dr["TransactionId"]) == tranId)
                {
                    return(true);
                }
            }

            return(false);
        }
        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);
        }
        // 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);
        }
        // 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);
        }
Example #12
0
        private void LoadAllCategories()
        {
            DataTable dtCategories = ItemCategoryDAL.GetAllCategories();

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

            this.treeViewCategories.Nodes.Clear();

            for (int itNum = 0; itNum < 2; ++itNum)
            {
                foreach (DataRow dr in dtCategories.Rows)
                {
                    int    catId       = StringUtil.GetSafeInt(dr["CategoryId"]);
                    int    parentCatId = StringUtil.GetSafeInt(dr["ParentCategoryId"]);
                    string catName     = StringUtil.GetSafeString(dr["CategoryName"]);

                    ItemCategoryType catType = new ItemCategoryType();
                    catType.CategoryId       = catId;
                    catType.ParentCategoryId = parentCatId;
                    catType.CategoryName     = catName;

                    TreeNode newNode = new TreeNode();
                    newNode.Tag  = catType;
                    newNode.Text = catName;
                    newNode.Name = catId.ToString();

                    if (parentCatId == -1 && itNum == 0)
                    {
                        this.treeViewCategories.Nodes.Add(newNode);
                    }
                    else if (parentCatId != -1 && itNum == 1)
                    {
                        TreeNode[] parentNodes = this.treeViewCategories.Nodes.Find(parentCatId.ToString(), true);
                        if (parentNodes.Length == 1)
                        {
                            parentNodes[0].Nodes.Add(newNode);
                        }
                    }
                }
            }

            this.treeViewCategories.ExpandAll();
            return;
        }
Example #13
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);
        }