Example #1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         Genaration gen = new Genaration()
         {
             //Convert.ToInt32(dgvList.Rows[0].Cells[0].Value
             Gen_id   = Convert.ToInt32(dgvList.Rows[0].Cells[0].Value),
             Gen_name = dgvList.Rows[0].Cells[1].Value.ToString(),
             Gen_red  = tbGenRed.Text,
             Gen_tag  = tbGenTag.Text,
             Gen_char = dgvList.Rows[0].Cells[2].Value.ToString(),
             Gen_big  = tbGenBig.Text,
         };
         GenarationDAL gdal = new GenarationDAL();
         if (gdal.Update(gen) == true)
         {
             MessageBox.Show("更新成功!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("更新失败!" + ex.Message);
     }
 }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //if (dgvList.DataSource != null)
            //{
            //    MessageBox.Show("您已经添加过族谱了哦!请勿重复添加");
            //}
            //else
            //{
            dgvList.Rows[0].Cells[2].Value = tbGenRed.Text;
            dgvList.Rows[0].Cells[3].Value = tbGenTag.Text;
            dgvList.Rows[0].Cells[5].Value = tbGenBig.Text;
            Genaration gen = new Genaration()
            {
                Gen_id   = Convert.ToInt32(dgvList.Rows[0].Cells[0].Value),
                Gen_name = dgvList.Rows[0].Cells[1].Value.ToString(),
                Gen_char = dgvList.Rows[0].Cells[2].Value.ToString(),
                Gen_red  = dgvList.Rows[0].Cells[3].Value.ToString(),
                Gen_tag  = dgvList.Rows[0].Cells[4].Value.ToString(),
                Gen_big  = dgvList.Rows[0].Cells[5].Value.ToString(),
            };
            GenarationDAL gdal = new GenarationDAL();

            try
            {
                if (gdal.Add(gen) == 0)
                {
                    MessageBox.Show("添加成功");
                }
                else
                {
                    MessageBox.Show("添加失败,请重试!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("添加异常!" + ex.Message);
            }
            //}
        }