// Load all message templates.
        private void LoadAllMessageTemplates()
        {
            DataTable dtTemplates = MessageTemplateDAL.GetAllMessageTemplates();

            foreach (DataRow dr in dtTemplates.Rows)
            {
                int    templateId         = StringUtil.GetSafeInt(dr["TemplateId"]);
                int    templateCategoryId = StringUtil.GetSafeInt(dr["TemplateCategoryId"]);
                String templateName       = StringUtil.GetSafeString(dr["TemplateName"]);
                String templateContent    = StringUtil.GetSafeString(dr["TemplateContent"]);

                MessageTemplateType templateType = new MessageTemplateType();
                templateType.TemplateId         = templateId;
                templateType.TemplateName       = templateName;
                templateType.TemplateCategoryId = templateCategoryId;
                templateType.TemplateContent    = templateContent;

                TreeNode newNode = new TreeNode();
                newNode.Tag  = templateType;
                newNode.Text = templateName;
                newNode.Name = templateId.ToString();

                // Find the category node.
                TreeNode[] categoryNodes = treeViewMessageTemplate.Nodes.Find(templateCategoryId.ToString(), false);

                if (categoryNodes.Length == 1)
                {
                    categoryNodes[0].Nodes.Add(newNode);
                    categoryNodes[0].ExpandAll();
                }
            }
        }
Example #2
0
        private void buttonDelSupplier_Click(object sender, EventArgs e)
        {
            DataGridViewCell cell = this.dgvItemSuppliers.CurrentCell;

            if (cell == null)
            {
                return;
            }

            DataGridViewRow dgvRow     = cell.OwningRow;
            int             supplierId = StringUtil.GetSafeInt(dgvRow.Cells[SupplierIdIndex].Value);

            DataRow row = null;

            int rowCount = mItemSuppliersTbl.Rows.Count;

            for (int ii = 0; ii < rowCount; ++ii)
            {
                DataRow rowLoc = mItemSuppliersTbl.Rows[ii];
                if (StringUtil.GetSafeInt(rowLoc["SupplierId"]) == supplierId)
                {
                    row = rowLoc;
                }
            }

            if (row != null)
            {
                mItemSuppliersTbl.Rows.Remove(row);
            }

            buttonSaveItemSupplier_Click(sender, e);
            MessageBox.Show("删除供应商信息成功", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
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;
        }
Example #4
0
        private void ToolStripMenuItemEditNote_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection rows = this.pagedDgvSourcingNote.DgvData.SelectedRows;

            if (rows == null || rows.Count != 1)
            {
                return;
            }

            DataGridViewRow row = rows[0];

            if (row == null)
            {
                return;
            }

            int noteId            = StringUtil.GetSafeInt(row.Cells[0].Value);
            SourcingNoteType note = SourcingNoteDAL.GetSourcingNoteById(noteId);

            if (note == null)
            {
                return;
            }

            FrmEditSourcingNote frm = new FrmEditSourcingNote(note);

            frm.StartPosition = FormStartPosition.CenterParent;
            frm.ShowDialog();

            this.pagedDgvSourcingNote.LoadData();
        }
