Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
protected void btnadd_Click(object sender, EventArgs e)

    {

     string totalPid = txtcname.Text.Trim().ToUpper() + "-" + txtcid.Text.Trim();
    int? InsertProductdetStatus;
    objProductsPL.prodName = totalPid;
    objProductsPL.productname = txtname.Text.Trim().ToString();
    objProductsPL.unitweight = Convert.ToInt32(txtunit.Text.ToString());
    objProductsPL.company = txtcompany.Text.ToString();
    objProductsPL.purpose = (txtpurpose.Text.Trim().ToString()== "" ? null : txtpurpose.Text.Trim());
    objProductsPL.producttype = ddlproducttype1.SelectedItem.Text.ToString();
    objProductsPL.unitprice = Convert.ToDouble(txtunitprice.Text.ToString());
    objProductsPL.productid3 = ddlctype.SelectedItem.Text.ToString();
    objProductsPL.username = Session["username"].ToString();
    InsertProductdetStatus = objProductsBAL.ProductidDetInsert(objProductsPL);
    if (InsertProductdetStatus.Equals(1))
    {
        ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "UpdateDetails", "alert('Details Already Exist');", true);

    }
    else if (InsertProductdetStatus.Equals(2))
    {


    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "UpdateDetails", "alert('Added Successfully');", true);
        Grid();
        clear();
        bindRate();
    }


}



Here I added my Product,without any problem..but i want to display previous price,current price column using sql server..so what i do..but it is based on Product Name..if I enter Same product second time,it will show the previous price column Rate.....Please Any one Help Me
Posted
Updated 8-Oct-13 21:16pm
v15
Comments
Mahesh Bailwal 9-Oct-13 1:28am    
Your question is not clear. Do you want to maintain two price of product old price and new price in database ?
Siva Hyderabad 9-Oct-13 1:44am    
yes..Mahesh

Then the most easy method would be maintaining another column in Table named as "OldPrice".

At the time of data insertion, insert the Price to both "Price" and "OldPrice" columns.
While updating, update new Price to "Price" column and "Price" column value to "OldPrice" column.
 
Share this answer
 
Hi,

It is just logical problem,
first you need to two column one previous price and second one is current price, by default previous price=0;

Put the condition on Addbutton event:
1. check product name it is belong to gridview or not , if it is belong then get current price of first row and put the value in previous price column and current price have current price.
may both column value same or not.

if( gridview["Productname"][i]== productname)
{
gridview["previousprice"][currentrow]= gridview["currentprice"][i];
}

I hope that you got solution of your problem.

Thanks
Mohit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900