Example #1
0
        private void RefreshRemain()
        {
            System.Threading.Thread t = new System.Threading.Thread(delegate()
            {
                IItemDao itDao = GlobalData.getIDao <IItemDao>();
                UInt32 cnt;

                cnt = itDao.CountNeedKansaItem_NotFlagged();

                ControlUtil.SafelyOperated(this.textBox_remain, (MethodInvoker) delegate()
                {
                    this.textBox_remain.Text = cnt.ToString();
                });

                UInt32 allcnt;
                allcnt = itDao.CountNeedKansaItem();

                ControlUtil.SafelyOperated(this.textBox_allkansa, (MethodInvoker) delegate()
                {
                    this.textBox_allkansa.Text = allcnt.ToString();
                });

                UInt32 sum;
                sum = itDao.SumNeedKansaItem_SellPrice();
                ControlUtil.SafelyOperated(this.textBox_sum, (MethodInvoker) delegate()
                {
                    this.textBox_sum.Text = sum.ToString("#,##0");
                });
            });

            t.IsBackground = true;
            t.Start();
        }
Example #2
0
        public void RefreshStatusBar()
        {
            System.Threading.Thread t = new System.Threading.Thread(
                (delegate() {
                try
                {
                    IItemDao itemDao = GlobalData.getIDao <IItemDao>();
                    string itemcount = itemDao.CountAll().ToString() + "個の商品";
                    string sold = "売上 ¥" + itemDao.SumSellPrice().ToString("#,##0") + "- " + itemDao.CountSoldItem().ToString() + "個";

                    ControlUtil.SafelyOperated(this.statusStrip1,
                                               (MethodInvoker) delegate()
                    {
                        this.status_itemcount.Text = itemcount;
                    });

                    ControlUtil.SafelyOperated(this.statusStrip1,
                                               (MethodInvoker) delegate()
                    {
                        this.status_sold.Text = sold;
                    });
                }
                catch { }
            }));
            t.Start();
        }
Example #3
0
        protected void setTitleConvBarcodeThread(object obj, BarcodeType type)
        {
            DataGridViewCell cell = (DataGridViewCell)obj;

            if (cell.ToolTipText == this.tooltip_BarcodeSearching)
            {
                return;
            }

            bool f = false;

            try
            {
                ControlUtil.SafelyOperated(this, (MethodInvoker) delegate() { cell.ToolTipText = this.tooltip_BarcodeSearching; });
                f = this.setTitleConvBarcode_Impl(cell, type);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "ISBN/JAN検索");
            }
            finally
            {
                if (f == false)
                {
                    //書名をセットしなかった
                }

                ControlUtil.SafelyOperated(this, (MethodInvoker) delegate() { cell.ToolTipText = null; });
            }
        }
Example #4
0
 public static object SafelyOperated(Control context, Delegate process)
 {
     return(ControlUtil.SafelyOperated(context, process, null));
 }
Example #5
0
        //別スレッド
        protected bool setTitleConvBarcode_Impl(DataGridViewCell cell, BarcodeType type)
        {
            if (cell.DataGridView.Columns[cell.ColumnIndex].Name != ColumnName.shouhinMei)
            {
                throw new Exception("商品名の列以外ではISBN/JANサーチはできません");
            }

            string code = (string)cell.Value;

            SignedRequestHelper helper = new SignedRequestHelper("13R1P6WSEW5Y6CP6MVR2", "yv69PdUY09Mosx/k4T9mwiP2xbcDZG6HMF4fsNuX", "ecs.amazonaws.jp");


            IDictionary <string, string> requestParams = new Dictionary <string, String>();

            requestParams["Service"]   = "AWSECommerceService";
            requestParams["Version"]   = "2009-11-01";
            requestParams["Operation"] = "ItemLookup";
            requestParams["ItemId"]    = code;

            if (type == BarcodeType.Isbn)
            {
                requestParams["IdType"] = "ISBN";
            }
            //else if (type == BarcodeType.Jan)
            else
            {
                requestParams["IdType"] = "EAN";
            }
            requestParams["SearchIndex"] = "All";

            string url = helper.Sign(requestParams);

            System.Diagnostics.Debug.WriteLine(url);

            System.Net.WebClient webc = new System.Net.WebClient();

            using (Stream st = webc.OpenRead(url))
            {
                if (st == null)
                {
                    return(false);
                }
                using (StreamReader sr = new StreamReader(st, Encoding.UTF8))
                {
                    XmlDocument xdoc = new XmlDocument();
                    xdoc.Load(sr);

                    XmlNodeList xlist = xdoc.GetElementsByTagName("Title", @"http://webservices.amazon.com/AWSECommerceService/2009-11-01");

                    if (xlist.Count > 0)
                    {
                        XmlNode xtitle = xlist.Item(0);
                        ControlUtil.SafelyOperated(this, (MethodInvoker) delegate()
                        {
                            cell.DataGridView[ColumnName.isbn, cell.RowIndex].Value = decimal.Parse(code);
                            cell.Value = xtitle.InnerText;
                        });
                        return(true);
                    }
                }
            }

            ControlUtil.SafelyOperated(this, (MethodInvoker) delegate()
            {
                cell.DataGridView[ColumnName.isbn, cell.RowIndex].Value = null;
            });

            return(false);
        }