Example #5
0
        public static InventoryItemType GetItemBySKU(string SKU)
        {
            DataTable dt = GetItemTableBySKU(SKU);

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

            DataRow dr = dt.Rows[0];

            InventoryItemType item = new InventoryItemType();

            item.ItemId                = StringUtil.GetSafeInt(dr["ItemId"]);
            item.CategoryId            = Int32.Parse(dr["CategoryId"].ToString());
            item.ItemName              = dr["ItemName"].ToString();
            item.ItemSKU               = SKU;
            item.ItemImagePath         = StringUtil.GetSafeString(dr["ItemImagePath"]);
            item.ItemStockShresholdNum = Int32.Parse(dr["ItemStockShresholdNum"].ToString());
            item.ItemStockNum          = Int32.Parse(dr["ItemStockNum"].ToString());
            item.ItemSourcingInfo      = dr["ItemSourcingInfo"].ToString();
            item.ItemSourcingURL       = StringUtil.GetSafeString(dr["ItemSourcingURL"]);
            item.ItemCost              = Double.Parse(dr["ItemCost"].ToString());
            item.ItemWeight            = Double.Parse(dr["ItemWeight"].ToString());
            item.ItemCustomName        = dr["ItemCustomName"].ToString();
            item.ItemCustomWeight      = Double.Parse(dr["ItemCustomWeight"].ToString());
            item.ItemCustomCost        = Double.Parse(dr["ItemCustomCost"].ToString());
            item.ItemAddDateTime       = DateTime.Parse(dr["ItemAddDateTime"].ToString());
            item.IsGroupItem           = Boolean.Parse(dr["IsGroupItem"].ToString());
            item.SubItemSKUs           = dr["SubItemSKUs"].ToString();
            item.ItemNote              = StringUtil.GetSafeString(dr["ItemNote"]);

            return(item);
        }
Example #6
0
        private void ToolStripMenuItemDelSupplier_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("你确认刪除该供应商么?\r\n删除前,必须删除所有该供应商的采购单。",
                                "确认发货?",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            // Check if any sourcing notes related to this supplier, if so, disallow delete.
            // [ZHI_TODO]

            int rowIdx     = this.pagedDgvSupplier.DgvData.CurrentRow.Index;
            int supplierId = StringUtil.GetSafeInt(this.pagedDgvSupplier.DgvData.Rows[rowIdx].Cells[0].Value.ToString());

            SupplierType supplier = SupplierDAL.GetSupplierById(supplierId);

            if (supplier == null)
            {
                return;
            }

            SupplierDAL.DeleteOneSupplier(supplierId);
            MessageBox.Show(String.Format("删除供应商成功!", supplier.SupplierName),
                            "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.pagedDgvSupplier.LoadData();
        }
Example #7
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 #8
0
        private void LoadExistingSourcingNote()
        {
            if (mSourcingNote == null)
            {
                return;
            }

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

            if (supplier == null)
            {
                return;
            }

            mSupplier = supplier;

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

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

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

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

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

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

                mItemsTable.Rows.Add(dr);
            }

            this.dgvItems.DataSource = mItemsTable;
        }
Example #9
0
        private void dgvItemSuppliers_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            DataGridViewRow row = this.dgvItemSuppliers.Rows[e.RowIndex];

            if (StringUtil.GetSafeInt(row.Cells[SupplierIdIndex].Value) <= 0)
            {
                return;
            }

            this.buttonDelSupplier.Enabled = true;
        }
Example #10
0
        private void LoadAllCategories()
        {
            DataTable dtCategories = ItemCategoryDAL.GetAllCategories();

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

            this.treeViewAllCategories.Nodes.Clear();

            foreach (DataRow dr in dtCategories.Rows)
            {
                int    catId        = StringUtil.GetSafeInt(dr["CategoryId"]);
                int    parentCatId  = StringUtil.GetSafeInt(dr["ParentCategoryId"]);
                string catName      = StringUtil.GetSafeString(dr["CategoryName"]);
                string catSkuPrefix = StringUtil.GetSafeString(dr["CategorySkuPrefix"]);

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

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

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

                int catSkuPrefixVal = -1;
                if (Int32.TryParse(catSkuPrefix, out catSkuPrefixVal) && catSkuPrefixVal > maxSkuPrefix)
                {
                    maxSkuPrefix = catSkuPrefixVal;
                }
            }

            this.treeViewAllCategories.ExpandAll();
            return;
        }
        private static ItemStockInNoteType GetItemStockInNoteFromDataRow(DataRow dr)
        {
            ItemStockInNoteType note = new ItemStockInNoteType();

            note.NoteId         = StringUtil.GetSafeInt(dr["NoteId"]);
            note.ItemSKU        = StringUtil.GetSafeString(dr["ItemSKU"]);
            note.ItemTitle      = StringUtil.GetSafeString(dr["ItemTitle"]);
            note.SourcingNoteId = StringUtil.GetSafeString(dr["SourcingNoteId"]);
            note.StockInNum     = StringUtil.GetSafeInt(dr["StockInNum"]);
            note.StockInDate    = StringUtil.GetSafeDateTime(dr["StockInDate"]);
            note.Comment        = StringUtil.GetSafeString(dr["Comment"]);
            return(note);
        }
