void Save() { foreach (DataGridViewRow row in dataGridView1.Rows) { // Yes if ((bool)row.Cells[2].Value == true && (bool)row.Cells[3].Value == false) { currentobj.ID = (int)row.Cells[0].Value; currentobj.AmenitiesTypeID = (int)CMBAmenitiesType.SelectedValue; currentobj.AmenitiesName = row.Cells[1].Value.ToString(); currentobj.Statuis = true; currentobj.Update(); // frm.Add((int)row.Cells[0].Value); } // No if ((bool)row.Cells[3].Value == true || (bool)row.Cells[2].Value == (bool)row.Cells[3].Value) { currentobj = currentobj.GetByID((int)row.Cells[0].Value); if (currentobj.Statuis == true) { currentobj.ID = (int)row.Cells[0].Value; currentobj.AmenitiesTypeID = (int)CMBAmenitiesType.SelectedValue; currentobj.AmenitiesName = row.Cells[1].Value.ToString(); currentobj.Statuis = false; currentobj.Update(); // Amenitiestobj.Delete((int)row.Cells[0].Value); } } } }
void Updated() { currentobj.AmenitiesTypeID = int.Parse(CMBType.SelectedValue.ToString()); currentobj.AmenitiesName = txtName.Text; currentobj.ID = ID; bool msg = currentobj.Update(); if (msg == true) { frmDone frmdone = new frmDone("Update Done"); frmdone.ShowDialog(); BindGrid(); } else { frmDone frmdone = new frmDone("Error"); frmdone.ShowDialog(); } }