protected void GridViewPoinPenilain_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Add") { try { GridViewRow row = GridViewPoinPenilaian.FooterRow; int getId = FestivalModel.GetMaksID(HiddenID.Value); getId++; TextBox poinpenilaian = (TextBox)row.FindControl("TextBoxPoinPenilaian"); var fd = new FestivalDetail(HiddenID.Value, getId, poinpenilaian.Text); Employee emp = (Employee)Session["Login"]; fd.CreatedBy = emp.employeeid; fd.UpdatedBy = emp.employeeid; int i = FestivalControl.InsertFestivalDetail(fd); bindGridViewFestivalDetail(HiddenID.Value); if (i > 0) ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('Data telah disimpan');", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('" + ex.Message + "');", true); } } }
protected void ButtonSubmit_Click(object sender, EventArgs e) { try { int rowCount = 0; if (String.IsNullOrEmpty(HiddenID.Value)) { int i = FestivalModel.GetMaksID(); i++; int temp = i; string enol = "00"; int digit = 0; while (temp != 0) { temp /= 10; digit++; } if (digit == 1) enol = "00"; else if (digit == 2) enol = "0"; else if (digit == 3) enol = ""; string newid = "FS" + enol + i; FestivalClass newfestival = new FestivalClass(newid, TextBoxNamaFestival.Text, RadioButtonListSistem.Text, TextBoxDescription.Text); Employee emp = (Employee)Session["Login"]; newfestival.CreatedBy = emp.employeeid; newfestival.UpdatedBy = emp.employeeid; rowCount=FestivalControl.InsertFestival(newfestival); clearField(); bindGridViewFestival(); bindGridViewFestivalDetail(""); } else { FestivalClass newfestival = new FestivalClass(HiddenID.Value, TextBoxNamaFestival.Text, RadioButtonListSistem.Text, TextBoxDescription.Text); Employee emp = (Employee)Session["Login"]; newfestival.UpdatedBy = emp.employeeid; rowCount= FestivalControl.UpdateFestival(newfestival); bindGridViewFestival(); clearField(); bindGridViewFestivalDetail(""); } if (rowCount > 0) ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('Data telah disimpan');", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('" + ex.Message + "');", true); } }