@dharmendr
problem solved use this code sir
the validation working properly and then save the data.
thanks much for the help.
using javascript for validation
<script type="text/javascript">
$(document).ready(function () {
$(document).on('click', '[id*=btnModalAddDataPengambilan]', function () {
var JmlPengambilan = $("[id*=txtjumlah_pengambilan]").val();
var Saldo = $("[id*=txt_Saldo]").val();
if (JmlPengambilan > Saldo) {
alert('The maximum amount taken must not be greater than the Balance Amount !!!')
return false
}
else if (JmlPengambilan >= Saldo) {
alert('The maximum amount of taken should not be less than the minimum balance of !!! \n Minimum Balance must be prepared Rp. 50.000')
return false
}
else {
alert('OK... Data Valid...')
return true
}
});
});
</script>
then data saved properly
protected void btnModalAddDataPengambilan_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "PopUp", "MessageSucces();", true);
AddDataPengambilan();
ShowData();
}
private void AddDataPengambilan()
{
using (SqlConnection con = new SqlConnection(koneksi))
{
using (SqlCommand cmd = new SqlCommand("spAddPengambilan"))
{
try
{
con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id_pengambilan", txtid_pengambilan.Text.Trim());
cmd.Parameters.AddWithValue("@tanggal_pengambilan", txttanggal_pengambilan.Text.Trim());
cmd.Parameters.AddWithValue("@id_anggota", txtid_anggota.Text.Trim());
cmd.Parameters.AddWithValue("@jumlah_pengambilan", txtjumlah_pengambilan.Text.Trim());
cmd.Parameters.AddWithValue("@id_user", txtid_user.Text.Trim());
cmd.Parameters.AddWithValue("@id_perusahaan", txtid_perusahaan.Text.Trim());
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
throw ex;
}
}
}
}