public ActionResult QuotationDetail(int QuotationID = 0, string QuotationCode = "")
        {
            int CompID    = 0;
            int ProductID = 0;

            RememberURL();
            if (!CheckIsLogin())
            {
                return(Redirect(res.Pageviews.PvMemberSignIn));
            }
            else
            {
                if (CheckIsAdmin(9))
                {
                    GetStatusUser();
                    if (QuotationID > 0)
                    {
                        Ouikum.Quotation.QuotationService svQuotation = new Ouikum.Quotation.QuotationService();
                        var Quotation = svQuotation.SelectData <view_Quotation>("*", "IsDelete = 0 AND QuotationID =" + QuotationID).First();
                        ViewBag.Quotation = Quotation;
                        if (Quotation.QuotationStatus == "Q")
                        {
                            CompID = Convert.ToInt32(Quotation.FromCompID);
                        }
                        else
                        {
                            CompID = Convert.ToInt32(Quotation.ToCompID);
                        }
                        if (Quotation.ProductID != 0)
                        {
                            ProductID = Convert.ToInt32(Quotation.ProductID);
                        }

                        #region ProductName
                        var svProduct   = new ProductService();
                        var ProductName = svProduct.SelectData <view_SearchProduct>("ProductID,ProductName", "ProductID = " + ProductID, "ProductName", 1, 0, false).First().ProductName;
                        if (ProductName.Length >= 40)
                        {
                            ViewBag.ProductName = ProductName.Substring(0, 40) + "...";
                        }
                        else
                        {
                            ViewBag.ProductName = ProductName;
                        }
                        #endregion

                        #region Company
                        var svCompany = new CompanyService();
                        if (CompID != 0)
                        {
                            var ToComp = svCompany.SelectData <view_Company>("CompID,CompName,CompImgPath,BizTypeName,ProvinceName,ContactEmail", "CompID = " + CompID, null, 1, 0, false).First();
                            ViewBag.ReqEmail = ToComp.ContactEmail;
                            ViewBag.ReqPhone = ToComp.ContactPhone;
                        }
                        else
                        {
                            ViewBag.ReqEmail = null;
                            ViewBag.ReqPhone = null;
                        }

                        #endregion

                        #region File Attach
                        var svQuotationAttach = new QuotationAttachService();
                        var AttachFile        = svQuotationAttach.SelectData <b2bQuotationAttach>("*", "QuotationID = " + QuotationID, null, 0, 0, false);
                        if (AttachFile.Count() > 0)
                        {
                            ViewBag.AttachFile   = AttachFile.First();
                            ViewBag.AttachRemark = AttachFile.First().Remark;
                        }
                        #endregion

                        return(View());
                    }
                    else
                    {
                        return(Redirect("~/Report/List"));
                    }
                }
                else
                {
                    return(Redirect(res.Pageviews.PvAccessDenied));
                }
            }
        }
        public ActionResult Reply(int?ID)
        {
            GetStatusUser();

            int CompID      = 0;
            int ProductID   = 0;
            int QuotationID = 0;

            /*------Quotation------*/
            #region QuotationReply
            var svQuotation = new QuotationService();
            var Quotation   = svQuotation.SelectData <b2bQuotation>("*", "QuotationID = " + ID, "CreatedDate", 1, 1).First();
            if (Quotation.FromCompID != 0)
            {
                CompID = Convert.ToInt32(Quotation.FromCompID);
            }
            if (Quotation.ProductID != 0)
            {
                ProductID = Convert.ToInt32(Quotation.ProductID);
            }
            QuotationID       = DataManager.ConvertToInteger(Quotation.QuotationID);
            ViewBag.QuoDetail = Quotation;
            ViewBag.QouStatus = "Quotation";
            #endregion

            #region File Attach
            var svQuotationAttach = new QuotationAttachService();
            var AttachFile        = svQuotationAttach.SelectData <b2bQuotationAttach>("*", "QuotationID = " + QuotationID, null, 0, 0, false);
            if (AttachFile.Count() > 0)
            {
                ViewBag.AttachFile   = AttachFile.First();
                ViewBag.AttachRemark = AttachFile.First().Remark;
            }
            #endregion

            #region ProductName
            svProduct = new ProductService();
            var ProductName = svProduct.SelectData <b2bProduct>("ProductID,ProductName", "ProductID = " + ProductID, "ProductName", 1, 0, false).First().ProductName;
            if (ProductName.Length >= 35)
            {
                ViewBag.ProNameShort = ProductName.Substring(0, 35) + "...";
            }
            else
            {
                ViewBag.ProNameShort = ProductName;
            }
            ViewBag.ProductName = ProductName;
            #endregion

            #region Company
            /*----FromCompany----*/
            if (CompID != 0)
            {
                svCompany = new CompanyService();
                var Company = svCompany.SelectData <view_Company>("CompID,CompName,CompLevel,CompImgPath,BizTypeName,ProvinceName,CompPhone,ContactEmail", "CompID = " + CompID, null, 1, 0, false).First();
                ViewBag.Company   = Company;
                ViewBag.CompName  = Company.CompName;
                ViewBag.CompPhone = Company.CompPhone;
                ViewBag.CompEmail = Company.ContactEmail;
                if (!string.IsNullOrEmpty(Company.ContactFirstName))
                {
                    ViewBag.ContactName = Company.ContactFirstName + " " + Company.ContactLastName;
                }
                else
                {
                    ViewBag.ContactName = "-";
                }
            }
            else
            {
                ViewBag.CompName = Quotation.SaleCompany;
                if (!string.IsNullOrEmpty(Quotation.SalePhone))
                {
                    ViewBag.CompPhone = Quotation.SalePhone;
                }
                else
                {
                    ViewBag.CompPhone = "-";
                }
                ViewBag.CompEmail   = Quotation.SaleEmail;
                ViewBag.ContactName = Quotation.SaleName;
            }
            /*ToCompany*/
            if (Quotation.ToCompID == 0)
            {
                svCompany = new CompanyService();
                int Quo_ID = Convert.ToInt16(ID) - 1;
                var ToComp = svQuotation.SelectData <b2bQuotation>("QuotationID,CompanyName", "QuotationID = " + ID, "CreatedDate", 1, 1).First();
                ViewBag.ToCompName = ToComp.CompanyName;
            }
            #endregion

            return(View());
        }