if i entered the sales return the balance is never change please refer my code in (Button1_Click) and desing.
if i click the to return i need to add balance + return its cuming but in that label it show as 9
balance is9 + return is 1=10 in label6 it show as 9 please check this error
my design
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="purchasereturn.aspx.cs" Inherits="purchasereturn" %>
.style1
{
width: 100%;
}
<%-- onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="120px"> | |
ontextchanged="TextBox5_TextChanged"> | |
my 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;
public partial class purchasereturn : System.Web.UI.Page
{
SqlConnection con;
SqlDataAdapter sda;
protected void Page_Load(object sender, EventArgs e)
{
con=new SqlConnection("Data Source=SELVI-PC\\SQLEXPRESS;Initial Catalog=demo;Persist Security Info=True;Integrated Security=True");
//sda = new SqlDataAdapter("select balance from purchase where barcode=" + DropDownList1.SelectedItem.Text.ToString(), con);
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["balance"]= TextBox4.Text;
try
{
if (TextBox5.Text != "")
{
TextBox4.Text = (Convert.ToInt32(TextBox4.Text) + Convert.ToInt32(TextBox5.Text)).ToString();
Label6.Text = "Our Balnce stock is" + (Session["balance"].ToString());
// DataSet ds = new DataSet();
//sda = new SqlDataAdapter("select balance from purchase where barcode=" + DropDownList1.SelectedItem.Text.ToString(), con);
//sda.Fill(ds);
//// Session["balance"] = TextBox4.Text;
// TextBox4.Text = ds.Tables[0].Rows[0]["balance"].ToString();
//Label6.Text = "Our Balnceis" + ds.Tables[0].Rows[0]["balance"].ToString();
//Label6.Text = "our bal is" + TextBox4.Text.ToString();
}
else if(TextBox5.Text=="")
{
Label6.Text = "Our Balnce stock is"+ (Session["balance"].ToString());
}
}
catch
{
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex > 0)
{
DataSet ds = new DataSet();
try
{
con.Open();
sda = new SqlDataAdapter("select balance from purchase where barcode=" + DropDownList1.SelectedItem.Text.ToString(), con);
sda.Fill(ds);
TextBox4.Text = ds.Tables[0].Rows[0]["balance"].ToString();
}
catch
{
}
}
}
protected void TextBox5_TextChanged(object sender, EventArgs e)
{
if (TextBox5.Text!= "")
{
Label6.Text = "Our Balnce stock is" + (Session["balance"].ToString());
}
else
{
}
}
}

Pawan KumarPosted May 1, 2014, 6:09 AM