Example #12
0
        private static DeliveryNoteType GetDeliveryNoteFromDataRow(DataRow dr)
        {
            DeliveryNoteType note = new DeliveryNoteType();

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

            return(note);
        }
Example #13
0
        private static SupplierType GetSupplierFromDataRow(DataRow dr)
        {
            SupplierType supplier = new SupplierType();

            supplier.SupplierID    = StringUtil.GetSafeInt(dr["SupplierID"]);
            supplier.SupplierName  = StringUtil.GetSafeString(dr["SupplierName"]);
            supplier.SupplierTel   = StringUtil.GetSafeString(dr["SupplierTel"]);
            supplier.SupplierLink1 = StringUtil.GetSafeString(dr["SupplierLink1"]);
            supplier.SupplierLink2 = StringUtil.GetSafeString(dr["SupplierLink2"]);
            supplier.SupplierLink3 = StringUtil.GetSafeString(dr["SupplierLink3"]);
            supplier.Comment       = StringUtil.GetSafeString(dr["Comment"]);

            return(supplier);
        }
Example #14
0
        // Returns null if no record corresponds to itemID;
        public static EbayActiveListingType GetOneActiveListing(String itemID)
        {
            if (itemID == null || itemID.Trim().Length == 0)
            {
                return(null);
            }

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

            DataTable dt = DataFactory.ExecuteSqlReturnTable(sql_getOneActiveListing);

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

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

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

            return(activeListing);
        }
        // Delete a message template category, if there are any message templates under
        // this category, prompt user.
        private void ToolStripMenuItemDelCategory_Click(object sender, EventArgs e)
        {
            TreeNode node = treeViewMessageTemplate.SelectedNode;

            if (node == null)
            {
                return;
            }

            if (node.Tag == null)
            {
                return;
            }

            if (node.Tag.GetType() != typeof(MessageTemplateCategoryType))
            {
                return;
            }

            MessageTemplateCategoryType categoryType = (MessageTemplateCategoryType)node.Tag;
            int categoryId = categoryType.CategoryId;

            DataTable dtMessageTemplates = MessageTemplateDAL.GetAllMessageTemplatesWithCategoryId(categoryId);

            if (dtMessageTemplates.Rows.Count > 0)
            {
                if (MessageBox.Show(string.Format("确认删除主题 {0}? 我们将删除所有隶属该主题的消息模板",
                                                  categoryType.CategoryName), "请确认",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                    == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }

            // Either cases:
            //  1) The category has message templates and user confirmed to delete the category.
            //  2) The category has no message templates.

            // Delete all the relevant message templates first.
            foreach (DataRow dr in dtMessageTemplates.Rows)
            {
                int messageTemplateId = StringUtil.GetSafeInt(dr["TemplateId"]);
                MessageTemplateDAL.DeleteOneMessageTemplate(messageTemplateId);
            }

            MessageTemplateCategoryDAL.DeleteOneMessageTemplateCategory(categoryType.CategoryId);
            treeViewMessageTemplate.Nodes.Remove(node);
        }
Example #16
0
        void DgvData_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            foreach (DataGridViewRow row in pagedDgvSourcingNote.DgvData.Rows)
            {
                int          supplierId = StringUtil.GetSafeInt(row.Cells[1].Value);
                SupplierType supplier   = SupplierDAL.GetSupplierById(supplierId);

                if (supplier == null)
                {
                    continue;
                }

                row.Cells[2].Value = supplier.SupplierName;
            }
        }
        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);
        }
        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);
        }
