コード例 #1
0
ファイル: Form1.cs プロジェクト: LiLulong/Dragon_Library
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab == tpplus) //创建新卡选项卡
            {
                ReadInfo(txtxiaofeiID, txtxiaofeiName);
            }
            else if (tabControl1.SelectedTab == tpplus)//账户充值选项卡
            {
                while (getinvatehandle && string.IsNullOrEmpty(txtxiaofeiID.Text))
                {
                    ReadInfo(txtxiaofeiID, txtxiaofeiName);
                }
            }
            else if (tabControl1.SelectedTab == tpselect)//账户查询选项卡
            {
                this.dgvUser.DataSource = UserInfoManage.GetAllUserinfos();
            }
            else if (tabControl1.SelectedTab == tpMinus) //消费记录选项卡
            {
                this.dgv.DataSource = UserInfoxiaofeiManage.SelectUserxiaofeiinfo();
            }
            else if (tabControl1.SelectedTab == tpgoods) //商品购物选项卡
            {
                this.listView1.Items.Clear();            //清空列表
                this.listView1.View = View.LargeIcon;    //视图样式

                List <GoodsInfo> list = GoodsInfoManage.AllGoodsInfo();
                foreach (GoodsInfo model in list)
                {
                    ListViewItem item = new ListViewItem();
                    item.SubItems[0].Text = model.GoodsName + "\n\t¥" + Math.Round(Convert.ToDecimal(model.GoodsPrice), 2);
                    item.Name             = model.GoodsID.ToString();
                    item.ImageIndex       = model.GoodsID - 1000;
                    this.listView1.Items.Add(item);
                }
                if (listView1.Items.Count > 0)
                {
                    listView1.Select();
                    listView1.Items[0].Selected = true;
                }
                while (getinvatehandle && string.IsNullOrEmpty(txtGoodsuserID.Text))
                {
                    ReadInfo(txtGoodsuserID, txtGoodsuserName);
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: LiLulong/Dragon_Library
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems == null || listView1.SelectedItems.Count < 1)
            {
                return;
            }
            ListViewItem item     = listView1.SelectedItems[0];
            int          id       = Convert.ToInt32(item.Name);
            GoodsInfo    goodinfo = GoodsInfoManage.AllGoodsInfoByGoodsID(id);

            if (goodinfo != null)
            {
                this.txtGoodsID.Text          = goodinfo.GoodsID.ToString();
                this.txtGoodsName.Text        = goodinfo.GoodsName;
                this.txtGoodsPrice.Text       = Math.Round(Convert.ToDecimal(goodinfo.GoodsPrice), 2).ToString();
                this.bttgoodsshooping.Enabled = true;
            }
            else
            {
                MessageBox.Show("该商品不存在!");
            }
        }