Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var objmodel = new VendorSetupManagementModel();

            ViewBag.AccountSection = true;
            eTracLoginModel objLoginSession = new eTracLoginModel();

            objLoginSession = (eTracLoginModel)Session["eTrac"];
            try
            {
                long CountryId = 1;
                ViewBag.Country             = _ICommonMethod.GetAllcountries();
                ViewBag.StateList           = _ICommonMethod.GetStateByCountryId(CountryId);
                ViewBag.JobTitleList        = _ICommonMethod.GetGlobalCodeData("UserJobTitle");
                ViewBag.ClientInvoicingTerm = _IGlobalAdmin.ListClientInvoicingTerm();
                ViewBag.VendorType          = _IVendorManagement.ListVendorType();
                ViewBag.OperatingHolder     = _IGlobalAdmin.ListCompanyHolder(true);
                ViewBag.ContractType        = _IGlobalAdmin.ListContractType();
                ViewBag.PaymentModeList     = _IVendorManagement.PaymentModeList();
                ViewBag.PaymentTermList     = _IVendorManagement.PaymentTermList();
                ViewBag.CostCodeList        = _IVendorManagement.ListAllCostCode();
                ViewBag.LocationListData    = _ICommonMethod.ListAllLocation();
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message; ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger; return(View("Error"));
            }
            return(View("~/Areas/AdminSection/Views/AdminCompany/Index.cshtml", objmodel));//D:\Project\eTrac\WorkOrderEMS\Areas\AdminSection\Views\AdminCompany\CompanyView.cshtml
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Created By : Ashwajit Bansod
        /// Created For : To view account
        /// Created Date : 07-Jan-2019
        /// </summary>
        /// <param name="CompanyId"></param>
        /// <returns></returns>
        public ActionResult AddAccount(string CompanyId)
        {
            eTracLoginModel ObjLoginModel = null;
            var             objModel      = new VendorSetupManagementModel();

            try
            {
                ViewBag.AccountSection = true;
                long id = 0;
                if (Session != null && Session["eTrac"] != null)
                {
                    ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
                }
                if (!string.IsNullOrEmpty(CompanyId))
                {
                    ViewBag.UpdateMode = true;
                    CompanyId          = Cryptography.GetDecryptedData(CompanyId, true);
                    long.TryParse(CompanyId, out id);
                }
                var getCompanyDetails = _IVendorManagement.GetCompanyDetails(id);
                objModel.CompanyType    = getCompanyDetails.CompanyType;
                objModel.CompanyId      = id;
                objModel.VendorId       = id;
                ViewBag.PaymentModeList = _IVendorManagement.PaymentModeList();
            }
            catch (Exception ex)
            {
                ViewBag.Message           = ex.Message;
                ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
            }
            return(View("~/Areas/AdminSection/Views/AdminCompany/AddAccount.cshtml", objModel));
        }
        public ActionResult VendorDetails()
        {
            eTracLoginModel objLoginSession = new eTracLoginModel();

            if ((eTracLoginModel)Session["eTrac"] != null)
            {
                objLoginSession = (eTracLoginModel)Session["eTrac"];
            }
            var Obj = new VendorSetupManagementModel();

            ViewBag.VendorList = _IeCountingReport.GetAllVendorList(objLoginSession.LocationID);
            ViewBag.VendorType = _IVendorManagement.ListVendorType();
            return(PartialView("_VendorDetails", Obj));
        }
