using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace DAL
{
    public sealed class SandoghMethods:Method
    {
        public bool Insert(string sname, string mojodi)
        {
            SqlParameter[] p = new SqlParameter[2];
            p[0] = new SqlParameter();
            p[0].ParameterName = "@sname";
            p[0].SqlDbType = System.Data.SqlDbType.NChar;
            p[0].Value = sname;
            //
            p[1] = new SqlParameter();
            p[1].ParameterName = "@mojodi";
            p[1].SqlDbType = System.Data.SqlDbType.Decimal;
            p[1].Value = mojodi;

            return this.ExecuteNonQuery("InsertSandogh", p, true);
        }

        public bool Update(string sname, string mojodi)
        {
            SqlParameter[] p = new SqlParameter[2];
            p[0] = new SqlParameter();
            p[0].ParameterName = "@sname";
            p[0].SqlDbType = System.Data.SqlDbType.NChar;
            p[0].Value = sname;
            //
            p[1] = new SqlParameter();
            p[1].ParameterName = "@mojodi";
            p[1].SqlDbType = System.Data.SqlDbType.Decimal;
            p[1].Value = mojodi;

            return this.ExecuteNonQuery("UpdateSandogh", p, true);
        }

        public bool Delete(string sname)
        {
            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter();
            p[0].ParameterName = "@sname";
            p[0].SqlDbType = System.Data.SqlDbType.NChar;
            p[0].Value = sname;
            return this.ExecuteNonQuery("DELETE FROM Sandogh WHERE sname=@sname", p, false);
        }

        public object SelectAll()
        {
            return this.ExecuteReader("SELECT * FROM Sandogh", null, false);
        }

        public object Select(string sname)
        {
            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter();
            p[0].ParameterName = "@sname";
            p[0].SqlDbType = System.Data.SqlDbType.NChar;
            p[0].Value = sname;
            return this.ExecuteReader("SELECT * FROM Sandogh WHERE sname=@sname", p, false);
        }
    }
}
