using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Site.Customer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AddCustomerRecord : CustomerRecordBasePage
{
    protected string IID;
    public bool IsDealer = IronIntel.Contractor.SystemParams.IsDealer;
    protected bool CRReadOnly = false;
    protected bool AllowCanOpenWO = false;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckLoginSession())
        {
            RedirectToLoginPage();
        }
        else
        {
            string methodName = Request.Form["MethodName"];
            if (!string.IsNullOrEmpty(methodName))
            {
                ProcessRequest();
            }
            else if (!IsPostBack)
            {
                this.Title = PageTitle;
                bool license = SystemParams.HasLicense("CustomerRecord");
                if (!license)
                    RedirectToLoginPage();

                bool permission = CheckRight(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
                if (!permission)
                    RedirectToLoginPage();

                CRReadOnly = CheckReadonly(SystemParams.CompanyID, Feature.CUSTOMER_RECORD);
                AllowCanOpenWO = SystemParams.HasLicense("AllowWOCreationFromFleetManagementPage");
            }
        }
    }

    public bool IsSupperAdmin
    {
        get
        {
            var user = GetCurrentUser();
            return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
        }
    }
}