Exemple #1
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();
        }
Exemple #2
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();
        }
        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; });
            }
        }
Exemple #4
0
 public static object SafelyOperated(Control context, Delegate process)
 {
     return(ControlUtil.SafelyOperated(context, process, null));
 }
Exemple #5
0
 private void 選択中の票を印刷PToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ControlUtil.DGV_ExSelect(this.dataGridView1);
     this.PrintSelections();
 }
Exemple #6
0
 //[Print]
 private void button4_Click(object sender, EventArgs e)
 {
     ControlUtil.DGV_ExSelect(this.dataGridView1);
     this.PrintSelections();
 }
        //別スレッド
        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);
        }