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


namespace DAL
{
    public sealed class KharidMethods:Method
    {
        public bool Insert(string sanadid, string fakid, string kalaid, string number, string kharid, string date)
        {
            SqlParameter[] p = new SqlParameter[6];
            p[0] = new SqlParameter();
            p[0].ParameterName = "@sanadid";
            p[0].SqlDbType = System.Data.SqlDbType.Decimal;
            p[0].Value = sanadid;
            //
            p[1] = new SqlParameter();
            p[1].ParameterName = "@fakid";
            p[1].SqlDbType = System.Data.SqlDbType.Decimal;
            p[1].Value = fakid;
            //
            p[2] = new SqlParameter();
            p[2].ParameterName = "@kalaid";
            p[2].SqlDbType = System.Data.SqlDbType.NChar;
            p[2].Value = kalaid;
            //
            p[3] = new SqlParameter();
            p[3].ParameterName = "@number";
            p[3].SqlDbType = System.Data.SqlDbType.Int;
            p[3].Value = number;
            //
            p[4] = new SqlParameter();
            p[4].ParameterName = "@kharid";
            p[4].SqlDbType = System.Data.SqlDbType.Decimal;
            p[4].Value = kharid;
            //
            p[5] = new SqlParameter();
            p[5].ParameterName = "@date";
            p[5].SqlDbType = System.Data.SqlDbType.NChar;
            p[5].Value = date;
            //
            return this.ExecuteNonQuery("InsertKharid", p, true);
        }

        public object GetNewKharidSanadId()
        {
            return this.ExecuteScalar("GetNewKharidSanadId", null, true);
        }

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

        public object GetMojodiKala(string kalaid)
        {

            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter();
            p[0].ParameterName = "@kalaid";
            p[0].SqlDbType = System.Data.SqlDbType.NChar;
            p[0].Value = kalaid;
            return this.ExecuteScalar("GetMojodiKala", p, true);
        }
    }
}
