//fungsi: Handle Permintaan Tambah data, Tampilkan FormView protected void lblTambah_Click(object sender, EventArgs e) { if (Page.IsValid) { FvChangeShift.DefaultMode = FormViewMode.Insert; FvChangeShift.ChangeMode(FormViewMode.Insert); showGridView(false); } }
//fungsi: Handle ketika tombol Edit di GridView di tekan protected void GvChangeShift_RowEditing(object sender, GridViewEditEventArgs e) { if (Page.IsValid) { dsChangeShift.SelectCommand = "SELECT NIP, PIN, NAMA, TGL_AWAL, TGL_AKHIR, KODE_SHIFT FROM q_UbahPola"; if (isEntryUseNIP()) { dsChangeShift.SelectCommand += " WHERE NIP = '" + GvChangeShift.Rows[e.NewEditIndex].Cells[0].Text + "' AND TGL_AWAL = '" + DateTime.Parse(((Label)GvChangeShift.Rows[e.NewEditIndex].Cells[2].FindControl("lblCol2Item")).Text).ToString("MM/dd/yyyy") + "'"; } else { dsChangeShift.SelectCommand += " WHERE PIN = '" + GvChangeShift.Rows[e.NewEditIndex].Cells[0].Text + "' AND TGL_AWAL = '" + DateTime.Parse(((Label)GvChangeShift.Rows[e.NewEditIndex].Cells[2].FindControl("lblCol2Item")).Text).ToString("MM/dd/yyyy") + "'"; } e.Cancel = true; FvChangeShift.DefaultMode = FormViewMode.Edit; FvChangeShift.ChangeMode(FormViewMode.Edit); showGridView(false); } else { e.Cancel = true; } }