// GET api/PatternDetails
        public PatternDetailModel Get(string number)
        {
            PatternDetailModel objModel = new PatternDetailModel();

            try
            {
                PatternBO objPattern = new PatternBO();
                objPattern.IsActiveWS = true;
                objPattern.IsActive   = true;
                objPattern.Number     = number;
                objPattern            = objPattern.SearchObjects().SingleOrDefault();

                if (objPattern != null && objPattern.Creator > 0)
                {
                    objModel.Pattern     = objPattern.ID;
                    objModel.Number      = objPattern.Number;
                    objModel.Remarks     = objPattern.Remarks;
                    objModel.Gender      = objPattern.objGender.Name;
                    objModel.Description = objPattern.Description;

                    if ((objPattern.PatternCompressionImage ?? 0) > 0)
                    {
                        objModel.GarmentSpecChartImagePath = PopulatePatternCompressionImage(objPattern);
                    }
                    else
                    {
                        List <MeasurementLocation> lstMLocations = new List <MeasurementLocation>();

                        SizeChartBO objSChart = new SizeChartBO();
                        objSChart.Pattern = objPattern.ID;
                        List <SizeChartBO> lstSizeCharts = objSChart.SearchObjects().Where(o => o.objMeasurementLocation.IsSend == true && o.Val > 0).ToList();

                        List <MeasurementLocationBO> lstLocations = lstSizeCharts.Select(m => m.objMeasurementLocation).Distinct().ToList();

                        IEnumerable <IGrouping <string, MeasurementLocationBO> > lst = lstLocations.GroupBy(m => m.Name);

                        foreach (IGrouping <string, MeasurementLocationBO> objML in lst)
                        {
                            MeasurementLocation location = new MeasurementLocation();
                            location.Name = objML.Key;

                            List <SizeChartBO> lstMSizes = lstSizeCharts.Where(m => m.MeasurementLocation == objML.ElementAtOrDefault(0).ID).ToList();

                            foreach (SizeChartBO objSize in lstMSizes)
                            {
                                location.ListSizes.Add(new Size {
                                    name = objSize.objSize.SizeName, Value = objSize.Val.ToString()
                                });
                            }

                            lstMLocations.Add(location);
                        }

                        objModel.ListMeasurementLocations = lstMLocations;
                    }

                    //Populate Images
                    PatternTemplateImageBO objOtherImage = new PatternTemplateImageBO();
                    objOtherImage.Pattern = objPattern.ID;
                    List <PatternTemplateImageBO> lstOtherImages = objOtherImage.SearchObjects();

                    List <PatternTemplateImageBO> lstOtherImages1 = lstOtherImages.Where(o => o.ImageOrder == 1).ToList();
                    List <PatternTemplateImageBO> lstOtherImages2 = lstOtherImages.Where(o => o.ImageOrder == 2).ToList();
                    List <PatternTemplateImageBO> lstOtherImages3 = lstOtherImages.Where(o => o.ImageOrder == 3).ToList();

                    objModel.GarmentImagePath1    = TemplateImagePath(lstOtherImages1);
                    objModel.GarmentImagePath2    = TemplateImagePath(lstOtherImages2);
                    objModel.GarmentImagePath3    = TemplateImagePath(lstOtherImages3);
                    objModel.GarmentSpecImagePath = TemplateImagePath(lstOtherImages.Where(o => o.IsHero).ToList(), true);
                }
            }
            catch (Exception ex)
            {
                objModel.Ex = ex;
            }

            return(objModel);
        }
