selvi subramanian

selvi subramanian

  • NA
  • 799
  • 572.8k

radio button data are not inserted in asp.net

May 9 2015 6:13 AM
private void bilno()
{
if (RadioButton1.Checked)
{
gen = TextBox1.Text;
}
else
{
gen = "No";
}
}
button click
try
{
bilnumber();
con = new SqlConnection(s);
con.Open();
string qry = "sectionexpenses";
cmd = new SqlCommand(qry, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@sectionname", SqlDbType.VarChar).Value = Sectionselect.Text;
// cmd.Parameters.Add("@Expensestype", SqlDbType.VarChar).Value = DropDownList1.Text;
cmd.Parameters.Add("@ExpensesName", SqlDbType.VarChar).Value = Ddexpenz.Text;
cmd.Parameters.Add("@Date", SqlDbType.VarChar).Value = TdATE.Text;
cmd.Parameters.Add("@BillNo", SqlDbType.VarChar).Value = bil;
cmd.Parameters.Add("@BillAmount", SqlDbType.Float).Value = bamountsave.Text;
cmd.Parameters.Add("@currentdate", SqlDbType.VarChar).Value = TextBox4.Text;
cmd.Parameters.Add("@partydetz", SqlDbType.VarChar).Value = DropDownList1.SelectedItem.ToString();
cmd.Parameters.Add("@bdate", SqlDbType.DateTime).Value = DateTime.ParseExact(TdATE.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);
int rs = cmd.ExecuteNonQuery();
if (rs == 1)
{
Response.Write("<script>alert('Data Inserted Successfully!')</script>");
snoi.Visible = false;
Printdata.Focus();
}
else
{
Response.Write("<script>alert('Data Not Inserted !')</script>");
}
}
catch
{
throw;
}
}
}
my proceudre
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sectionexpenses]
(@sectionname varchar(30),
@ExpensesName varchar(max),
@Date varchar(30),
@BillNo varchar(max),
@BillAmount float,
@currentdate varchar(50),
@partydetz varchar(max),
@bdate datetime)
AS
DECLARE @Result int
BEGIN TRANSACTION
IF EXISTS
(
SELECT * FROM expenzsection WHERE sectionname=@sectionname
and partydetz=@partydetz and BillAmount=@BillAmount
)
BEGIN
SELECT @Result = -1
END
ELSE
begin
insert into Expenzsection(sectionname,ExpensesName,Date,BillNo,BillAmount,currentdate,partydetz,bdate)
values
(
@sectionname,@ExpensesName,@Date,@BillNo,@BillAmount,@currentdate,@partydetz,@bdate
)
SELECT @Result = @@ERROR
end
IF @Result <> 0
BEGIN
ROLLBACK
END
ELSE
BEGIN
COMMIT
END
RETURN @Result
if billno is yes means data is inserted sucessfully .............. billno is
NO means data are not inserted

Answers (1)