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

namespace BLL
{
    public class Anbar
    {
        string _acode;
        string _kalaid;
        string _kalaname;
        string _mojodi;
        string _kharid;

        public string acode
        {
            set { _acode = value; }
            get { return _acode; }
        }
        public string kalaid
        {
            get
            {
                return _kalaid;
            }
            set
            {
                this._kalaid = value;

            }
        }
        public string Mojodi
        {
            get
            {
                return _mojodi;
            }
            set
            {
                this._mojodi = value;

            }
        }
        public string kalaname
        {
            get
            {
                return _kalaname;
            }
            set
            {
                this._kalaname = value;

            }
        }

        public string kharid
        {
            set
            {
                _kharid = value;
            }
            get
            {
                return _kharid;
            }
        }

        public static List<Anbar> GetAllKalas()
        {
            AnbarMethods methods = new AnbarMethods();
            return GetAllKalas((IDataReader)methods.SelectAll());
        }

        private static List<Anbar> GetAllKalas(IDataReader reader)
        {
            List<Anbar> tempList = new List<Anbar>();
            while (reader.Read())
            {
                try
                {
                    Anbar temp = new Anbar
                    {
                        acode = reader["acode"].ToString(),
                        kalaid = reader["kalaid"].ToString(),
                        kalaname = reader["kalaname"].ToString(),
                        Mojodi = reader["mojodi"].ToString(),
                        kharid = reader["kharid"].ToString()
                    };
                    tempList.Add(temp);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message.ToString());
                }
            }
            return tempList;
        }

        public static void DeleteZeroMojodi()
        {
            AnbarMethods methods = new AnbarMethods();
            methods.DeleteZeroMojodi();
        }

        public void Insert()
        {
            AnbarMethods methods = new AnbarMethods();
            methods.Insert(this.kalaid, this.kharid, this.Mojodi);
        }

        public void Update()
        {
            AnbarMethods methods = new AnbarMethods();
            methods.Update(this.acode, this.kalaid, this.kharid, this.Mojodi);
        }

        public void Delete()
        {
            AnbarMethods methods = new AnbarMethods();
            methods.Delete(this.acode);
        }

        public static object GetMojodiKala(string kalaid)
        {
            AnbarMethods methods = new AnbarMethods();
            return methods.GetMojodiKala(kalaid);
        }
    }
}
