示例#1
0
        public ActionResult QuotationForm(int formNo)
        {
            ViewBag.formCount = Request.Form["formNo"];

            //Common Method to be called for Purchase Quotation Form
            SubmitPurchaseQuotationViewModel pqvm = PurchaseQuotationCommon();

            return(PartialView(pqvm));
        }
示例#2
0
        public ViewResult AddPurchaseQuotation()
        {
            ViewBag.Title = Constant.ADD_PURCHASE_QUOTATION;

            //Common Method to be called for Purchase Quotation Form
            SubmitPurchaseQuotationViewModel pqvm = PurchaseQuotationCommon();

            return(View(pqvm));
        }
示例#3
0
        public PartialViewResult EditQuotation(int id)
        {
            //Common Method to be called for Purchase Quotation Form
            SubmitPurchaseQuotationViewModel spqvm = PurchaseQuotationCommon();

            spqvm.quotationDetails = _repPurchaseQuotation.GetQuotationDetails(id);

            return(PartialView(spqvm));
        }
示例#4
0
        public ActionResult NewField(string field)
        {
            ViewBag.formCount = Request.Form["formNo"];

            var counter = Request.Form["counter"];

            //Common Method to be called for Purchase Quotation Form
            SubmitPurchaseQuotationViewModel pqvm = PurchaseQuotationCommon();

            if (field.Equals("existing"))
            {
                return(PartialView("ExistingField", pqvm));
            }
            else
            {
                return(PartialView(pqvm));
            }
        }
示例#5
0
        public ActionResult EditQuotation(int id, FormCollection fc)
        {
            var updateStatus = 0;
            //Common Method to be called for Purchase Quotation Form
            SubmitPurchaseQuotationViewModel spqvm = PurchaseQuotationCommon();

            try
            {
                spqvm.AssetListId  = fc["formValue[AssetList]"];
                spqvm.Price        = fc["formValue[Price]"];
                spqvm.VAT          = fc["formValue[VAT]"];
                spqvm.Quantity     = fc["formValue[Quantity]"];
                spqvm.PurchaseType = fc["formValue[PurchaseType]"];
                spqvm.QuotedDate   = fc["formValue[QuotedDate]"];

                var Username              = SessionHelper.Username;
                var CreatedDate           = DateTime.Now;
                var UserId                = SessionHelper.UserId;
                var currentAnnualBudgetId = new BaseController(_repAnnualBudget).budgetList;

                if (ModelState.IsValid)
                {
                    _repPurchaseQuotation.UpdateQuotationDetails(spqvm, id);
                    _repPurchaseQuotation.UpdateQuotationEntryLog(spqvm, id, UserId, Username, CreatedDate, currentAnnualBudgetId);
                    updateStatus = 1;

                    return(Content(updateStatus.ToString()));
                }
            }
            catch (IOException e)
            {
                if (e.Source != null)
                {
                    Console.WriteLine("IOException source: {0}", e.Source);
                    throw;
                }
            }

            spqvm.quotationDetails = _repPurchaseQuotation.GetQuotationDetails(id);

            return(View(spqvm));
        }
