Untitled

mail@pastecode.io avatar
unknown
csharp
2 years ago
1.4 kB
5
Indexable
Never
 private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int secilenDersID = int.Parse(cbDers.SelectedValue.ToString());
                string OgrenciNo = dataGridView1.Rows[e.RowIndex].Cells["OgrenciId"].Value.ToString();
                int OgrenciNoParsed = int.Parse(OgrenciNo);
                MiniOBSEntities vt = new MiniOBSEntities();
                var result = vt.OgrenciNot.SingleOrDefault(on => on.OgrenciId == OgrenciNoParsed && on.DersId == secilenDersID);
                if (result != null)
                {
                    var vizeValue = dataGridView1.Rows[e.RowIndex].Cells["VizeNot"].Value;
                    var finalValue = dataGridView1.Rows[e.RowIndex].Cells["FinalNot"].Value;
                    if (vizeValue != null)
                    {
                        result.VizeNot = vizeValue.ToString();
                    }
                    if (finalValue != null)
                    {
                        result.FinalNot = finalValue.ToString();
                    }
                    
                    
                    vt.SaveChanges();
                    MessageBox.Show("Not Güncelleme Başarılı");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Not Güncelleme Başarısız");
            }
        }