Esempio n. 2
0
        protected void rptGarmentSpecs_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;

            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
            {
                PatternBO objItem = (PatternBO)(item.DataItem);

                HtmlAnchor linkPattern = (HtmlAnchor)(item.FindControl("linkPattern"));

                //#if DEBUG
                //                linkPattern.HRef = "javascript:void(parent.window.location.href='http://www.bmizzle.com.au/sizing-spec-details/?" +
                //                                   objItem.Number.ToString() + "');";
                //#else
                //                linkPattern.HRef = "javascript:void(parent.window.location.href='http://www.blackchrome.com.au/our-products/garment-sizing-specification-details/?" +
                //                                   objItem.Number.ToString() + "');";
                //#endif

#if DEBUG
                linkPattern.HRef = "javascript:void(window.open('http://local-indico.com/SizingSpecDetails.aspx?id=" + objItem.Number.ToString() + "','_blank'))";
#else
                linkPattern.HRef = "javascript:void(window.open('http://gw.indiman.net/SizingSpecDetails.aspx?id=" + objItem.Number.ToString() + "','_blank'))";
#endif

                string imgLocation = string.Empty;
                PatternTemplateImageBO objPatternTemplateImage = new PatternTemplateImageBO();
                objPatternTemplateImage.Pattern = objItem.ID;

                List <PatternTemplateImageBO> lstPTImages = objPatternTemplateImage.SearchObjects().Where(m => m.ImageOrder == 1).ToList();

                if (lstPTImages.Any())
                {
                    objPatternTemplateImage = lstPTImages.First();

                    if (objPatternTemplateImage != null)
                    {
                        imgLocation = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + objItem.ID.ToString() + "/" + objPatternTemplateImage.Filename + objPatternTemplateImage.Extension;
                        if (!File.Exists(IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + imgLocation))
                        {
                            imgLocation = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                        }
                    }
                }
                else
                {
                    imgLocation = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                }

                Image imgItem = (Image)(item.FindControl("imgItem"));
                imgItem.ImageUrl = imgLocation;

                HtmlGenericControl lblDescription = (HtmlGenericControl)(item.FindControl("lblDescription"));
                lblDescription.InnerText = objItem.Number + " - " + objItem.NickName;
                //lblDescription.InnerText = objItem.Remarks;

                HtmlGenericControl lblAgeGroupGender = (HtmlGenericControl)(item.FindControl("lblAgeGroupGender"));
                HtmlGenericControl lblSizeSet        = (HtmlGenericControl)(item.FindControl("lblSizeSet"));

                string        sizes    = string.Empty;
                List <SizeBO> lstSizes = objItem.objSizeSet.SizesWhereThisIsSizeSet.Where(o => o.IsDefault == true).ToList();
                if (lstSizes.Any())
                {
                    sizes = (lstSizes.Count > 1) ? lstSizes.First().SizeName + " - " + lstSizes.Last().SizeName : lstSizes.First().SizeName;
                }

                lblAgeGroupGender.InnerText = objItem.objGender.Name + ((objItem.AgeGroup.HasValue && objItem.AgeGroup > 0) ? " - " + objItem.objAgeGroup.Name : "");
                lblSizeSet.InnerText        = sizes;
            }
        }
        protected void RadGridCostSheet_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = e.Item as GridDataItem;

                if (item.ItemIndex > -1 && item.DataItem is CostSheetDetailsView)
                {
                    CostSheetDetailsView objCostSheet = (CostSheetDetailsView)item.DataItem;

                    Label lblCostSheet = (Label)item.FindControl("lblCostSheet");
                    lblCostSheet.Text = (objCostSheet.CostSheet).ToString();

                    TextBox txtQuotedCIF = (TextBox)item.FindControl("txtQuotedCIF");
                    txtQuotedCIF.Text = (objCostSheet.QuotedCIF).ToString("0.00");

                    TextBox txtFOBCost = (TextBox)item.FindControl("txtFOBCost");
                    txtFOBCost.Text = (objCostSheet.QuotedFOBCost).ToString("0.00");

                    TextBox txtExchangeRate = (TextBox)item.FindControl("txtExchangeRate");
                    txtExchangeRate.Text = (objCostSheet.ExchangeRate).ToString("0.00");

                    TextBox txtDutyRate = (TextBox)item.FindControl("txtDutyRate");
                    txtDutyRate.Text = (objCostSheet.DutyRate).ToString("0.00");

                    TextBox txtSMVRate = (TextBox)item.FindControl("txtSMVRate");
                    txtSMVRate.Text = (objCostSheet.SMVRate).ToString("0.000");

                    HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit");
                    linkEdit.NavigateUrl = "/AddEditFactoryCostSheet.aspx?id=" + objCostSheet.CostSheet.ToString();

                    LinkButton btnPrintJkCostSheet = (LinkButton)item.FindControl("btnPrintJkCostSheet");
                    btnPrintJkCostSheet.Attributes.Add("id", objCostSheet.CostSheet.ToString());

                    LinkButton btnIndimanCostSheet = (LinkButton)item.FindControl("btnIndimanCostSheet");
                    btnIndimanCostSheet.Attributes.Add("id", objCostSheet.CostSheet.ToString());
                    btnIndimanCostSheet.Visible = (this.LoggedUserRoleName == UserRole.IndimanAdministrator) ? true : false;

                    var linkDelete = (HyperLink)item.FindControl("linkDelete");
                    var hasProduct = ValidateField2(0, "VisualLayout", "FabricCode", objCostSheet.FabricID.ToString(), "Pattern", objCostSheet.PatternID.ToString()) < 1;
                    if (hasProduct)
                    {
                        linkDelete.Visible = false;
                    }


                    linkDelete.Attributes.Add("qid", objCostSheet.CostSheet.ToString());

                    //VisualLayoutBO objVL = new VisualLayoutBO();
                    //objVL.Pattern = objCostSheet.patt

                    HyperLink linkClone = (HyperLink)item.FindControl("linkClone");
                    linkClone.NavigateUrl = "AddEditFactoryCostSheet.aspx?cloneid=" + objCostSheet.CostSheet.ToString();

                    LinkButton btnShowToIndico = (LinkButton)item.FindControl("btnShowToIndico");
                    btnShowToIndico.Attributes.Add("id", objCostSheet.CostSheet.ToString());
                    btnShowToIndico.Text = ((bool)objCostSheet.ShowToIndico) ? "Hide from Indico" : "Show to Indico";

                    btnShowToIndico.Visible = !(this.LoggedUserRoleName == UserRole.FactoryAdministrator || this.LoggedUserRoleName == UserRole.FactoryCoordinator);

                    /*  // Column show to indico
                     * Label lblShowToIndico = (Label)item.FindControl("lblShowToIndico");
                     * lblShowToIndico.Attributes.Add("id", objCostSheet.CostSheet.ToString());
                     * if((bool)objCostSheet.ShowToIndico)
                     * {
                     *    lblShowToIndico.Text = "Yes";
                     * ;                   }
                     * else if ((bool)objCostSheet.ShowToIndico == false)
                     * {
                     *    lblShowToIndico.Text = "No";
                     * } */

                    Label lblShowToIndico = (Label)item.FindControl("lblShowToIndico");
                    if ((bool)objCostSheet.ShowToIndico)
                    {
                        lblShowToIndico.Text = @"<span class='badge badge-success '\>&nbsp;</span>";
                    }
                    else if ((bool)objCostSheet.ShowToIndico == false)
                    {
                        lblShowToIndico.Text = @"<span class='badge badge-important'\>&nbsp;</span>";
                    }

                    //Displaying pattern images
                    string imagePath_1    = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                    string imagePath_2    = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                    string imagePath_3    = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                    string imagePath_hero = IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                    int    count          = 0;

                    int patternID = objCostSheet.PatternID;
                    PatternTemplateImageBO objPatternTemplateImage = new PatternTemplateImageBO();
                    objPatternTemplateImage.Pattern = patternID;

                    List <PatternTemplateImageBO> lstPatternTemplateImageNotHero = objPatternTemplateImage.SearchObjects().Where(m => m.IsHero == false).ToList();
                    count = lstPatternTemplateImageNotHero.Count;

                    foreach (PatternTemplateImageBO patImage in lstPatternTemplateImageNotHero)
                    {
                        if (patImage.ImageOrder == 1)
                        {
                            string imagePath1 = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + "/" + patImage.Pattern + "/" + patImage.Filename + lstPatternTemplateImageNotHero[0].Extension;

                            if (File.Exists(Server.MapPath(imagePath1)))
                            {
                                imagePath_1 = imagePath1;
                            }

                            continue;
                        }

                        if (patImage.ImageOrder == 2)
                        {
                            string imagepPath2 = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + "/" + patImage.Pattern + "/" + patImage.Filename + lstPatternTemplateImageNotHero[0].Extension;

                            if (File.Exists(Server.MapPath(imagepPath2)))
                            {
                                imagePath_2 = imagepPath2;
                            }

                            continue;
                        }

                        if (patImage.ImageOrder == 3)
                        {
                            string imagePath3 = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + "/" + patImage.Pattern + "/" + patImage.Filename + lstPatternTemplateImageNotHero[0].Extension;

                            if (File.Exists(Server.MapPath(imagePath3)))
                            {
                                imagePath_3 = imagePath3;
                            }

                            continue;
                        }
                    }

                    HtmlAnchor         ancTemplateImage = (HtmlAnchor)item.FindControl("ancTemplateImage");
                    HtmlGenericControl iimageView       = (HtmlGenericControl)item.FindControl("iimageView");

                    List <PatternTemplateImageBO> lstPatternTemplateImageHero = objPatternTemplateImage.SearchObjects().Where(m => m.IsHero == true).ToList();

                    if (lstPatternTemplateImageHero.Count > 0)
                    {
                        string imagePathHero = IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + patternID.ToString() + "/" + lstPatternTemplateImageHero.First().Filename + lstPatternTemplateImageHero.First().Extension;
                        if (File.Exists(Server.MapPath(imagePathHero)))
                        {
                            imagePath_hero = imagePathHero;
                        }

                        if (File.Exists(Server.MapPath(imagePathHero)))
                        {
                            ancTemplateImage.Attributes.Add("class", "btn-link preview");
                            iimageView.Attributes.Add("class", "icon-eye-open");

                            System.Drawing.Image VLOrigImage = System.Drawing.Image.FromFile(Server.MapPath(imagePathHero));
                            SizeF origImageSize = VLOrigImage.PhysicalDimension;
                            VLOrigImage.Dispose();

                            System.Drawing.Image VLImage_1 = System.Drawing.Image.FromFile(Server.MapPath(imagePath_1));
                            SizeF image_1Size = VLImage_1.PhysicalDimension;
                            VLImage_1.Dispose();

                            System.Drawing.Image VLImage_2 = System.Drawing.Image.FromFile(Server.MapPath(imagePath_2));
                            SizeF image_2Size = VLImage_2.PhysicalDimension;
                            VLImage_2.Dispose();

                            System.Drawing.Image VLImage_3 = System.Drawing.Image.FromFile(Server.MapPath(imagePath_3));
                            SizeF image_3Size = VLImage_3.PhysicalDimension;
                            VLImage_3.Dispose();

                            List <float> lstVLImageDimensions = (new ImageProcess()).GetResizedImageDimension(Convert.ToInt32(Math.Abs(origImageSize.Width)), Convert.ToInt32(Math.Abs(origImageSize.Height)), 380, 380);
                            List <float> lstVLImageDimensionsForPhotographyImage_1 = (new ImageProcess()).GetResizedImageDimension(Convert.ToInt32(Math.Abs(image_1Size.Width)), Convert.ToInt32(Math.Abs(image_1Size.Height)), 128, 128);
                            List <float> lstVLImageDimensionsForPhotographyImage_2 = (new ImageProcess()).GetResizedImageDimension(Convert.ToInt32(Math.Abs(image_2Size.Width)), Convert.ToInt32(Math.Abs(image_2Size.Height)), 128, 128);
                            List <float> lstVLImageDimensionsForPhotographyImage_3 = (new ImageProcess()).GetResizedImageDimension(Convert.ToInt32(Math.Abs(image_3Size.Width)), Convert.ToInt32(Math.Abs(image_3Size.Height)), 128, 128);

                            string htmlPreview = "<div id='dvPatternTemplate' class=\"ihero\"  target='_blank'>" +
                                                 "<div class=\"ihero-image\">" +
                                                 "<img src=\"" + imagePathHero + "\" alt=\"Hero Image\" height=\"" + lstVLImageDimensions[0].ToString() + "\" width=\"" + lstVLImageDimensions[1].ToString() + "\" />" +
                                                 "</div>" +
                                                 "<div class=\"ihero-details\">" +
                                                 "<img src=\"" + imagePath_1 + "\" alt=\"Thumbnail\" height=\"" + lstVLImageDimensionsForPhotographyImage_1[0].ToString() + "\" width=\"" + lstVLImageDimensionsForPhotographyImage_1[1].ToString() + "\" />" +
                                                 "<img src=\"" + imagePath_2 + "\" alt=\"Thumbnail\" height=\"" + lstVLImageDimensionsForPhotographyImage_2[0].ToString() + "\" width=\"" + lstVLImageDimensionsForPhotographyImage_2[1].ToString() + "\" />" +
                                                 "<img src=\"" + imagePath_3 + "\" alt=\"Thumbnail\" height=\"" + lstVLImageDimensionsForPhotographyImage_3[0].ToString() + "\" width=\"" + lstVLImageDimensionsForPhotographyImage_3[1].ToString() + "\" />" +
                                                 "</div>" +
                                                 "</div>";

                            HtmlContainerControl previewTemplate = (HtmlContainerControl)item.FindControl("previewTemplate");
                            previewTemplate.InnerHtml = htmlPreview;

                            HtmlAnchor ancFullImage = (HtmlAnchor)item.FindControl("ancFullImage");
                            ancFullImage.HRef    = imagePathHero;
                            ancFullImage.Visible = true;

                            ancTemplateImage.HRef = "#" + previewTemplate.ClientID;
                            // ancTemplateImage.Title = "Pattern Images";

                            //ancTemplateImage.Attributes.Add("target", "_blank");
                            //ancTemplateImage.Attributes.Add("onclick", "Javascript:populateDiv(this);return false;");
                            //ancTemplateImage.Attributes.Add("style", "pointer-events:none;");

                            ancTemplateImage.Attributes.Add("hero", imagePathHero);
                            ancTemplateImage.Attributes.Add("nohero_1", imagePath_1);
                            ancTemplateImage.Attributes.Add("nohero_2", imagePath_2);
                            ancTemplateImage.Attributes.Add("nohero_3", imagePath_3);
                        }
                        else
                        {
                            ancTemplateImage.Title = "Pattern Images Not Found";
                            //ancTemplateImage.Attributes.Add("class", "btn-link iremove");
                            iimageView.Attributes.Add("class", "icon-eye-close");
                        }
                    }
                    else
                    {
                        ancTemplateImage.Title = "Pattern Images Not Found";
                        //ancTemplateImage.Attributes.Add("class", "btn-link iremove");
                        iimageView.Attributes.Add("class", "icon-eye-close");
                    }
                }
            }
        }
        private void PopulateControls()
        {
            if (string.IsNullOrEmpty(this.QueryNumber))
            {
                //#if DEBUG
                //                Response.Redirect("http://www.bmizzle.com.au/sizing-specs/");
                //#else
                //                Response.Redirect("http://www.blackchrome.com.au/garment-sizing-specifications/");
                //#endif
                Response.Redirect("http://www.blackchrome.com.au/");
            }
            else
            {
                PatternBO objPattern = new PatternBO();
                objPattern.IsActiveWS = true;
                objPattern.IsActive   = true;
                objPattern.Number     = this.QueryNumber;
                objPattern            = objPattern.SearchObjects().SingleOrDefault();

                if (objPattern != null && objPattern.Creator > 0)
                {
                    WebServicePattern obj = new WebServicePattern();

                    if ((objPattern.PatternCompressionImage ?? 0) > 0)
                    {
                        this.imgSpec.ImageUrl = PopulatePatternCompressionImage(objPattern);
                        this.imgSpec.Visible  = true;
                    }
                    else
                    {
                        this.litSpecBody.Text    = obj.CreateHtml(objPattern, "0", true);
                        this.litSpecBody.Visible = this.dvUnits.Visible = true;
                    }

                    //Populate Images
                    PatternTemplateImageBO objOtherImage = new PatternTemplateImageBO();
                    objOtherImage.Pattern = objPattern.ID;
                    List <PatternTemplateImageBO> lstOtherImages = objOtherImage.SearchObjects();

                    List <PatternTemplateImageBO> lstOtherImages1 = lstOtherImages.Where(o => o.ImageOrder == 1).ToList();
                    List <PatternTemplateImageBO> lstOtherImages2 = lstOtherImages.Where(o => o.ImageOrder == 2).ToList();
                    List <PatternTemplateImageBO> lstOtherImages3 = lstOtherImages.Where(o => o.ImageOrder == 3).ToList();

                    this.imgOther1.Src = this.TemplateImagePath(lstOtherImages1);
                    this.lnkImage1.Attributes.Add("data-image", "../" + this.imgOther1.Src);
                    this.lnkImage1.Attributes.Add("data-zoom-image", "../" + this.imgOther1.Src);
                    this.lnkImage1.Visible = !string.IsNullOrEmpty(this.imgOther1.Src);

                    this.imgOther2.Src = TemplateImagePath(lstOtherImages2);
                    this.lnkImage2.Attributes.Add("data-image", "../" + this.imgOther2.Src);
                    this.lnkImage2.Attributes.Add("data-zoom-image", "../" + this.imgOther2.Src);
                    this.lnkImage2.Visible = !string.IsNullOrEmpty(this.imgOther2.Src);

                    this.imgOther3.Src = TemplateImagePath(lstOtherImages3);
                    this.lnkImage3.Attributes.Add("data-image", "../" + this.imgOther3.Src);
                    this.lnkImage3.Attributes.Add("data-zoom-image", "../" + this.imgOther3.Src);
                    this.lnkImage3.Visible = !string.IsNullOrEmpty(this.imgOther3.Src);

                    //PatternTemplateImageBO objGamentSpec = new PatternTemplateImageBO();
                    //if (lstOtherImages.Where(o => o.IsHero).Any())
                    //{
                    //    objGamentSpec = lstOtherImages.Where(o => o.IsHero).Last();
                    this.imgGamentSpec.Src = TemplateImagePath(lstOtherImages.Where(o => o.IsHero).ToList(), true);
                    // }

                    this.lblNumber.InnerText      = objPattern.Number;
                    this.lblRemarks.InnerText     = objPattern.Remarks;
                    this.lblGender.InnerText      = objPattern.objGender.Name;
                    this.lblDescription.InnerText = objPattern.Description;

                    this.imgHero.Src = (this.lnkImage3.Visible) ? this.imgOther3.Src :
                                       (this.lnkImage1.Visible) ? this.imgOther1.Src : IndicoConfiguration.AppConfiguration.DataFolderName + "/noimage-png-350px-350px.png";
                }
                else
                {
                    //#if DEBUG
                    //                    Response.Redirect("http://www.bmizzle.com.au/sizing-specs/");
                    //#else
                    //                    Response.Redirect("http://www.blackchrome.com.au/garment-sizing-specifications/");
                    //#endif
                    Response.Redirect("http://www.blackchrome.com.au/");
                }
            }
        }