示例#6
0
        private SubmitPurchaseQuotationViewModel PurchaseQuotationCommon()
        {
            var pqvm = new SubmitPurchaseQuotationViewModel();

            //List Item for Purchase Type
            List <SelectListItem> objPurchaseType = new List <SelectListItem>();

            objPurchaseType.Add(new SelectListItem {
                Text = "--Select Purchase Type--"
            });
            objPurchaseType.Add(new SelectListItem {
                Text = "Brand New", Value = "Brand New"
            });
            objPurchaseType.Add(new SelectListItem {
                Text = "Second Hand", Value = "Second Hand"
            });
            pqvm.compPurchaseType = objPurchaseType;

            pqvm.assetLst = _repAsset.GetAssetInfo().ToList();

            //List Item for Asset List
            List <SelectListItem> objAssetList = new List <SelectListItem>();
            bool assetTypeSelected             = false;

            objAssetList.Add(new SelectListItem {
                Text = "-- Select Asset--"
            });
            foreach (var item in pqvm.assetLst)
            {
                objAssetList.Add(new SelectListItem
                {
                    Text     = String.Concat(item.AssetName, " (", item.AssetCategoryName, ")"),
                    Value    = item.Id.ToString(),
                    Selected = assetTypeSelected
                });
            }
            pqvm.AssetList = objAssetList;

            return(pqvm);
        }
        /// <summary>
        /// Updates Purchase Quotation Entry Log
        /// </summary>
        /// <param name="lstPurchaseQuotation">SubmitPurchaseQuotationViewModel object</param>
        /// <param name="id">Purchase Quotation Entry Log ID</param>
        /// <param name="userid">User ID</param>
        /// <param name="username">Username</param>
        /// <param name="createddate">Created Date</param>
        /// <param name="budgetId">Budget ID</param>
        public void UpdateQuotationEntryLog(SubmitPurchaseQuotationViewModel purchaseQuotation, int id, long userId, string username, DateTime createddate, long budgetId)
        {
            var date        = DateTime.ParseExact(purchaseQuotation.QuotedDate.ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");
            var QueryString = String.Format(
                @"  INSERT INTO {0} (AssetId, AnnualBudgetId, UserId, AssetPrice, VAT, Quantity, QuotedDate, IsApproved, PurchaseType, ActionType, Username, CreatedDate)
                    VALUES ({1}, {2}, {3}, {4}, {5}, {6}, '{7}', {8}, '{9}', '{10}', '{11}', '{12}')",
                TableConstant.TBL_PURCHASE_QUOTATION_ENTRY_LOG,
                purchaseQuotation.AssetListId,
                budgetId,
                userId,
                purchaseQuotation.Price,
                purchaseQuotation.VAT,
                purchaseQuotation.Quantity,
                date,
                1,
                purchaseQuotation.PurchaseType,
                "Update",
                username,
                createddate);

            ado.ExecNonQuery(QueryString);
        }
        /// <summary>
        /// Updates Purchase Quotation Details
        /// </summary>
        /// <param name="lstPurchaseQuotation">SubmitPurchaseQuotationViewModel object</param>
        /// <param name="id">Purchase Quotation ID</param>
        public void UpdateQuotationDetails(SubmitPurchaseQuotationViewModel purchaseQuotation, int id)
        {
            var date = DateTime.ParseExact(purchaseQuotation.QuotedDate.ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");

            ado.ExecNonQuery(
                String.Format(
                    @"  UPDATE {0} 
                    SET AssetId = {1}, 
                        AssetPrice = {2}, 
                        VAT = {3}, 
                        Quantity = {4}, 
                        QuotedDate = '{5}', 
                        PurchaseType = '{6}' 
                    WHERE Id = {7}",
                    TableConstant.TBL_PURCHASE_QUOTATION,
                    purchaseQuotation.AssetListId,
                    purchaseQuotation.Price,
                    purchaseQuotation.VAT,
                    purchaseQuotation.Quantity,
                    date,
                    purchaseQuotation.PurchaseType,
                    id)
                );
        }
示例#9
0
        public ActionResult AddPurchaseQuotation(FormCollection fc)
        {
            var currentAnnualBudgetId = new BaseController(_repAnnualBudget).budgetList;

            ViewBag.Title = Constant.ADD_PURCHASE_QUOTATION;

            //Common Method to be called for Purchase Quotation Form
            SubmitPurchaseQuotationViewModel pqvm = PurchaseQuotationCommon();

            try
            {
                pqvm.AssetListId  = fc["AssetList"];
                pqvm.Price        = fc["Price"];
                pqvm.VAT          = fc["VAT"];
                pqvm.Quantity     = fc["Quantity"];
                pqvm.PurchaseType = fc["PurchaseType"];
                pqvm.QuotedDate   = fc["QuotedDate"];

                var lstAssetListId  = pqvm.AssetListId.Split(',').ToList();
                var lstPrice        = pqvm.Price.Split(',').ToList();
                var lstVAT          = pqvm.VAT.Split(',').ToList();
                var lstQuantity     = pqvm.Quantity.Split(',').ToList();
                var lstPurchaseType = pqvm.PurchaseType.Split(',').ToList();
                var lstQuotedDate   = pqvm.QuotedDate.Split(',').ToList();

                var lstPurchaseQuotation = new List <PurchaseQuotation>();
                for (int i = 0; i < lstAssetListId.Count; i++)
                {
                    var pq = new PurchaseQuotation();
                    pq.AssetId        = long.Parse(lstAssetListId[i]);
                    pq.AnnualBudgetId = currentAnnualBudgetId;
                    pq.UserId         = SessionHelper.UserId;
                    pq.AssetPrice     = decimal.Parse(lstPrice[i]);
                    pq.VAT            = decimal.Parse(lstVAT[i]);
                    pq.Quantity       = int.Parse(lstQuantity[i]);
                    pq.PurchaseType   = lstPurchaseType[i];
                    pq.QuotedDate     = DateTime.Parse(lstQuotedDate[i]);
                    lstPurchaseQuotation.Add(pq);
                }

                var lstPqEnryLog = new List <PurchaseQuotationEntryLog>();
                for (int i = 0; i < lstAssetListId.Count; i++)
                {
                    var pqel = new PurchaseQuotationEntryLog();
                    pqel.AssetId        = long.Parse(lstAssetListId[i]);
                    pqel.AnnualBudgetId = currentAnnualBudgetId;
                    pqel.UserId         = SessionHelper.UserId;
                    pqel.AssetPrice     = decimal.Parse(lstPrice[i]);
                    pqel.VAT            = decimal.Parse(lstVAT[i]);
                    pqel.Quantity       = int.Parse(lstQuantity[i]);
                    pqel.PurchaseType   = lstPurchaseType[i];
                    pqel.QuotedDate     = DateTime.Parse(lstQuotedDate[i]);
                    pqel.IsApproved     = 1;
                    pqel.ActionType     = "Create";
                    pqel.Username       = SessionHelper.Username;
                    pqel.CreatedDate    = DateTime.Now;
                    lstPqEnryLog.Add(pqel);
                }

                if (ModelState.IsValid)
                {
                    _repPurchaseQuotation.AddPurchaseQuotationInfo(lstPurchaseQuotation, lstPqEnryLog);

                    FlashMessage.Confirmation("Purchase quotation has been added successfully.");
                    return(RedirectToAction("QuotationDetails"));
                }
            }
            catch (IOException e)
            {
                // Extract some information from this exception, and then
                // throw it to the parent method.
                if (e.Source != null)
                {
                    Console.WriteLine("IOException source: {0}", e.Source);
                    throw;
                }
            }

            return(View(pqvm));
        }