Esempio n. 1
0
        public ActionResult Index()
        {
            var objPOTypeModel = new POTypeDataModel();

            try
            {
                // ViewBag.VendorList = _IPOTypeDetails.GetCompany_VendorList();
                ViewBag.PONumber = _IPOTypeDetails.PONumberData();
                ViewBag.POType   = _IPOTypeDetails.POTypeList();
            }
            catch (Exception ex)
            {
            }
            return(View(objPOTypeModel));
        }
Esempio n. 2
0
        /// <summary>
        /// Created By: Ashwajit bansod
        /// Created Date : 03-Oct-2018
        /// Created For: to edit PO as per POId
        /// </summary>
        /// <param name="POId"></param>
        /// <param name="LocationId"></param>
        /// <returns></returns>
        public ActionResult EditPOByPOId(string POId, long LocationId)
        {
            eTracLoginModel ObjLoginModel  = null;
            long            Id             = 0;
            var             objPOTypeModel = new POTypeDataModel();

            try
            {
                if (Session["eTrac"] != null)
                {
                    ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
                }
                if (!string.IsNullOrEmpty(POId))
                {
                    ViewBag.UpdateMode = true;
                    POId = Cryptography.GetDecryptedData(POId, true);
                    long.TryParse(POId, out Id);
                }
                if (Id > 0)
                {
                    var DataPO = _IPOTypeDetails.GetPODetailsById(Id);
                    ViewBag.Vendor       = DataPO.Vendor;
                    ViewBag.POTypeDate   = DataPO.POType;
                    ViewBag.PONumberData = DataPO.PONumber;
                    ViewBag.POType       = _IPOTypeDetails.POTypeList();
                    ViewBag.VendorList   = _IPOTypeDetails.GetCompany_VendorList(LocationId, false);
                    return(View("Index", DataPO));
                }
                else
                {
                    ViewBag.AlertMessageClass = new AlertMessageClass().Danger;
                    ViewBag.Message           = Result.DoesNotExist;
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message           = ex.Message;
                ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
            }
            return(View("Index"));
        }
Esempio n. 3
0
        /// <summary>
        /// Created By : Ashwajit Bansod
        /// Created Date : 17-April-2019
        /// Created For : To get PO Details ad facility list by PO id
        /// </summary>
        /// <param name="POId"></param>
        /// <param name="_search"></param>
        /// <param name="UserId"></param>
        /// <param name="rows"></param>
        /// <param name="page"></param>
        /// <param name="TotalRecords"></param>
        /// <param name="sord"></param>
        /// <param name="txtSearch"></param>
        /// <param name="sidx"></param>
        /// <param name="UserType"></param>
        /// <returns></returns>
        public JsonResult GetAllPODetailByPOId(long POId, string _search, long?UserId, int?rows = 20, int?page = 1, int?TotalRecords = 10, string sord = null, string txtSearch = null, string sidx = null, string UserType = null)
        {
            eTracLoginModel ObjLoginModel = null;
            var             getResult     = new POTypeDataModel();
            var             resultPayment = new BillPayment();

            if (Session["eTrac"] != null)
            {
                ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
            }
            try
            {
                var obj = new PaymentModel();
                obj.BillNo = POId;
                var getPOByBillNo = _IPaymentManager.GetPODetails(null, obj);
                getResult = _IPOTypeDetails.GetPODetailsById(getPOByBillNo.POId);
                if (getResult != null)
                {
                    getResult.IssueDateDisplay    = getResult.IssueDate.ToString();
                    getResult.DeliveryDateDisplay = getResult.DeliveryDate.ToString();
                    JQGridResults    result     = new JQGridResults();
                    List <JQGridRow> rowss      = new List <JQGridRow>();
                    decimal?         grandTotal = 0;
                    sord      = string.IsNullOrEmpty(sord) ? "desc" : sord;
                    sidx      = string.IsNullOrEmpty(sidx) ? "UserEmail" : sidx;
                    txtSearch = string.IsNullOrEmpty(txtSearch) ? "" : txtSearch; //UserType = Convert.ToInt64(Helper.UserType.ITAdministrator);
                    getResult.NewPOTypeDetails = _IPOTypeDetails.GetAllPOFacilityByPOIdList(ObjLoginModel.UserId, getPOByBillNo.POId, rows, TotalRecords, sidx, sord);

                    foreach (var poFacilityList in getResult.NewPOTypeDetails.rows)
                    {
                        grandTotal += poFacilityList.UnitPrice * poFacilityList.Quantity;
                        poFacilityList.TotalPrice = grandTotal;
                        //poFacilityList.TotalPrice = poFacilityList.UnitPrice * poFacilityList.Quantity;
                        poFacilityList.Total = poFacilityList.UnitPrice * poFacilityList.Quantity;
                        JQGridRow row = new JQGridRow();
                        row.id      = Cryptography.GetEncryptedData(Convert.ToString(poFacilityList.COM_FacilityId), true);
                        row.cell    = new string[10];
                        row.cell[0] = poFacilityList.COM_FacilityId.ToString();
                        row.cell[1] = poFacilityList.CostCode.ToString();
                        row.cell[2] = poFacilityList.FacilityType.ToString();
                        row.cell[3] = poFacilityList.COM_Facility_Desc.ToString();
                        row.cell[4] = poFacilityList.UnitPrice.ToString();
                        row.cell[5] = poFacilityList.Tax.ToString();
                        row.cell[6] = poFacilityList.Quantity.ToString();
                        row.cell[7] = poFacilityList.Total.ToString();
                        row.cell[8] = poFacilityList.TotalPrice.ToString();
                        row.cell[9] = poFacilityList.CostCodeName.ToString();
                        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(getResult, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public JsonResult SavePOTypeDetails(POTypeDataModel objPOTypeDataModel, List <GridDataPO> obj, List <QuestionAnswerModel> objQuestioAsnwerList)//, HttpPostedFileBase file)//(POTypeDataModel objPOTypeDataModel)
        {
            eTracLoginModel        ObjLoginModel = null;
            HttpFileCollectionBase files         = Request.Files;
            bool savedStatus = false;
            var  resultSave  = new PurchaseOrder();

            if (Session["eTrac"] != null)
            {
                ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
            }
            try
            {
                objPOTypeDataModel.UserId = ObjLoginModel.UserId;
                if (objPOTypeDataModel != null && objPOTypeDataModel.POId == 0)
                {
                    if (objPOTypeDataModel.POD_EmergencyPODocumentFile != null)
                    {
                        string AttachmentName = ObjLoginModel.UserId + "_" + DateTime.Now.Ticks.ToString() + "_" + Convert.ToString(objPOTypeDataModel.POD_EmergencyPODocumentFile.FileName);
                        CommonHelper.StaticUploadImage(objPOTypeDataModel.POD_EmergencyPODocumentFile, Server.MapPath(ConfigurationManager.AppSettings["EmergencyDocuments"]), AttachmentName);
                        objPOTypeDataModel.POD_EmergencyPODocument = AttachmentName;
                    }
                    bool IsManager = true;


                    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);
                            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();

                            QueryService <Vendor> querySvc   = new QueryService <Vendor>(serviceContext);
                            List <Vendor>         vendorList = querySvc.ExecuteIdsQuery("SELECT * FROM Vendor MaxResults 1000").ToList();

                            //var Vendor = _IVendorManagement.GetVendorId(objListData.CompanyName);
                            var           VendorDetails   = _IVendorManagement.GetCompanyQuickBookId(Convert.ToInt64(objPOTypeDataModel.Vendor));
                            ReferenceType parentReference = new ReferenceType();
                            var           purchaseOrder   = new PurchaseOrder();
                            //var lineDetailType = new LineDetailTypeEnum();
                            if (VendorDetails > 0)
                            {
                                var vendorData = vendorList.Where(x => x.Id == VendorDetails.ToString()).FirstOrDefault();
                                //Vendor Reference
                                purchaseOrder.VendorRef = new ReferenceType()
                                {
                                    name  = vendorData.DisplayName,
                                    Value = vendorData.Id
                                };
                            }
                            var LocationName = _IBillDataManager.GetLocationDataByLocId(Convert.ToInt64(objPOTypeDataModel.Location));
                            purchaseOrder.DepartmentRef = new ReferenceType()
                            {
                                name  = LocationName.LocationName,
                                Value = LocationName.QBK_Id.ToString()
                            };
                            purchaseOrder.POStatus = PurchaseOrderStatusEnum.Open;
                            //Line line = new Line();
                            List <Line> lineList   = new List <Line>();
                            var         accountRef = new AccountBasedExpenseLineDetail();
                            purchaseOrder.APAccountRef = new ReferenceType()
                            {
                                name  = "Accounts Payable (A/P)",
                                Value = "33"
                            };

                            foreach (var item in obj)
                            {
                                var line = new Line();
                                line.DetailType = LineDetailTypeEnum.AccountBasedExpenseLineDetail;
                                long CostCodeId   = Convert.ToInt64(item.CostCode);
                                var  costCodeName = _IBillDataManager.GetCostCodeData(CostCodeId);
                                var  dataget      = listAccount.Where(x => x.Name == costCodeName.Description).FirstOrDefault();
                                if (dataget != null)
                                {
                                    accountRef.AccountRef = new ReferenceType()
                                    {
                                        name  = dataget.Name,
                                        Value = dataget.Id
                                    };
                                }
                                line.AnyIntuitObject     = accountRef;
                                line.DetailTypeSpecified = true;
                                line.Amount          = Convert.ToDecimal(item.Quantity) * Convert.ToDecimal(item.UnitPrice);
                                line.AmountSpecified = true;
                                line.Description     = item.COM_Facility_Desc;
                                lineList.Add(line);
                            }
                            purchaseOrder.Line = lineList.ToArray();
                            resultSave         = commonServiceQBO.Add(purchaseOrder) as PurchaseOrder;
                        }
                        catch (Exception ex)
                        {
                            ViewBag.Message           = ex.Message;
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                        }
                    }
                    if (resultSave.Id != null)
                    {
                        objPOTypeDataModel.QBK_Id = Convert.ToInt64(resultSave.Id);
                    }
                    else
                    {
                        objPOTypeDataModel.QBK_Id = 0;
                    }
                    savedStatus = _IPOTypeDetails.SavePODetails(objPOTypeDataModel, obj, objQuestioAsnwerList, IsManager);
                    if (savedStatus == true)
                    {
                        ViewBag.Message           = CommonMessage.SaveSuccessMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                        return(Json(savedStatus, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        ViewBag.Message           = CommonMessage.FailureMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;// store the failure message in tempdata to display in view.
                        return(Json(savedStatus, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    bool IsManager = true;
                    savedStatus = _IPOTypeDetails.SavePODetails(objPOTypeDataModel, obj, objQuestioAsnwerList, IsManager);
                    if (savedStatus == true)
                    {
                        ViewBag.Message           = CommonMessage.UpdateSuccessMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                        return(Json(savedStatus, JsonRequestBehavior.AllowGet));
                        //return RedirectToAction("AllPOList", "POTypeData");

                        //return View("AllPOList");
                    }
                    else
                    {
                        ViewBag.Message           = CommonMessage.FailureMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;// store the failure message in tempdata to display in view.
                        //return RedirectToAction("AllPOList", "POTypeData");
                        return(Json(savedStatus, JsonRequestBehavior.AllowGet));
                        //return View("AllPOList");
                    }
                }
                //var objModel = new POTypeDataModel();
                //return View("AllPOList");
                //return Json(savedStatus, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                ViewBag.Message           = ex;
                ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                throw ex;
            }
            finally
            {
                ViewBag.PONumber = _IPOTypeDetails.PONumberData();
                ViewBag.POType   = _IPOTypeDetails.POTypeList();
            }
            //return View("AllPOList");
        }