i cant give(pass) NAME,ABBR to my insert_city function
public string city, abbr;
public string NAME
{
get { return city; }
set { city = value; }
}
public string ABBR
{
get { return abbr; }
set { abbr = value; }
}
public static string insert_city()
{
SqlParameter[] p = new SqlParameter[2];
p[0] = new SqlParameter("@NAME",NAME.get);
p[1] = new SqlParameter("@ABBR",ABBR.get);
return DAL.project.SqlDataProvider.insert_city(p);
}
What I have tried:
is used 3tire architecture with two class library(bll,dal)
my dals code is :
public static string insert_city()
{
bookingEntities db = new bookingEntities();
CITY ct = new CITY();
ct.NAME = @NAME;
ct.ABBR = @ABBR;
db.CITies.Add(ct);
db.SaveChanges();
return ct.NAME;
}
in my blls code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL.project;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace BLL.project
{
public class DataProvider
{
public DataProvider()
{
}
public string city, abbr;
public string NAME
{
get { return city; }
set { city = value; }
}
public string ABBR
{
get { return abbr; }
set { abbr = value; }
}
//
public static string insert_city()
{
SqlParameter[] p = new SqlParameter[2];
p[0] = new SqlParameter("@NAME",NAME.get);
p[1] = new SqlParameter("@ABBR",ABBR.get);
return DAL.project.SqlDataProvider.insert_city(p);
}
and in my persentaions code :
public partial class Default4 : System.Web.UI.Page
{
DataProvider obj = new DataProvider();
protected void Button15_Click(object sender, EventArgs e)
{
obj.city = Convert.ToString(TextBox4.Text);
obj.abbr = Convert.ToString(TextBox5.Text);
if (!String.IsNullOrEmpty(obj.city))
{
if (!String.IsNullOrEmpty(obj.abbr))
{
string ci = BLL.project.DataProvider.insert_city();
Label28.Text = "شهر " + ci + " به لیست شهر ها اضافه شد.";
}
else
{
Label28.Text = "اختصار نمیتواند خالی باشد.";
}
}
else
{
Label28.Text = " نام شهر نمی تواند خالی باشد.";
}
}
}