Ejemplo n.º 4
0
        public ActionResult Index(VendorSetupManagementModel Obj)
        {
            eTracLoginModel objLoginSession = new eTracLoginModel();

            ViewBag.AccountSection = true;
            objLoginSession        = (eTracLoginModel)Session["eTrac"];
            var _workorderems = new workorderEMSEntities();

            try
            {
                Obj.UserId = objLoginSession.UserId;
                //Obj.CompanyType = 2;
                if (Obj.VendorId == null)
                {
                    Obj.VendorId = 0;
                    if (Obj.CompanyDocumentsFile != null)
                    {
                        string FileName = objLoginSession.UserId + "_" + DateTime.Now.Ticks.ToString() + "_" + Convert.ToString(Obj.CompanyDocumentsFile.FileName);
                        CommonHelper.StaticUploadImage(Obj.CompanyDocumentsFile, Server.MapPath(ConfigurationManager.AppSettings["CompanyDocument"]), FileName);
                        Obj.CompanyDocuments = FileName;
                    }
                    if (Obj.VendorInsuranceModel.InsuranceDocumentFile != null)
                    {
                        string FileName = objLoginSession.UserId + "_" + DateTime.Now.Ticks.ToString() + "_" + Convert.ToString(Obj.VendorInsuranceModel.InsuranceDocumentFile.FileName);
                        CommonHelper.StaticUploadImage(Obj.VendorInsuranceModel.InsuranceDocumentFile, Server.MapPath(ConfigurationManager.AppSettings["LicenseAndInsuranceDocument"]), FileName);
                        Obj.VendorInsuranceModel.InsuranceDocument = FileName;
                    }
                    if (Obj.VendorInsuranceModel.LicenseDocumentFile != null)
                    {
                        string FileName = objLoginSession.UserId + "_" + DateTime.Now.Ticks.ToString() + "_" + Convert.ToString(Obj.VendorInsuranceModel.LicenseDocumentFile.FileName);
                        CommonHelper.StaticUploadImage(Obj.VendorInsuranceModel.LicenseDocumentFile, Server.MapPath(ConfigurationManager.AppSettings["LicenseAndInsuranceDocument"]), FileName);
                        Obj.VendorInsuranceModel.LicenseDocument = FileName;
                    }
                    if (Obj.VendorAccountDetailsModel.AccountDocumentsFile != null)
                    {
                        string FileName = objLoginSession.UserId + "_" + DateTime.Now.Ticks.ToString() + "_" + Convert.ToString(Obj.VendorAccountDetailsModel.AccountDocumentsFile.FileName);
                        CommonHelper.StaticUploadImage(Obj.VendorAccountDetailsModel.AccountDocumentsFile, Server.MapPath(ConfigurationManager.AppSettings["BankAccountDocsDocument"]), FileName);
                        Obj.VendorAccountDetailsModel.AccountDocuments = FileName;
                    }


                    //if (Session["realmId"] != null)
                    //{
                    string realmId = CallbackController.RealMId.ToString();// Session["realmId"].ToString();
                    try
                    {
                        string AccessToken = CallbackController.AccessToken.ToString();// Session["access_token"].ToString();
                        var    principal   = User as ClaimsPrincipal;
                        var    cmp_Data    = new CompanyInfo();
                        OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(AccessToken);

                        // Create a ServiceContext with Auth tokens and realmId
                        ServiceContext serviceContext = new ServiceContext(realmId, IntuitServicesType.QBO, oauthValidator);
                        serviceContext.IppConfiguration.MinorVersion.Qbo = "23";
                        DataService commonServiceQBO = new DataService(serviceContext);
                        // Create a QuickBooks QueryService using ServiceContext
                        QueryService <CompanyInfo> querySvc = new QueryService <CompanyInfo>(serviceContext);
                        CompanyInfo company = querySvc.ExecuteIdsQuery("SELECT * FROM CompanyInfo").FirstOrDefault();

                        QueryService <Account> querySvcAccount = new QueryService <Account>(serviceContext);
                        List <Account>         accountData     = querySvcAccount.ExecuteIdsQuery("SELECT * FROM Account MaxResults 1000").ToList();

                        var address       = new PhysicalAddress();
                        var emailaddr     = new EmailAddress();
                        var websiteAddr   = new WebSiteAddress();
                        var telephoneAddr = new TelephoneNumber();

                        var account = new Account();


                        var getCompanyInfo = _IVendorManagement.GetCompanyInfo(Convert.ToInt64(company.Id));
                        if (Obj.CompanyType == 2)
                        {
                            if (getCompanyInfo > 0)
                            {
                                ViewBag.Message           = CommonMessage.CompanyAlreadySaved();
                                ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                            }
                            else
                            {
                                address.City                 = Obj.Address1City;
                                address.Country              = "USA";
                                address.Line1                = Obj.Address1;
                                address.PostalCode           = company.CompanyAddr.PostalCode;
                                company.CompanyAddr          = address;
                                emailaddr.Address            = Obj.VendorEmail;
                                company.CompanyEmailAddr     = emailaddr;
                                websiteAddr.URI              = Obj.Website;
                                company.CompanyURL           = websiteAddr;
                                telephoneAddr.FreeFormNumber = Obj.Phone1;
                                company.PrimaryPhone         = telephoneAddr;
                                company.LegalAddr            = address;
                                company.LegalName            = Obj.CompanyNameLegal;
                                company.CompanyName          = Obj.CompanyNameLegal;
                                CompanyInfo update          = commonServiceQBO.Update(company) as CompanyInfo;
                                var         resultQuickBook = _IVendorManagement.SaveQuickBookId(company.Id, Obj.VendorId);

                                if (Obj.VendorAccountDetailsModel != null)
                                {
                                    account.Active = true;
                                    if (Obj.VendorAccountDetailsModel.PaymentMode == 1)
                                    {
                                        var str = Obj.VendorAccountDetailsModel.CardNumber.Substring(Obj.VendorAccountDetailsModel.CardNumber.Length - 4);
                                        account.AccountAlias       = "CreditCard_" + str;
                                        account.Description        = "Credit Card";
                                        account.FullyQualifiedName = "CreditCard_" + str;
                                        account.Name        = "CreditCard_" + str;
                                        account.AccountType = AccountTypeEnum.CreditCard;
                                        account.BankNum     = Obj.VendorAccountDetailsModel.CardNumber;
                                    }
                                    else
                                    {
                                        var str = Obj.VendorAccountDetailsModel.AccountNumber.Substring(Obj.VendorAccountDetailsModel.AccountNumber.Length - 4);
                                        account.AccountAlias       = Obj.VendorAccountDetailsModel.BankName + str;
                                        account.Description        = "Bank";
                                        account.FullyQualifiedName = Obj.VendorAccountDetailsModel.BankName + str;
                                        account.Name        = Obj.VendorAccountDetailsModel.BankName + str;
                                        account.AccountType = AccountTypeEnum.Bank;

                                        account.AcctNum = Obj.VendorAccountDetailsModel.AccountNumber;
                                        account.BankNum = Obj.VendorAccountDetailsModel.AccountNumber;
                                    }

                                    account.Classification       = AccountClassificationEnum.Liability;
                                    account.SubAccount           = false;
                                    account.AccountTypeSpecified = true;
                                    account.sparse = false;
                                    Account accountSaved = commonServiceQBO.Add(account) as Account;
                                    Obj.VendorAccountDetailsModel.QuickbookAcountId = Convert.ToInt64(accountSaved.Id);
                                }

                                //This one added on 21 Feb
                                var result = _IVendorManagement.ProcessVendorSetup(Obj);
                                if (result.Result == Result.Completed)
                                {
                                    ViewBag.Message           = CommonMessage.SaveSuccessMessage();
                                    ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                                    return(View("~/Areas/AdminSection/Views/AdminCompany/CompanyListAdmin.cshtml"));
                                }
                                else
                                {
                                    ViewBag.Message           = CommonMessage.VendorFailure();
                                    ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                                    return(View("~/Areas/AdminSection/Views/AdminCompany/CompanyListAdmin.cshtml"));
                                }
                                //ViewBag.Message = CommonMessage.VendorSave();
                                //ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Message           = ex.Message;
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                    }
                    //}

                    if (Obj.CompanyType == 3)
                    {
                        var result = _IVendorManagement.ProcessVendorSetup(Obj);
                        if (result.Result == Result.Completed)
                        {
                            ViewBag.Message           = CommonMessage.SaveSuccessMessage();
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                            return(View("~/Areas/AdminSection/Views/AdminCompany/CompanyListAdmin.cshtml"));
                        }
                        else
                        {
                            ViewBag.Message           = CommonMessage.VendorFailure();
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                            return(View("~/Areas/AdminSection/Views/AdminCompany/CompanyListAdmin.cshtml"));
                        }
                    }
                    else
                    {
                        ViewBag.Message           = CommonMessage.CompanyAlreadySaved();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message; ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
            }
            return(View("~/Areas/AdminSection/Views/AdminCompany/CompanyListAdmin.cshtml"));
        }
Ejemplo n.º 5
0
        public ActionResult AddAccountDetailsAdmin(VendorSetupManagementModel Obj)
        {
            eTracLoginModel objLoginSession = new eTracLoginModel();

            objLoginSession = (eTracLoginModel)Session["eTrac"];
            var accountSaved = new Account();

            try
            {
                Obj.UserId = objLoginSession.UserId;
                if (Obj.VendorId > 0)
                {
                    if (Obj.VendorAccountDetailsModel.AccountDocumentsFile != null)
                    {
                        string FileName = objLoginSession.UserId + "_" + DateTime.Now.Ticks.ToString() + "_" + Convert.ToString(Obj.VendorAccountDetailsModel.AccountDocumentsFile.FileName);
                        CommonHelper.StaticUploadImage(Obj.VendorAccountDetailsModel.AccountDocumentsFile, Server.MapPath(ConfigurationManager.AppSettings["BankAccountDocsDocument"]), FileName);
                        Obj.VendorAccountDetailsModel.AccountDocuments = FileName;
                    }
                    //Obj.VendorId = Obj.CompanyId;
                    //if (Session["realmId"] != null)
                    //{
                    string realmId = CallbackController.RealMId.ToString(); //Session["realmId"].ToString();
                    try
                    {
                        string AccessToken = CallbackController.AccessToken.ToString();// Session["access_token"].ToString();
                        var    principal   = User as ClaimsPrincipal;
                        var    cmp_Data    = new CompanyInfo();
                        OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(AccessToken);

                        // Create a ServiceContext with Auth tokens and realmId
                        ServiceContext serviceContext = new ServiceContext(realmId, IntuitServicesType.QBO, oauthValidator);
                        serviceContext.IppConfiguration.MinorVersion.Qbo = "23";
                        DataService commonServiceQBO = new DataService(serviceContext);
                        // Create a QuickBooks QueryService using ServiceContext
                        QueryService <CompanyInfo> querySvc = new QueryService <CompanyInfo>(serviceContext);
                        CompanyInfo company = querySvc.ExecuteIdsQuery("SELECT * FROM CompanyInfo").FirstOrDefault();

                        QueryService <Account> querySvcAccount = new QueryService <Account>(serviceContext);
                        List <Account>         accountData     = querySvcAccount.ExecuteIdsQuery("SELECT * FROM Account MaxResults 1000").ToList();

                        var address       = new PhysicalAddress();
                        var emailaddr     = new EmailAddress();
                        var websiteAddr   = new WebSiteAddress();
                        var telephoneAddr = new TelephoneNumber();

                        var account = new Account();

                        var getCompanyInfo = _IVendorManagement.GetCompanyInfo(Convert.ToInt64(company.Id));
                        if (getCompanyInfo > 0 && getCompanyInfo == Convert.ToInt64(company.Id))
                        {
                            ViewBag.Message           = CommonMessage.CompanyAlreadySaved();
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;

                            if (Obj.VendorAccountDetailsModel != null)
                            {
                                account.Active = true;
                                if (Obj.VendorAccountDetailsModel.PaymentMode == 1)
                                {
                                    var str = Obj.VendorAccountDetailsModel.CardNumber.Substring(Obj.VendorAccountDetailsModel.CardNumber.Length - 4);
                                    account.AccountAlias       = "CreditCard_" + str;
                                    account.Description        = "Credit Card";
                                    account.FullyQualifiedName = "CreditCard_" + str;
                                    account.Name        = "CreditCard_" + str;
                                    account.AccountType = AccountTypeEnum.CreditCard;
                                    account.BankNum     = Obj.VendorAccountDetailsModel.CardNumber;
                                }
                                else
                                {
                                    var str = Obj.VendorAccountDetailsModel.AccountNumber.Substring(Obj.VendorAccountDetailsModel.AccountNumber.Length - 4);
                                    account.AccountAlias       = Obj.VendorAccountDetailsModel.BankName + str;
                                    account.Description        = "Bank";
                                    account.FullyQualifiedName = Obj.VendorAccountDetailsModel.BankName + str;
                                    account.Name        = Obj.VendorAccountDetailsModel.BankName + str;
                                    account.AccountType = AccountTypeEnum.Bank;
                                    //account.SubAccount = "Saving";
                                    account.AcctNum = Obj.VendorAccountDetailsModel.AccountNumber;
                                    account.BankNum = Obj.VendorAccountDetailsModel.AccountNumber;
                                }

                                //account.Classification = AccountClassificationEnum.Liability;
                                account.SubAccount           = false;
                                account.AccountTypeSpecified = true;
                                account.sparse                      = false;
                                account.CurrentBalance              = Obj.VendorAccountDetailsModel.BalanceAmount;
                                account.CurrentBalanceSpecified     = true;
                                account.OpeningBalance              = Obj.VendorAccountDetailsModel.BalanceAmount;
                                account.OpeningBalanceSpecified     = true;
                                account.OpeningBalanceDate          = DateTime.UtcNow;
                                account.OpeningBalanceDateSpecified = true;

                                accountSaved = commonServiceQBO.Add(account) as Account;
                                Obj.VendorAccountDetailsModel.QuickbookAcountId = Convert.ToInt64(accountSaved.Id);
                            }

                            ViewBag.Message           = CommonMessage.VendorSave();
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                        }
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Message           = ex.Message;
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                    }
                    //}
                    ViewBag.AccountSection = true;
                    var result = _IVendorManagement.SaveVendorAccount(Obj);
                    if (result.Result == Result.Completed)
                    {
                        ViewBag.Message           = CommonMessage.SaveSuccessMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                        return(View("~/Areas/AdminSection/Views/AdminCompany/CompanyListAdmin.cshtml"));
                    }
                    else
                    {
                        ViewBag.Message           = CommonMessage.FailureMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                        return(View("~/Areas/AdminSection/Views/AdminCompany/AddAccount.cshtml"));
                    }
                }
                else
                {
                    return(View("~/Areas/AdminSection/Views/AdminCompany/AddAccount.cshtml"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message; ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
            }
            return(View("~/Areas/AdminSection/Views/AdminCompany/CompanyListAdmin.cshtml"));
        }