My design
BILLING DETAILS | ||
> | ||
onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="146px" AppendDataBoundItems="True"> | ||
onselectedindexchanged="DropDownList2_SelectedIndexChanged" Height="16px" Width="146px"> | ||
onselectedindexchanged="DropDownList3_SelectedIndexChanged" Width="149px" > | ||
> | ||
ontextchanged="TextBox6_TextChanged"> | ||
ontextchanged="TextBox3_TextChanged" > | ||
AutoPostBack="true" Text="(14.5/100)" ReadOnly="True" > ontextchanged="TextBox4_TextChanged"> | ||
type | ||
Coding
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using TestWebMsgApp;
using NTRUHS;
public partial class Admin_Default : System.Web.UI.Page
{
REMO sel = new REMO();
DataSet ds = new DataSet();
// string s = ConfigurationManager.AppSettings["RM"].ToString();
SqlConnection cn;
SqlCommand cd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
public int se;
public float sl;
public Admin_Default()
{
//cn = new SqlConnection("Data Source=VALUED-HO1E64NO\\SQLEXPRESS;Initial Catalog=Agri;User ID=sa;Password=watt;Integrated Security =True");
// cn.Open();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadQuantity();
//prr();
sno();
pqice();
txtdate.Text = System.DateTime.Now.ToString("dd-MM-yyyy");
}
}
private void sno()
{
string bill=sel.getmaxid("BillNo", "cement1");
txtbillno.Text = bill.ToString();
/* // int z = 0;
//ListItem cb = new ListItem();
// ds = sel.GETDS("select Billno from numbeer");
ds = sel.GETDS("select min (Billno) as Billno from numbeer where status='view'");
foreach (DataRow dr in ds.Tables[0].Rows)
{
//ListItem sw = new ListItem();
txtbillno.Text = dr["Billno"].ToString();
//sw.Value = Convert.ToString(z + 1);
}*/
}
private void pqice()
{
ListItem lik = new ListItem();
// lik.Text = "Select";
DropDownList3.Items.Insert(0, new ListItem("--Select--", "0"));
lik.Value = "0";
for (int se = 1; se <= 700; se++)
{
DropDownList3.Items.Add(Convert.ToString(se));
}
}
private void prr()
{
int s = 0;
ListItem lim = new ListItem();
//lim.Text = "Select";
//lim.Value = "0";
//DropDownList1.Items.Add(lim.ToString());
ds = sel.GETDS("select DISTINCT name from demo");
//DropDownList1.Items.Insert(0, new ListItem("--Select--", "0"));
foreach (DataRow dr in ds.Tables[0].Rows)
{
DropDownList1.Items.Clear();
ListItem ss = new ListItem();
lim.Text = dr["name"].ToString();
lim.Value = Convert.ToString(s + 1);
DropDownList1.Items.Add(lim.ToString());
}
}
void LoadQuantity()
{
ds = sel.GETDS("select DISTINCT name from demo");
foreach (DataRow dr in ds.Tables[0].Rows)
{
// DropDownList1.Items.Clear();
ListItem ss = new ListItem();
ss.Text = dr["name"].ToString();
//ss.Value = Convert.ToString(s + 1);
DropDownList1.Items.Add(ss.ToString());
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
DataSet ds = new DataSet();
string qr = "select weight from demo where name='" + DropDownList1.SelectedValue.ToString() + "'";
ds = sel.GETDS(qr);
ListItem se = new ListItem();
//se.Value = "0";
//se.Text = "Select";
DropDownList2.Items.Insert(0, new ListItem("--Select--", "0"));
foreach (DataRow dr in ds.Tables[0].Rows)
{
ListItem liz = new ListItem();
//liz.Text = "Select";
liz.Value = dr["weight"].ToString();
DropDownList2.Items.Add(liz.ToString());
}
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
ListItem sss = new ListItem();
// sss.Text = "Select";
DropDownList2.Items.Insert(0, new ListItem("--Select--", "0"));
DataSet ds = new DataSet();
string sq = "select price from demo where weight='" + DropDownList2.SelectedItem.ToString() + "'";
ds = sel.GETDS(sq);
TextBox1.Text = ds.Tables[0].Rows[0]["price"].ToString();
foreach (DataRow dr in ds.Tables[0].Rows)
{
TextBox1.Text = dr["price"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
/* string qrt = "exec ins_cement values ('" + txtdate.Text;
qrt += "','" + txtbillno.Text;
qrt += "','" + txtcn.Text;
qrt += "','" + txtad.Text;
qrt += "','" + DropDownList1.SelectedItem.ToString();
qrt += "','" + DropDownList2.SelectedItem.ToString();
qrt += "','" + TextBox1.Text;
// qrt += "','" + ddprice.SelectedItem.ToString();
qrt += "','" + txtex.Text;
qrt += "')";
sel.Insert(qrt);
Label10.Visible = true;
Label10.Text = "Sucess";
cn = new SqlConnection(s);
//cn.Open();
//string qrs = "insert into product (date,Product,BillNo,ProductName,Quantity,Price,Extra) values ('" + txtdate.Text;
//qrs += "','" + TextBox2.Text;
//qrs += "','" + txtbillno.Text;
////sqrs += "','" + txtcn.Text;
//qrs += "','" + DropDownList1.SelectedItem.ToString();
//qrs += "','" + DropDownList2.SelectedItem.ToString();
//qrs += "','" + TextBox1.Text;
////qrs += "','" + ddprice.SelectedItem.ToString();
//qrs += "','" + txtex.Text;
//qrs += "')";
////sel.Insert(qrs);
//cd = new SqlCommand(qrs, cn);
//cd.ExecuteNonQuery();
//cn.Close();
string up = "update numbeer set status='Viewed' where Billno='" + txtbillno.Text + "'";
sel.Insert(up);*/
SqlParameter[] p = new SqlParameter[15];
try
{
p[0] = new SqlParameter("@Product", TextBox2.Text);
p[1] = new SqlParameter("@Date", txtdate.Text);
p[2] = new SqlParameter("@BillNo", txtbillno.Text);
p[3] = new SqlParameter("@CustomerName", txtcn.Text);
p[4] = new SqlParameter("@Address", txtad.Text);
p[5] = new SqlParameter("@BrandName", DropDownList1.SelectedItem.Text);
p[6] = new SqlParameter("@Quantity", DropDownList2.SelectedItem.Text);
p[7] = new SqlParameter("@ProductPrice", TextBox1.Text);
p[8] = new SqlParameter("@Requiredno", DropDownList3.SelectedItem.Text);
p[9] = new SqlParameter("@Price", txttp.Text);
p[10] = new SqlParameter("@Extra", txtvat.Text);
p[11] = new SqlParameter("@Vat", txtex.Text);
p[12] = new SqlParameter("@TotalAmount", TextBox7.Text);
p[13] = new SqlParameter("@CorrectPrice", TextBox5.Text);
p[14] = new SqlParameter("@type", TextBox8.Text);
int res = SqlHelper.ExecuteNonQuery(Cls_Connection.ConnectionString, CommandType.StoredProcedure, "im", p);
if (res == 2)
{
WebMsgBox.Show("Product Data Submited Successfully ");
Session["bno"] = txtbillno.Text;
//ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('cementreport.aspx');", true);
clear();
}
else
{
WebMsgBox.Show("Product Data Not Submited");
}
}
catch( Exception e1)
{
}
}
protected void Button2_Click(object sender, EventArgs e)
{
clear();
}
public void clear()
{
//txtdate.Text = "";
txtbillno.Text = "";
txtcn.Text = "";
txtad.Text = "";
DropDownList1.SelectedIndex = 0;
DropDownList2.SelectedIndex = 0;
DropDownList3.SelectedIndex = 0;
txttp.Text = "";
TextBox6.Text = "";
txtvat.Text = "";
TextBox7.Text = "";
TextBox3.Text = "";
TextBox1.Text = "";
//txtex.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
sno();
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
float sl =(Convert.ToSingle(DropDownList3.Text)* Convert.ToSingle(TextBox1.Text));
txttp.Text = Convert.ToString(sl);
TextBox6.Text = (int.Parse(txttp.Text) * (14.5 / 100)).ToString();
}
protected void txtvat_TextChanged(object sender, EventArgs e)
{
float amm=(float.Parse(txttp.Text)+float.Parse(txtvat.Text));
TextBox3.Text = Convert.ToString(amm);
double guna = int.Parse(TextBox3.Text) * (14.5 / 100);
TextBox4.Text = Convert.ToString(guna);
TextBox5.Text = (amm + guna).ToString();
float s =Convert.ToSingle(txttp.Text) + Convert.ToSingle(TextBox6.Text);
TextBox7.Text=s.ToString();
//float amman = (sl+ float.Parse(TextBox6.Text));
//TextBox7.Text = Convert.ToString(amman);
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{
float sgs = int.Parse(TextBox3.Text) + int.Parse(TextBox4.Text);
TextBox5.Text = Convert.ToString(sgs);
}
protected void TextBox6_TextChanged(object sender, EventArgs e)
{
double value1 = Convert.ToDouble(txttp.Text);
double v2 = Convert.ToDouble(TextBox6.Text);
double t = value1 + v2;
TextBox7.Text = Convert.ToString(t);
}
protected void TextBox3_TextChanged(object sender, EventArgs e)
{
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("~/Admin/cementreport1.aspx");
}
}
it throw error like this
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
My procedure is
USE [Agri]
GO
/****** Object: StoredProcedure [dbo].[im] Script Date: 09/17/2013 14:35:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[im]
(@Product varchar(15),@Date varchar(50) ,@BillNo varchar(30) ,
@CustomerName varchar(50),@Address varchar(50) ,
@BrandName varchar(50) ,@Quantity varchar(20),
@ProductPrice varchar(20) ,@Requiredno varchar(50),
@Price varchar(50),@Extra varchar(20) ,
@Vat varchar(50),@TotalAmount varchar(50),
@CorrectPrice varchar(50),@type varchar(10)
)
AS
BEGIN
insert into sampl (ProductName,Date,BillNo,CustomerName,Address,BrandName,
Quantity,ProductPrice,Requiredno,Price,Vat,TotalAmount,type)
values(@Product,@Date,@BillNo ,@CustomerName ,@Address ,@BrandName ,
@Quantity ,@ProductPrice ,@Requiredno ,@Price ,@Vat ,@TotalAmount,@type);
insert into samle (ProductName,Date,BillNo,CustomerName,Address,BrandName,
Quantity,ProductPrice,Requiredno,Price,Extra,Vat,CorrectPrice) values
(@Product ,@Date,@BillNo ,@CustomerName ,@Address ,@BrandName ,@Quantity ,
@ProductPrice ,@Requiredno ,@Price ,@Extra ,
@Vat,@CorrectPrice );
if @type='s'
begin
declare @purno int
set @purno=(select purno from pr where brandname=@brandname)
declare @Reqno int
set @reqno=(select requiredno from sampl where brandname=@brandname)
update pr set purno=@purno-@Reqno where BrandName=@BrandName
end
END

Shankar MPosted Sep 17, 2013, 7:34 AM
Hi Selvi,
Rewrite your query to return a single value. You get this error when you compare the select statement against a subquery using = operator where the subquery return more than one value.
The error may have occured in the SET statement. Try checking it with the direct Input supplied and see how many rows are returned.