コード例 #1
0
        private void BindItem(bool isFlush)
        {
            if (UserHelper.ContractItemList == null || isFlush == true)
            {
                int projectId = Convert.ToInt32(this.SelectedProject.SelectedValue);

                List <ContractItem> list = null;
                list = _sc.QueryContractItem(projectId);
                UserHelper.ContractItemList = list;
            }
            this.dataGridView1.AutoGenerateColumns = false;
            this.dataGridView1.DataSource          = UserHelper.ContractItemList;
        }
コード例 #2
0
        //绑定栏目三工程量
        //根据项目名称类型去获取相应的工程量item
        private void AddItem_Click(object sender, EventArgs e)           //添加主要项目和工程量
        {
            //项目id
            int projectid = Convert.ToInt32(this.xmName.SelectedValue);

            List <ContractItem> list = new List <ContractItem>();

            list = _sc.QueryContractItem(projectid);
            UserHelper.ContractItemList = list;

            int      num = (this.ProjectPanel.Controls.Count - 1) / 6;
            ComboBox cmb = new ComboBox();

            cmb.Size          = new Size(120, 29);
            cmb.Location      = new Point(10, 10 + 34 * num);
            cmb.Name          = "Item_" + (1 * num + 1).ToString();
            cmb.ValueMember   = "Id";
            cmb.DisplayMember = "Item";
            cmb.DataSource    = UserHelper.ContractItemList;
            //cmb.SelectedIndexChanged += cmb_SelectedIndexChanged;    //用于绑定工作量和投资额
            this.ProjectPanel.Controls.Add(cmb);
            Label l = new Label();

            l.Size     = new Size(70, 29);
            l.Location = new Point(130, 10 + 34 * num);
            l.Text     = "工作量:";
            l.Name     = "WorkDsc_" + (1 * num + 1).ToString();
            this.ProjectPanel.Controls.Add(l);
            TextBox t = new TextBox();

            t.Size     = new Size(60, 29);
            t.Location = new Point(202, 10 + 34 * num);
            t.Name     = "WorkNum_" + (1 * num + 1).ToString();
            this.ProjectPanel.Controls.Add(t);
            Label l1 = new Label();

            l1.Size     = new Size(70, 29);
            l1.Location = new Point(269, 10 + 34 * num);
            l1.Text     = "投资额:";
            l1.Name     = "ExpenseDsc_" + (1 * num + 1).ToString();
            this.ProjectPanel.Controls.Add(l1);
            TextBox t1 = new TextBox();

            t1.Size     = new Size(60, 29);
            t1.Location = new Point(341, 10 + 34 * num);
            t1.Name     = "Expense_" + (1 * num + 1).ToString();
            this.ProjectPanel.Controls.Add(t1);
            Button b = new Button();

            b.Size     = new Size(60, 29);
            b.Location = new Point(411, 10 + 34 * num);
            b.Name     = "Delete_" + (1 * num + 1).ToString();
            b.Text     = "删除";
            //增加按钮事件
            b.Click += new EventHandler(b_Click);
            this.ProjectPanel.Controls.Add(b);
            this.ProjectPanel.Height = this.ProjectPanel.Height + 34;
        }