Пример #1
0
 protected void GridViewDesa_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try {
         DesaClass desadelete = new DesaClass(GridViewDesa.DataKeys[e.RowIndex][0].ToString());
         Employee  emp        = (Employee)Session["Login"];
         desadelete.CreatedBy = emp.employeeid;
         desadelete.UpdatedBy = emp.employeeid;
         int i = DesaControl.DeleteDesa(desadelete);
         if (i > 0)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('Data telah dihapus.');", true);
         }
         bindGridViewDesa();
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "showPop('" + ex.Message + "');", true);
     }
 }
Пример #2
0
 protected void ButtonSubmit_Click(object sender, EventArgs e)
 {
     try {
         int rowCount = 0;
         if (String.IsNullOrEmpty(HiddenID.Value))
         {
             int i = DesaModel.GetMaksID();
             i++;
             string    newid   = "DS" + i;
             DesaClass newdesa = new DesaClass(newid, TextBoxNamaDesa.Text, TextBoxMesjidDesa.Text, TextBoxAlamat.Text);
             Employee  emp     = (Employee)Session["Login"];
             newdesa.CreatedBy = emp.employeeid;
             newdesa.UpdatedBy = emp.employeeid;
             rowCount          = DesaControl.InsertDesa(newdesa);
             clearField();
             bindGridViewDesa();
         }
         else
         {
             DesaClass newdesa = new DesaClass(HiddenID.Value, TextBoxNamaDesa.Text, TextBoxMesjidDesa.Text, TextBoxAlamat.Text);
             Employee  emp     = (Employee)Session["Login"];
             newdesa.CreatedBy = emp.employeeid;
             newdesa.UpdatedBy = emp.employeeid;
             rowCount          = DesaControl.UpdateDesa(newdesa);
             bindGridViewDesa();
             clearField();
         }
         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);
     }
 }