this is a Class in my code:
public class Pr
{
public Pr()
{
//Blank Instructor
}
public void AddP(string code, string name, double price)
{
string str = "Select * From products Where pcode='" + code + "';";
string dbName = "DataBaseS.mdb";
DataTable dt = new DataTable();
dt = Dbase.SelectFromTable(str, dbName);
if (dt.Rows.Count == 0)
{
string strSql = "INSERT INTO [products] ([pcode] , [pname] , [pprice]) VALUES ('" + code
+ "','" + name + "','" + "','" + price + "');";
int didItWork = Dbase.ChangeTable(strSql, dbName);
}
}
public void DeleteP(string code)
{
string str = "Select * From products Where pcode='" + code + "';";
string dbName = "DataBaseS.mdb";
DataTable dt = new DataTable();
dt = Dbase.SelectFromTable(str, dbName);
if (dt.Rows.Count == 0)
{
string strSql = "DELETE * From [products] WHERE pcode='" + code + "');";
int didItWork = Dbase.ChangeTable(strSql, dbName);
}
}
public void UpdatePPrice(string code, double price)
{
string str = "Select * From products Where pcode='" + code + "';";
string dbName = "DataBaseS.mdb";
DataTable dt = new DataTable();
dt = Dbase.SelectFromTable(str, dbName);
if (dt.Rows.Count == 0)
{
string strSql = "UPDATE [products] SET pprice='" + price + "' WHERE pcode='" + code +
"');";
int didItWork = Dbase.ChangeTable(strSql, dbName);
}
}
}
This Class is used in a webform with master page as following:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebProject.Site1
{
public partial class UpdateProducts : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Pr pr = new Pr();
if (addcheck.Checked)
{
double pprice = double.Parse(addproductprice.Text);
pr.AddP(addproductcode.Text, addproductname.Text, pprice);
changedone.Text = "product added";
changedone.Visible = true;
}
if (deletecheck.Checked)
{
pr.DeleteP(addproductcode.Text);
changedone.Text = "product deleted";
changedone.Visible = true;
}
if (addcheck.Checked)
{
double cpprice = double.Parse(changeproductprice.Text);
pr.ChangePPrice(addproductcode.Text, cpprice);
changedone.Text = "price changed";
changedone.Visible = true;
}
}
}
}
A red line is shown under the command "Pr pr = new Pr();" and it says :"The type or namespace name 'Pr' could not be found (are you missing a using directive or an assembly refrence?)"
What is wrong with the code? I mean the red line is only under the command where I define a new Pr but it isn't shown under cmmands like "pr.DeleteP(addproductcode.Text);".