using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Aram_CRM_Project.BLL.Entity;

namespace Aram_CRM_Project.BLL
{
    class CustomerCRUD : Aram_CRM_Project.DAL.DA
    {

        public DataTable SearchCustomer(Customer CustomerVar)
        {
            try
            {
                DataTable dtTemp = new DataTable();
                base.SQL = "SP_SearchCustomer";
                base.InitializeCommand();
                base.AddParameter("@Name", CustomerVar.Name);
                base.AddParameter("@Address", CustomerVar.Address);
                base.AddParameter("@Tel", CustomerVar.Tel);
                base.AddParameter("@Cell", CustomerVar.Cell);
                base.AddParameter("@CustomerGroupName", CustomerVar.CustomerGroupName);
                base.AddParameter("@CityStateName", CustomerVar.CityStateName);
                base.AddParameter("@RelationshipWayName", CustomerVar.RelationshipWayName);
                base.AddParameter("@StartBirthDate", CustomerVar.StartBirthDate);
                base.AddParameter("@EndBirthDate", CustomerVar.EndBirthDate);
                base.AddParameter("@StartMarriageDate", CustomerVar.StartMarriageDate);
                base.AddParameter("@EndMarriageDate", CustomerVar.EndMarriageDate);
                base.FillDataTable(dtTemp);
                return dtTemp;
            }
            catch(Exception exp)
            {
                return null;
            }
        }

        public DataTable SearchCustomerWithoutDate(Customer CustomerVar)
        {
            try
            {
                DataTable dtTemp = new DataTable();
                base.SQL = "SP_SearchCustomerWithoutDate";
                base.InitializeCommand();
                base.AddParameter("@Name", CustomerVar.Name);
                base.AddParameter("@Address", CustomerVar.Address);
                base.AddParameter("@Tel", CustomerVar.Tel);
                base.AddParameter("@Cell", CustomerVar.Cell);
                base.AddParameter("@CustomerGroupName", CustomerVar.CustomerGroupName);
                base.AddParameter("@CityStateName", CustomerVar.CityStateName);
                base.AddParameter("@RelationshipWayName", CustomerVar.RelationshipWayName);
                base.FillDataTable(dtTemp);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }

        public DataTable SearchCustomerWithMarriage(Customer CustomerVar)
        {
            try
            {
                DataTable dtTemp = new DataTable();
                base.SQL = "SP_SearchCustomerWithMarriage";
                base.InitializeCommand();
                base.AddParameter("@Name", CustomerVar.Name);
                base.AddParameter("@Address", CustomerVar.Address);
                base.AddParameter("@Tel", CustomerVar.Tel);
                base.AddParameter("@Cell", CustomerVar.Cell);
                base.AddParameter("@CustomerGroupName", CustomerVar.CustomerGroupName);
                base.AddParameter("@CityStateName", CustomerVar.CityStateName);
                base.AddParameter("@RelationshipWayName", CustomerVar.RelationshipWayName);
                base.AddParameter("@StartMarriageDate", CustomerVar.StartMarriageDate);
                base.AddParameter("@EndMarriageDate", CustomerVar.EndMarriageDate);
                base.FillDataTable(dtTemp);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }

        public DataTable SearchCustomerWithBirth(Customer CustomerVar)
        {
            try
            {
                DataTable dtTemp = new DataTable();
                base.SQL = "SP_SearchCustomerWithBirth";
                base.InitializeCommand();
                base.AddParameter("@Name", CustomerVar.Name);
                base.AddParameter("@Address", CustomerVar.Address);
                base.AddParameter("@Tel", CustomerVar.Tel);
                base.AddParameter("@Cell", CustomerVar.Cell);
                base.AddParameter("@CustomerGroupName", CustomerVar.CustomerGroupName);
                base.AddParameter("@CityStateName", CustomerVar.CityStateName);
                base.AddParameter("@RelationshipWayName", CustomerVar.RelationshipWayName);
                base.AddParameter("@StartBirthDate", CustomerVar.StartBirthDate);
                base.AddParameter("@EndBirthDate", CustomerVar.EndBirthDate);
                base.FillDataTable(dtTemp);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }

        public DataTable SearchOrderStatistic(Customer CustomerVar)
        {
            try
            {
                DataTable dtTemp = new DataTable();
                base.SQL = "SP_SearchOrderStatistic";
                base.InitializeCommand();
                base.AddParameter("@CustomerId", CustomerVar.Id);
                base.AddParameter("@Stuff", CustomerVar.Stuff);
                base.AddParameter("@StartDate", CustomerVar.StartDate);
                base.AddParameter("@EndDate", CustomerVar.EndDate);
                base.FillDataTable(dtTemp);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }

        public DataTable SearchReserveStatistic(Customer CustomerVar)
        {
            try
            {
                DataTable dtTemp = new DataTable();
                base.SQL = "SP_SearchReserveStatistic";
                base.InitializeCommand();
                base.AddParameter("@CustomerId", CustomerVar.Id);
                base.AddParameter("@Stuff", CustomerVar.Stuff);
                base.AddParameter("@StartDate", CustomerVar.StartDate);
                base.AddParameter("@EndDate", CustomerVar.EndDate);
                base.FillDataTable(dtTemp);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }

        public DataTable SearchOrderIdStatistic(string OrderId,string CustomerId)
        {
            try
            {
                DataTable dtTemp = new DataTable();
                base.SQL = "SP_SearchOrderIdStatistic";
                base.InitializeCommand();
                base.AddParameter("@OrderId", OrderId);
                base.AddParameter("@CustomerId", CustomerId);
                base.FillDataTable(dtTemp);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }

        public DataTable SearchReserveIdStatistic(string ReserveId, string CustomerId)
        {
            try
            {
                DataTable dtTemp = new DataTable();
                base.SQL = "SP_SearchReserveIdStatistic";
                base.InitializeCommand();
                base.AddParameter("@ReserveId", ReserveId);
                base.AddParameter("@CustomerId", CustomerId);
                base.FillDataTable(dtTemp);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }
        

        public DataTable ShowCustomerGroupForSearchComboBox()
        {
            try
            {
                DataTable dtTemp = new DataTable();
                DataRow dr = dtTemp.NewRow();

                base.SQL = "SP_GetCustomerGroupForComboBox";
                base.InitializeCommand();
                base.FillDataTable(dtTemp);
                dr["Id"] = 0;
                dr["Name"] = "همه گروه ها";
                dtTemp.Rows.Add(dr);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }

        public DataTable ShowCityStateForSearchComboBox()
        {
            try
            {
                DataTable dtTemp = new DataTable();
                DataRow dr = dtTemp.NewRow();

                base.SQL = "SP_GetCityStateForComboBox";
                base.InitializeCommand();
                base.FillDataTable(dtTemp);
                dr["Id"] = 0;
                dr["Name"] = "همه مناطق";
                dtTemp.Rows.Add(dr);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }

        public DataTable ShowRelationshipWayForSearchComboBox()
        {
            try
            {
                DataTable dtTemp = new DataTable();
                DataRow dr = dtTemp.NewRow();

                base.SQL = "SP_GetRelationshipWayForComboBox";
                base.InitializeCommand();
                base.FillDataTable(dtTemp);
                dr["Id"] = 0;
                dr["Name"] = "همه موارد";
                dtTemp.Rows.Add(dr);
                return dtTemp;
            }
            catch (Exception exp)
            {
                return null;
            }
        }

    }
}
