Example #1
0
        private void button_del_Click(object sender, EventArgs e)
        {
            //dataGridView1.SelectedRows
            foreach (DataGridViewRow dr in dataGridView1.SelectedRows)
            {
                int will_del_id = Convert.ToInt32(dr.Cells["componentId"].Value);
                del_list.Add(will_del_id);
                dataGridView1.Rows.Remove(dr);
            }
            return;

            int index = this.dataGridView1.CurrentCell.RowIndex;

            if (index >= 0 && index < this.dgvljjl.Rows.Count)
            {
                var id = this.dataGridView1.Rows[index].Cells["componentId"].Value;
                Maticsoft.BLL.component comp_bll = new Maticsoft.BLL.component();
                if (comp_bll.Delete(Convert.ToInt32(id)))
                {
                    MessageBox.Show("删除成功");
                }
                else
                {
                    MessageBox.Show("没有删除成功");
                }
            }
            requery();
        }
Example #2
0
 private void bt_update_Click(object sender, EventArgs e)
 {
     Maticsoft.BLL.component comp_bll = new Maticsoft.BLL.component();
     foreach (DataGridViewRow dgr in dataGridView1.Rows)
     {
         if (dgr != null)
         {
             Maticsoft.Model.component comp_mode = new Maticsoft.Model.component
             {
                 ARef        = dgr.Cells["ARef"].Value.ToString(),
                 componentId = Convert.ToInt32(dgr.Cells["componentId"].Value),
                 jobnum      = dgr.Cells["jobnum"].Value.ToString(),
                 size        = dgr.Cells["size"].Value.ToString(),
                 name        = dgr.Cells["name"].Value.ToString(),
                 photo       = dgr.Cells["photo"].Value.ToString(),
                 remark      = dgr.Cells["remark"].Value.ToString(),
                 sm          = dgr.Cells["sm"].Value.ToString(),
             };
             if (comp_bll.Update(comp_mode))
             {
                 // MessageBox.Show("更新成功");
             }
             else
             {
                 MessageBox.Show("更新失败");
             }
         }
     }
     foreach (int del_id in del_list)
     {
         if (comp_bll.Delete(del_id))
         {
             // MessageBox.Show("删除成功");
         }
         else
         {
             MessageBox.Show("没有删除成功");
         }
     }
     MessageBox.Show("提交成功");
     // DataGridViewRow dgr = dataGridView1.CurrentRow
 }