Example #19
0
        private static SourcingNoteType GetSourcingNoteFromDataRow(DataRow dr)
        {
            SourcingNoteType note = new SourcingNoteType();

            note.SourcingId    = StringUtil.GetSafeInt(dr["SourcingId"]);
            note.SupplierId    = StringUtil.GetSafeInt(dr["SupplierId"]);
            note.ItemSkuList   = StringUtil.GetSafeString(dr["ItemSkuList"]);
            note.ItemNumList   = StringUtil.GetSafeString(dr["ItemNumList"]);
            note.ItemPriceList = StringUtil.GetSafeString(dr["ItemPriceList"]);
            note.ExtraFee      = StringUtil.GetSafeDouble(dr["ExtraFee"]);
            note.ShippingFee   = StringUtil.GetSafeDouble(dr["ShippingFee"]);
            note.TotalFee      = StringUtil.GetSafeDouble(dr["TotalFee"]);
            note.Comment       = StringUtil.GetSafeString(dr["Comment"]);
            note.SourcingDate  = StringUtil.GetSafeDateTime(dr["SourcingDate"]);
            return(note);
        }
Example #20
0
        private void LoadAllMessageTemplates()
        {
            this.tvMessageTemplates.Nodes.Clear();

            DataTable dtMessageCategories = MessageTemplateCategoryDAL.GetAllMessageTemplateCategories();
            DataTable dtMessageTemplates  = MessageTemplateDAL.GetAllMessageTemplates();

            foreach (DataRow drCategory in dtMessageCategories.Rows)
            {
                int    categoryId   = StringUtil.GetSafeInt(drCategory["CategoryId"]);
                String categoryName = StringUtil.GetSafeString(drCategory["CategoryName"]);
                MessageTemplateCategoryType catType = new MessageTemplateCategoryType();

                TreeNode catNode = new TreeNode();
                catNode.Tag  = catType;
                catNode.Text = categoryName;
                catNode.Name = categoryId.ToString();

                this.tvMessageTemplates.Nodes.Add(catNode);
            }

            foreach (DataRow drMessageTemplate in dtMessageTemplates.Rows)
            {
                int    templateId      = StringUtil.GetSafeInt(drMessageTemplate["TemplateId"]);
                int    categoryId      = StringUtil.GetSafeInt(drMessageTemplate["TemplateCategoryId"]);
                String templateName    = StringUtil.GetSafeString(drMessageTemplate["TemplateName"]);
                String templateContent = StringUtil.GetSafeString(drMessageTemplate["TemplateContent"]);

                MessageTemplateType templateType = new MessageTemplateType();
                templateType.TemplateId         = templateId;
                templateType.TemplateCategoryId = categoryId;
                templateType.TemplateName       = templateName;
                templateType.TemplateContent    = templateContent;

                TreeNode msgNode = new TreeNode();
                msgNode.Tag  = templateType;
                msgNode.Text = templateName;

                TreeNode[] catNodes = this.tvMessageTemplates.Nodes.Find(categoryId.ToString(), false);
                if (catNodes.Length > 0)
                {
                    catNodes[0].Nodes.Add(msgNode);
                }
            }

            this.tvMessageTemplates.ExpandAll();
        }
Example #21
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 #22
0
        private void OnDgvDataBindCompleted()
        {
            for (int rowIdx = 0; rowIdx < this.pagedDgvItem.DgvData.Rows.Count; rowIdx++)
            {
                DataGridViewCell cell = this.pagedDgvItem.DgvData.Rows[rowIdx].Cells[2];
                if (cell == null)
                {
                    continue;
                }

                int stockNum = StringUtil.GetSafeInt(cell.Value);
                if (stockNum == 0)
                {
                    this.pagedDgvItem.DgvData.Rows[rowIdx].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#D4D4D6");
                }
            }
        }
Example #23
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);
        }
