示例#1
0
        /// <summary>
        /// Created By: Ashwajit Bansod
        /// Created Date : 19-Dec-2018
        /// Created For : To get cos code data by cost code Id
        /// </summary>
        /// <param name="CostCodeId"></param>
        /// <returns></returns>
        public CostCodeModel GetCostCodeData(long CostCodeId)
        {
            var data = new CostCodeModel();

            try
            {
                if (CostCodeId > 0)
                {
                    data = _workorderems.CostCodes.Where(x => x.CCD_CostCode == CostCodeId).Select(a => new CostCodeModel
                    {
                        Description = a.CCD_Description
                    }).FirstOrDefault();
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public string GetCostCodeData(long CostCodeId)", "Exception While Getting data of cost code.", null);
                throw;
            }
            return(data);
        }
示例#2
0
        public CostCodeModel SaveCostCode(CostCodeModel objCostCodeModel)
        {
            var    objCostCodeRepository = new CostCodeRepository();
            var    objCostCode           = new CostCode();
            string action = "";

            if (objCostCodeModel.CostCodeId == 0 && objCostCodeModel.CostCode == null)
            {
                action = "I";
                var saveMasterCostCode = _workorderems.spSetCostCodeMaster(action, objCostCodeModel.QuickBookCostCodeMasterId, objCostCodeModel.CostCode,
                                                                           objCostCodeModel.Description, objCostCodeModel.ModifiedBy,
                                                                           objCostCodeModel.ApprovedBy, objCostCodeModel.IsActive);
                objCostCodeModel.Result = Result.Completed;
            }
            else if (objCostCodeModel.CostCode != null)
            {
                action = "I";
                var saveMasterCostCode = _workorderems.spSetCostCode(action, objCostCodeModel.QuickBookCostCodeId, null, objCostCodeModel.CostCode,
                                                                     objCostCodeModel.Description, null, objCostCodeModel.ModifiedBy,
                                                                     objCostCodeModel.ApprovedBy, objCostCodeModel.IsActive);
                objCostCodeModel.Result = Result.Completed;
            }
            else
            {
                action = "U";
                var saveMasterCostCode = _workorderems.spSetCostCodeMaster(action, null, objCostCodeModel.CostCode,
                                                                           objCostCodeModel.Description, objCostCodeModel.ModifiedBy,
                                                                           objCostCodeModel.ApprovedBy, objCostCodeModel.IsActive);
                objCostCodeModel.Result = Result.UpdatedSuccessfully;
            }
            return(objCostCodeModel);
        }
示例#3
0
        public JsonResult GetListOfSubCostCode(string id, string _search, long?UserId, long?locationId, int?rows = 20, int?page = 1, int?TotalRecords = 10, string sord = null, string txtSearch = null, string sidx = null, string UserType = null)
        {
            eTracLoginModel ObjLoginModel = null;

            ViewBag.AccountSection = true;
            long _CostCodeId = 0;

            if (Session["eTrac"] != null)
            {
                ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
                if (locationId == null)
                {
                    locationId = ObjLoginModel.LocationID;
                }
                UserId = ObjLoginModel.UserId;
            }
            if (!string.IsNullOrEmpty(id))
            {
                id = Cryptography.GetDecryptedData(id, true);
                long.TryParse(id, out _CostCodeId);
            }
            CostCodeModel    objCostCodeModel = new CostCodeModel();
            JQGridResults    result           = new JQGridResults();
            List <JQGridRow> rowss            = new List <JQGridRow>();

            sord      = string.IsNullOrEmpty(sord) ? "desc" : sord;
            sidx      = string.IsNullOrEmpty(sidx) ? "UserEmail" : sidx;
            txtSearch = string.IsNullOrEmpty(txtSearch) ? "" : txtSearch; //UserType = Convert.ToInt64(Helper.UserType.ITAdministrator);
            try
            {
                var costCodeList = _ICostCode.GetListOfSubCostCode(_CostCodeId, UserId, rows, TotalRecords, sidx, sord, locationId, txtSearch, UserType);
                foreach (var costCode in costCodeList.rows)
                {
                    if (costCode.IsDeleted == false)
                    {
                        JQGridRow row = new JQGridRow();
                        row.id      = Cryptography.GetEncryptedData(Convert.ToString(costCode.CCM_CostCode), true);
                        row.cell    = new string[3];
                        row.cell[0] = costCode.CCM_CostCode.ToString();
                        row.cell[1] = costCode.Description;
                        row.cell[2] = costCode.IsActive == "Y"?"Active":"Not Activated";
                        rowss.Add(row);
                    }
                }
                result.rows    = rowss.ToArray();
                result.page    = Convert.ToInt32(page);
                result.total   = (int)Math.Ceiling((decimal)Convert.ToInt32(TotalRecords.Value) / rows.Value);
                result.records = Convert.ToInt32(TotalRecords.Value);
            }
            catch (Exception ex)
            { return(Json(ex.Message, JsonRequestBehavior.AllowGet)); }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        /// <summary>
        /// Created By : Ashwajit Bansod
        /// Created Date : 18 July 2018
        /// Created For : To Save Cost Code
        /// </summary>
        /// <param name="objCostCodeModel"></param>
        /// <returns></returns>
        public ActionResult SaveCostCode(CostCodeModel objCostCodeModel)
        {
            eTracLoginModel      ObjLoginModel = null;
            workorderEMSEntities _workorderems = new workorderEMSEntities();

            ViewBag.AccountSection = true;
            bool isUpdate = false;

            if (Session != null)
            {
                if (Session["eTrac"] != null)
                {
                    ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
                    if (Convert.ToInt64(Session["eTrac_SelectedDasboardLocationID"]) == 0)
                    {
                        (Session["eTrac_SelectedDasboardLocationID"]) = ObjLoginModel.LocationID;
                    }
                }
            }
            try
            {
                if (objCostCodeModel.CostCodeId == 0)  //Save cost code
                {
                    objCostCodeModel.CreatedBy   = ObjLoginModel.UserId;
                    objCostCodeModel.CreatedDate = DateTime.UtcNow;
                    objCostCodeModel.IsDeleted   = false;
                    objCostCodeModel.LocationId  = ObjLoginModel.LocationID;
                    var SubaccountCostCode = new Account();
                    var accountCostCode    = new Account();
                    SubaccountCostCode = null; accountCostCode = null;
                    var    data    = new Account();
                    string realmId = CallbackController.RealMId.ToString();//Session["realmId"].ToString();
                    if (realmId != null)
                    {
                        try
                        {
                            string AccessToken  = CallbackController.AccessToken.ToString();// Session["access_token"].ToString();
                            string refreshToken = CallbackController.RefreshToken;
                            var    principal    = User as ClaimsPrincipal;
                            OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(AccessToken);
                            //OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(principal.FindFirst("refresh_token").Value);
                            //OAuthRequestValidator oauthValidator = new OAuthRequestValidator(refreshToken);

                            // 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
                            Account account = new Account();

                            QueryService <Account> querySvcCompany = new QueryService <Account>(serviceContext);
                            List <Account>         listAccount     = querySvcCompany.ExecuteIdsQuery("SELECT * FROM Account MaxResults 1000")
                                                                     .ToList();
                            ReferenceType parentReference = new ReferenceType();
                            if (objCostCodeModel.CostCode != null)
                            {
                                var getMasterData = _workorderems.CostCodeMasters.Where(x => x.CCM_CostCode == objCostCodeModel.CostCode).FirstOrDefault();
                                QueryService <Account> querySvcAcc = new QueryService <Account>(serviceContext);
                                Account AccountInfo = querySvcAcc.ExecuteIdsQuery("SELECT * FROM Account").FirstOrDefault();
                                data = listAccount.Where(x => x.Name == getMasterData.CCM_Description).FirstOrDefault();

                                account.SubAccount    = true;
                                parentReference.name  = getMasterData.CCM_Description;
                                parentReference.Value = data.Id;
                                //account.AccountSubType = "AccountsPayable";
                                account.AccountSubType = objCostCodeModel.CatagoryValue;
                                //account.AccountType = AccountTypeEnum.Expense;
                                account.Name         = objCostCodeModel.Description;
                                account.Active       = true;
                                account.AccountAlias = objCostCodeModel.Description;
                                account.Description  = objCostCodeModel.Description;
                                //parentReference.Value =
                                account.ParentRef  = parentReference;
                                SubaccountCostCode = commonServiceQBO.Add(account) as Account;
                            }
                            else
                            {
                                account.Active             = true;
                                account.AccountAlias       = objCostCodeModel.Description;
                                account.Description        = objCostCodeModel.Description;
                                account.FullyQualifiedName = objCostCodeModel.Description;
                                account.Name = objCostCodeModel.Description;

                                switch (objCostCodeModel.CategoryList)
                                {
                                case "Accounts Payable":
                                    account.AccountType    = AccountTypeEnum.AccountsPayable;
                                    account.Classification = AccountClassificationEnum.Liability;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Accounts Receivable":
                                    account.AccountType    = AccountTypeEnum.AccountsReceivable;
                                    account.Classification = AccountClassificationEnum.Liability;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Bank":
                                    account.AccountType    = AccountTypeEnum.Bank;
                                    account.Classification = AccountClassificationEnum.Liability;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Cost of Goods Sold":
                                    account.AccountType    = AccountTypeEnum.CostofGoodsSold;
                                    account.Classification = AccountClassificationEnum.Liability;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Credit Card":
                                    account.AccountType    = AccountTypeEnum.CreditCard;
                                    account.Classification = AccountClassificationEnum.Liability;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Equity":
                                    account.AccountType    = AccountTypeEnum.Equity;
                                    account.Classification = AccountClassificationEnum.Equity;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Expense":
                                    account.AccountType    = AccountTypeEnum.Expense;
                                    account.Classification = AccountClassificationEnum.Expense;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Fixed Asset":
                                    account.AccountType    = AccountTypeEnum.FixedAsset;
                                    account.Classification = AccountClassificationEnum.Asset;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Income":
                                    account.AccountType    = AccountTypeEnum.Income;
                                    account.Classification = AccountClassificationEnum.Liability;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Long Term Liability":
                                    account.AccountType    = AccountTypeEnum.LongTermLiability;
                                    account.Classification = AccountClassificationEnum.Liability;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Other Current Asset":
                                    account.AccountType    = AccountTypeEnum.OtherCurrentAsset;
                                    account.Classification = AccountClassificationEnum.Asset;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Other Current Liability":
                                    account.AccountType    = AccountTypeEnum.OtherCurrentLiability;
                                    account.Classification = AccountClassificationEnum.Liability;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Other Expense":
                                    account.AccountType    = AccountTypeEnum.OtherExpense;
                                    account.Classification = AccountClassificationEnum.Expense;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                case "Other Income":
                                    account.AccountType    = AccountTypeEnum.OtherIncome;
                                    account.Classification = AccountClassificationEnum.Revenue;
                                    account.AccountSubType = objCostCodeModel.CatagoryValue;
                                    break;

                                default:
                                    break;
                                }
                                account.SubAccount           = false;
                                account.AccountTypeSpecified = true;
                                account.sparse  = false;
                                accountCostCode = commonServiceQBO.Add(account) as Account;
                            }
                        }
                        catch (Exception ex)
                        {
                            ViewBag.Message = ex.Message; ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                        }
                        //}
                        if (accountCostCode != null)
                        {
                            objCostCodeModel.QuickBookCostCodeMasterId = Convert.ToInt64(accountCostCode.Id);
                        }
                        if (SubaccountCostCode != null)
                        {
                            objCostCodeModel.QuickBookCostCodeId       = Convert.ToInt64(SubaccountCostCode.Id);
                            objCostCodeModel.QuickBookCostCodeMasterId = Convert.ToInt64(data.Id);
                        }
                        var SaveCostCodeData = _ICostCode.SaveCostCode(objCostCodeModel);
                        if (objCostCodeModel.Result == Result.Completed)
                        {
                            ModelState.Clear();
                            ViewBag.Message           = CommonMessage.CostCodeSaved();
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                        }
                    }
                    else  //edit cost code data update
                    {
                        isUpdate = true;
                        objCostCodeModel.ModifiedBy   = ObjLoginModel.UserId;
                        objCostCodeModel.ModifiedDate = DateTime.UtcNow;
                        objCostCodeModel.LocationId   = ObjLoginModel.LocationID;
                        var Data = _ICostCode.SaveCostCode(objCostCodeModel);
                        if (objCostCodeModel.Result == Result.UpdatedSuccessfully)
                        {
                            ModelState.Clear();
                            ViewBag.Message           = CommonMessage.CostCodeSaved();
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message; ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
            }

            finally
            {
                ViewBag.CategoryList = _ICostCode.GetCategoryList();
            }
            return(View("~/Areas/AdminSection/Views/CostCode/CostCodeList.cshtml"));
            //return View("CostCodeList");
        }