using System;
using System.Data;
using System.Configuration;
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;

/// <summary>
///SupplierClass 的摘要说明
/// </summary>
public class SupplierClass
{
    DataSet ds = new DataSet();
    SqlConnection con = ConSql.ConnectionSql();

  /// <summary>
  /// 添加供货商信息
  /// </summary>
  /// <param name="sst"></param>
  /// <returns></returns>
    public string SupplierAdd(SupplierST sst)
    {
        string messgae = "";
        SqlCommand cmd = new SqlCommand();                           //创建SqlCommand对象
        cmd.Connection = con;
        cmd.CommandText = "insert into supplier([name],addr1,zip,phone,city,state) values(@name,@addr,@zip,@phone,@city,@state)";

        cmd.Parameters.Add("@name", SqlDbType.VarChar).Value = sst.Name;
        cmd.Parameters.Add("@addr", SqlDbType.VarChar).Value = sst.Addr1 ;
        cmd.Parameters.Add("@zip", SqlDbType.VarChar).Value = sst.Zip;
        cmd.Parameters.Add("@phone", SqlDbType.VarChar).Value = sst.Phone;
        cmd.Parameters.Add("@city", SqlDbType.VarChar).Value = sst.City;
        cmd.Parameters.Add("@state", SqlDbType.VarChar).Value = sst.State;
       
        try
        {
            con.Open();            //打开数据库
            if (cmd.ExecuteNonQuery() > 0)              //执行SQL语句
            {
                messgae = "供货商添加成功！";
            }
            else
            {
                messgae = "供货商添加失败！";
            }
        }
        catch(Exception ex)
        {
            messgae = "数据库打开出错！";
        }
        finally
        {
            con.Close();      //关闭数据库           
        }
        return messgae;
    }

}