Example #24
0
        private void ToolStripMenuItemEditSupplier_Click(object sender, EventArgs e)
        {
            int rowIdx     = this.pagedDgvSupplier.DgvData.CurrentRow.Index;
            int supplierId = StringUtil.GetSafeInt(this.pagedDgvSupplier.DgvData.Rows[rowIdx].Cells[0].Value.ToString());

            SupplierType supplier = SupplierDAL.GetSupplierById(supplierId);

            if (supplier == null)
            {
                return;
            }

            FrmEditSupplier frmEditSupplier = new FrmEditSupplier(supplierId);

            frmEditSupplier.ShowDialog();

            this.pagedDgvSupplier.LoadData();
        }
        public static MessageTemplateCategoryType GetMessageTemplateCategory(String categoryName)
        {
            String sql_getCategory
                = String.Format("select * from [MessageTemplateCategory] where CategoryName='{0}'", categoryName);
            DataTable dt = DataFactory.ExecuteSqlReturnTable(sql_getCategory);

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

            DataRow dr = dt.Rows[0];

            MessageTemplateCategoryType categoryType = new MessageTemplateCategoryType();

            categoryType.CategoryId       = StringUtil.GetSafeInt(dr["CategoryId"]);
            categoryType.ParentCategoryId = StringUtil.GetSafeInt(dr["ParentCategoryId"]);
            categoryType.CategoryName     = StringUtil.GetSafeString(dr["CategoryName"]);
            return(categoryType);
        }
Example #26
0
        private void btnFinishSelecting_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = this.pagedDgvSupplier.DgvData.CurrentRow;

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

            int supplierId = StringUtil.GetSafeInt(row.Cells[0].Value);

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

            this.Close();
        }
        public static MessageTemplateType GetMessageTemplate(int parentCategoryId, String templateName)
        {
            String sql_getTemplate
                = String.Format("select * from [MessageTemplate] where TemplateCategoryId={0} and TemplateName='{1}'",
                                parentCategoryId,
                                templateName);
            DataTable dt = DataFactory.ExecuteSqlReturnTable(sql_getTemplate);

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

            DataRow dr = dt.Rows[0];

            MessageTemplateType templateType = new MessageTemplateType();

            templateType.TemplateCategoryId = StringUtil.GetSafeInt(dr["TemplateCategoryId"]);
            templateType.TemplateName       = StringUtil.GetSafeString(dr["TemplateName"]);
            templateType.TemplateContent    = StringUtil.GetSafeString(dr["TemplateContent"]);
            return(templateType);
        }
        // Load all message template categories.
        private void LoadAllMessageTemplateCategories()
        {
            DataTable dtCategories = MessageTemplateCategoryDAL.GetAllMessageTemplateCategories();

            this.treeViewMessageTemplate.Nodes.Clear();

            foreach (DataRow dr in dtCategories.Rows)
            {
                int    categoryId   = StringUtil.GetSafeInt(dr["CategoryId"]);
                String categoryName = StringUtil.GetSafeString(dr["CategoryName"]);

                MessageTemplateCategoryType categoryType = new MessageTemplateCategoryType();
                categoryType.CategoryId   = categoryId;
                categoryType.CategoryName = categoryName;

                TreeNode newNode = new TreeNode();
                newNode.Tag  = categoryType;
                newNode.Text = categoryName;
                newNode.Name = categoryId.ToString();
                this.treeViewMessageTemplate.Nodes.Add(newNode);
            }
        }
Example #29
0
        public static EbayMessageType GetOneMessage(String ebayMessageId)
        {
            String    sql_getAllMessages = String.Format("select * from [Message] where EbayMessageId='{0}'", ebayMessageId);
            DataTable dt = DbAccess.ExecuteSqlReturnTable(sql_getAllMessages);

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

            DataRow         dr  = dt.Rows[0];
            EbayMessageType msg = new EbayMessageType();

            msg.MessageId         = StringUtil.GetSafeInt(dr["MessageId"]);
            msg.SellerName        = StringUtil.GetSafeString(dr["SellerName"]);
            msg.EbayMessageId     = StringUtil.GetSafeString(dr["EbayMessageId"]);
            msg.MessageType       = StringUtil.GetSafeString(dr["MessageType"]);
            msg.QuestionType      = StringUtil.GetSafeString(dr["QuestionType"]);
            msg.IsRead            = StringUtil.GetSafeBool(dr["IsRead"]);
            msg.IsReplied         = StringUtil.GetSafeBool(dr["IsReplied"]);
            msg.IsResponseEnabled = StringUtil.GetSafeBool(dr["IsResponseEnabled"]);
            msg.ResponseURL       = StringUtil.GetSafeString(dr["ResponseURL"]);
            msg.UserResponseDate  = StringUtil.GetSafeDateTime(dr["UserResponseDate"]);
            msg.ReceiveDate       = StringUtil.GetSafeDateTime(dr["ReceiveDate"]);
            msg.Sender            = StringUtil.GetSafeString(dr["Sender"]);
            msg.RecipientUserId   = StringUtil.GetSafeString(dr["RecipientUserId"]);
            msg.Subject           = StringUtil.GetSafeString(dr["Subject"]);
            msg.Content           = StringUtil.GetSafeString(dr["MessageContent"]);
            msg.Text = StringUtil.GetSafeString(dr["MessageText"]);
            msg.ExternalMessageId = StringUtil.GetSafeString(dr["ExternalMessageId"]);
            msg.FolderId          = StringUtil.GetSafeInt(dr["FolderId"]);
            msg.ItemID            = StringUtil.GetSafeString(dr["ItemID"]);
            msg.ItemTitle         = StringUtil.GetSafeString(dr["ItemTitle"]);
            // ZHI_TODO:

            return(msg);
        }  // GetOneMessage
Example #30
0
        private void dataGridViewPostSale_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            if (e.ListChangedType == ListChangedType.ItemChanged)
            {
                return;
            }

            for (int rowIdx = 0; rowIdx < this.dataGridViewPostSale.Rows.Count; rowIdx++)
            {
                DataGridViewCell orderLineItemIdCell = this.dataGridViewPostSale.Rows[rowIdx].Cells[PostSaleDgv_OrderLineItemIdIdx];
                if (orderLineItemIdCell.Value == null)
                {
                    continue;
                }

                String  orderLineItemId = orderLineItemIdCell.Value.ToString();
                DataRow dr = getPostSaleOrderLocally(orderLineItemId);
                if (dr == null)
                {
                    continue;
                }

                int    transId    = StringUtil.GetSafeInt(dr["TransactionId"]);
                String buyerId    = StringUtil.GetSafeString(dr["BuyerId"]);
                String sellerName = StringUtil.GetSafeString(dr["SellerName"]);
                String itemId     = StringUtil.GetSafeString(dr["ItemId"]);

                if (buyerId == "" || sellerName == "" || itemId == "")
                {
                    continue;
                }

                TransactionMessageStatus messageStatus = (TransactionMessageStatus)StringUtil.GetSafeInt(dr["MessageStatus"]);

                if (messageStatus == TransactionMessageStatus.BuyerRepliedSellerNotReplied)
                {
                    TransactionMessageStatus messageStatusComputed
                        = EbayMessageDAL.GetTransactionMessageStatus(buyerId, sellerName, itemId);

                    if (messageStatus != messageStatusComputed)
                    {
                        EbayTransactionDAL.UpdateTransactionMessageStatus(transId, messageStatusComputed);
                        messageStatus = messageStatusComputed;
                    }
                }

                Color rowBkColor = Color.White;
                if (messageStatus == TransactionMessageStatus.SellerInquired)
                {
                    rowBkColor = ColorTranslator.FromHtml("#90EE90");
                }
                else if (messageStatus == TransactionMessageStatus.BuyerRepliedSellerNotReplied)
                {
                    rowBkColor = ColorTranslator.FromHtml("#FFFF00");
                }
                else if (messageStatus == TransactionMessageStatus.BuyerRepliedSellerReplied)
                {
                    rowBkColor = ColorTranslator.FromHtml("#DAA520");
                }

                if (!StringUtil.GetSafeBool(dr["IsPaid"]))
                {
                    rowBkColor = ColorTranslator.FromHtml("#808080");
                }

                this.dataGridViewPostSale.Rows[rowIdx].DefaultCellStyle.BackColor = rowBkColor;
            }
        }