private void ComparePatternGarmentSpec(int pattern)
        {
            PatternBO objPattern = new PatternBO();

            objPattern.ID = pattern;
            objPattern.GetObject();

            this.litPattern2.Text = objPattern.Number + " - " + objPattern.NickName;

            List <SizeChartBO> lstSizeCharts = objPattern.SizeChartsWhereThisIsPattern;


            List <IGrouping <int, SizeChartBO> > lstSizeChartGroup = lstSizeCharts.OrderBy(o => o.objMeasurementLocation.Key).GroupBy(o => o.MeasurementLocation).ToList();

            if (lstSizeChartGroup.Count > 0)
            {
                this.rptCompareSpecSizeQtyHeader.DataSource = (List <SizeChartBO>)lstSizeChartGroup[0].ToList();
                this.rptCompareSpecSizeQtyHeader.DataBind();

                this.rptCompareSpecML.DataSource = lstSizeChartGroup;
                this.rptCompareSpecML.DataBind();
            }

            this.dvComparePatternEmpty.Visible  = (lstSizeCharts.Count > 0) ? false : true;
            this.linkComparePattern.NavigateUrl = "~/AddEditPattern.aspx?id=" + objPattern.ID.ToString();
            this.dvEmptyDiffrence.Visible       = (lstSizeCharts.Count > 0) ? false : true;
            this.dvComparePattern.Visible       = (lstSizeChartGroup.Count > 0) ? true : false;
            this.dvDiffrence.Visible            = (lstSizeChartGroup.Count > 0) ? true : false;
            this.legPattern02.Visible           = true;
            this.legDiffrence.Visible           = true;
        }
        private void PopulateOriginalPatternSpec(int pattern)
        {
            PatternBO objPattern = new PatternBO();

            objPattern.ID = pattern;
            objPattern.GetObject();

            SizeSetBO objSizeSet = new SizeSetBO();

            objSizeSet.ID = objPattern.SizeSet;
            objSizeSet.GetObject();

            List <SizeChartBO> lstSizeCharts = objPattern.SizeChartsWhereThisIsPattern;

            List <IGrouping <int, SizeChartBO> > lstSizeChartGroup = lstSizeCharts.OrderBy(o => o.objMeasurementLocation.Key).GroupBy(o => o.MeasurementLocation).ToList();

            if (lstSizeChartGroup.Count > 0)
            {
                this.rptSpecSizeQtyHeader.DataSource = (List <SizeChartBO>)lstSizeChartGroup[0].ToList();
                this.rptSpecSizeQtyHeader.DataBind();

                this.rptSpecML.DataSource = lstSizeChartGroup;
                this.rptSpecML.DataBind();
            }

            this.ddlComparePattern.Enabled = (lstSizeCharts.Count > 0) ? true : false;
            this.dvEmptyPattern.Visible    = (lstSizeCharts.Count > 0) ? false : true;
            this.linkPattern.NavigateUrl   = "~/AddEditPattern.aspx?id=" + objPattern.ID.ToString();
            this.dvOriginalPattern.Visible = (lstSizeCharts.Count > 0) ? true : false;
            this.legPattern01.Visible      = true;
        }
        private List <KeyValuePair <int, string> > PopulateCategories(string MenuItem)
        {
            List <KeyValuePair <int, string> > lstCategoryItems = new List <KeyValuePair <int, string> >();
            PatternBO objPattern = new PatternBO();

            objPattern.IsActiveWS = true;
            List <int> lstCategoryIDs = new List <int>();

            //1	MENS
            //2	LADIES
            //3	UNISEX
            //4	N/A
            //5	&nbsp;

            //1	ADULT
            //2	YOUTH	NULL
            //3	INFANTS	NULL
            //4	N/A	NULL
            //5	FULL RANGE	NULL
            //7	BESPOKE

            switch (MenuItem)
            {
            case "Mens":
                lstCategoryIDs = PatternCategorySource.Where(m => m.Gender == 1 && m.AgeGroup == 1).Select(m => m.CoreCategory).Distinct().ToList();
                break;

            case "Ladies":
                lstCategoryIDs = PatternCategorySource.Where(m => m.Gender == 2 && m.AgeGroup == 1).Select(m => m.CoreCategory).Distinct().ToList();
                break;

            case "Unisex":
                lstCategoryIDs = PatternCategorySource.Where(m => m.Gender == 3).Select(m => m.CoreCategory).Distinct().ToList();
                break;

            case "Youth":
                lstCategoryIDs = PatternCategorySource.Where(m => m.AgeGroup == 2).Select(m => m.CoreCategory).Distinct().ToList();
                break;

            case "Other":
                lstCategoryIDs = PatternCategorySource.Where(m => m.Gender > 3 || m.AgeGroup > 2).Select(m => m.CoreCategory).Distinct().ToList();
                break;

            default:
                break;
            }

            foreach (int CatID in lstCategoryIDs)
            {
                CategoryBO objCat = this.CategorySource.Where(m => m.ID == CatID).SingleOrDefault();
                lstCategoryItems.Add(new KeyValuePair <int, string>(CatID, objCat.Name));
            }

            return(lstCategoryItems.OrderBy(m => m.Value).ToList());
        }
        private string PopulateGarmentSpecStatus(PatternBO objPattern)
        {
            string status     = string.Empty;
            bool   haveValues = false;
            bool   haveZeroes = false;

            // check pattern status
            if (objPattern.SizeChartsWhereThisIsPattern.Count > 0)
            {
                foreach (SizeChartBO sChartValue in objPattern.SizeChartsWhereThisIsPattern)
                {
                    if (sChartValue.Val != 0)
                    {
                        haveValues = true;
                    }
                    else
                    {
                        haveZeroes = true;
                    }
                }
            }
            if (objPattern.SizeChartsWhereThisIsPattern.Count == 0 && objPattern.objItem.MeasurementLocationsWhereThisIsItem.Count > 0 && objPattern.objSizeSet.SizesWhereThisIsSizeSet.Count > 0)
            {
                status = "Not Completed";
            }
            else if (objPattern.SizeChartsWhereThisIsPattern.Count == 0 && objPattern.objItem.MeasurementLocationsWhereThisIsItem.Count == 0)
            {
                status = "Spec Missing";
            }
            else if (objPattern.SizeChartsWhereThisIsPattern.Count == 0 && objPattern.objItem.MeasurementLocationsWhereThisIsItem.Count > 0 && objPattern.objSizeSet.SizesWhereThisIsSizeSet.Count == 0)
            {
                status = "Spec Missing";
            }
            //-----------------------------------------------------------
            if (haveValues == true && haveZeroes == true)
            {
                status = "Partialy Completed";
            }

            if (haveValues == true && haveZeroes == false)
            {
                status = "Completed";
            }

            if (haveValues == false && haveZeroes == true)
            {
                status = "Not Completed";
            }
            //-------------------------------------------------------------

            return(status);
        }
        private string GetCompressionImagePhysicalPath(PatternBO objPattern)
        {
            string filePath = string.Empty;

            if ((objPattern.PatternCompressionImage ?? 0) > 0)
            {
                string fileName           = objPattern.objPatternCompressionImage.Filename;
                string extension          = objPattern.objPatternCompressionImage.Extension;
                string physicalFolderPath = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\PatternCompressionImages\\" + objPattern.ID + "\\";
                filePath = (physicalFolderPath + fileName + extension);
            }

            return(filePath);
        }
        protected void RadGridPattern_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = e.Item as GridDataItem;

                if ((item.ItemIndex > -1 && item.DataItem is ReturnPatternDetailsViewBO))
                {
                    ReturnPatternDetailsViewBO objPatternDetails = (ReturnPatternDetailsViewBO)item.DataItem;

                    TextBox txtManualDescription = (TextBox)item.FindControl("txtManualDescription");
                    txtManualDescription.Text = objPatternDetails.Remarks;

                    TextBox txtMarketingDescription = (TextBox)item.FindControl("txtMarketingDescription");
                    txtMarketingDescription.Text = objPatternDetails.MarketingDescription;

                    TextBox txNotes = (TextBox)item.FindControl("txNotes");
                    txNotes.Text = objPatternDetails.PatternNotes;

                    TextBox txtFactoryDescription = (TextBox)item.FindControl("txtFactoryDescription");
                    txtFactoryDescription.Text = objPatternDetails.FactoryDescription;

                    PatternBO objPattern = new PatternBO();
                    objPattern.ID = (int)objPatternDetails.Pattern;
                    objPattern.GetObject();

                    string status = this.PopulateGarmentSpecStatus(objPattern);

                    RadGridPattern.Columns[12].Visible = (this.LoggedUser.HaveAccessForHTTPPost != null) ? (bool)this.LoggedUser.HaveAccessForHTTPPost : false;
                    Literal lblStatus = (Literal)item.FindControl("lblStatus");
                    lblStatus.Text = "<span class=\"badge badge-" + status.ToLower().Replace(" ", string.Empty).Trim() + "\">&nbsp;</span>";

                    LinkButton lbSave = (LinkButton)item.FindControl("lbSave");
                    lbSave.Attributes.Add("pid", objPatternDetails.Pattern.ToString());

                    Literal litPost = (Literal)item.FindControl("litPost");

                    bool HaveAcccessHttpPost = (this.LoggedUser.HaveAccessForHTTPPost != null) ? (bool)this.LoggedUser.HaveAccessForHTTPPost : false;
                    if (objPatternDetails.IsActiveWS == true && HaveAcccessHttpPost)
                    {
                        litPost.Text = "Sent";
                    }
                    else
                    {
                        litPost.Text = "Not yet sent";
                    }
                }
            }
        }
        protected void lbSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    foreach (GridDataItem item in RadGridPattern.Items)
                    {
                        TextBox txtManualDescription = (TextBox)item.FindControl("txtManualDescription");

                        TextBox txtMarketingDescription = (TextBox)item.FindControl("txtMarketingDescription");

                        TextBox txNotes = (TextBox)item.FindControl("txNotes");

                        TextBox txtFactoryDescription = (TextBox)item.FindControl("txtFactoryDescription");

                        LinkButton lbSave = (LinkButton)item.FindControl("lbSave");

                        int id = int.Parse(((System.Web.UI.WebControls.WebControl)(lbSave)).Attributes["pid"].ToString());

                        if (id > 0)
                        {
                            PatternBO objPattern = new PatternBO(this.ObjContext);
                            objPattern.ID = id;
                            objPattern.GetObject();

                            objPattern.Remarks            = txtManualDescription.Text;
                            objPattern.Description        = txtMarketingDescription.Text;
                            objPattern.PatternNotes       = txNotes.Text;
                            objPattern.FactoryDescription = txtFactoryDescription.Text;

                            //if (objPattern.IsActiveWS)
                            //{
                            //    this.UpdateWebService(objPattern);
                            //}
                        }
                    }
                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }

                this.PopulateDataGrid();
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while changing the notes and descriptions in Pattern from ViewDescriptionGrid.aspx", ex);
            }
        }
        protected void lbDownload_Click(object sender, EventArgs e)
        {
            try
            {
                WebServicePattern objWebServicePattern = new WebServicePattern();
                PatternBO         objPattern           = new PatternBO();
                objPattern.Number     = this.QueryNumber;
                objPattern.IsActiveWS = true;
                objPattern.IsActive   = true;
                objPattern            = objPattern.SearchObjects().SingleOrDefault();

                string filePath = objWebServicePattern.GeneratePDF(objPattern, false, this.hdnType.Value, this.CompressionImagePhysicalPath);
                this.DownloadPDFFile(filePath, objPattern.Number);
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while downloading pdf in Sizingspecs.aspx", ex);
            }
        }
        private void Search()
        {
            int Pattern = int.Parse(this.ddlPattern.SelectedValue);

            if (Pattern > 0)
            {
                _activePatternBO      = null;
                _activePatternFabrics = null;

                // Set active pattern ID
                this.hdnPattern.Value = Pattern.ToString();

                // Populate pattern
                this.PopulatePattern();
            }

            ViewState["PopulatePatern"] = false;
            ViewState["PopulateFabric"] = false;
        }
Exemple #10
0
        /// <summary>
        /// Process the page data.
        /// </summary>
        private void ProcessForm(int queryId, bool isDelete)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    PatternBO objPattern = new PatternBO(this.ObjContext);
                    if (queryId > 0)
                    {
                        objPattern.ID = queryId;
                        objPattern.GetObject();
                    }
                    if (isDelete)
                    {
                        List <PriceBO> lstPrces = objPattern.PricesWhereThisIsPattern;
                        foreach (PriceBO price in lstPrces)
                        {
                            PriceBO objPrice = new PriceBO(this.ObjContext);
                            objPrice.ID = price.ID;
                            objPrice.GetObject();

                            foreach (PriceLevelCostBO priceLevelCost in objPrice.PriceLevelCostsWhereThisIsPrice)
                            {
                                PriceLevelCostBO objPriceLevelCost = new PriceLevelCostBO(this.ObjContext);
                                objPriceLevelCost.ID = priceLevelCost.ID;
                                objPriceLevelCost.GetObject();

                                objPriceLevelCost.Delete();
                            }

                            objPrice.Delete();
                        }
                    }
                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                // Log the error
                //IndicoLogging.log("Error occured while Adding the Item", ex);
            }
        }
Exemple #11
0
        protected void btnSelectPattern_Click(object sender, EventArgs e)
        {
            int qid = int.Parse(((System.Web.UI.WebControls.LinkButton)(sender)).Attributes["qid"].ToString());

            if (qid > 0)
            {
                _activePatternBO      = null;
                _activePatternFabrics = null;

                // Set active pattern ID
                this.hdnPattern.Value = qid.ToString();

                // Populate pattern
                this.PopulatePattern();
            }

            ViewState["PopulatePatern"] = false;
            ViewState["PopulateFabric"] = false;
        }
Exemple #12
0
        protected void dgPatterns_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            DataGridItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is PatternBO)
            {
                PatternBO objPattern = (PatternBO)item.DataItem;

                Label lblItemName = (Label)item.FindControl("lblItemName");
                lblItemName.Text = objPattern.objItem.Name;

                Label lblGender = (Label)item.FindControl("lblGender");
                lblGender.Text = objPattern.objGender.Name;

                Label lblIsAcitve = (Label)item.FindControl("lblIsAcitve");
                lblIsAcitve.Text = (objPattern.IsActive ? "Inactive" : "Active");

                LinkButton btnSelectPattern = (LinkButton)item.FindControl("btnSelectPattern");
                btnSelectPattern.Attributes.Add("qid", objPattern.ID.ToString());
            }
        }
        private string PopulatePatternCompressionImage(PatternBO objPattern)
        {
            string dataFolderPath = "/" + IndicoConfiguration.AppConfiguration.DataFolderName;
            string ImagePath      = dataFolderPath + "/noimage-png-350px-350px.png";

            if ((objPattern.PatternCompressionImage ?? 0) > 0)
            {
                string fileName  = objPattern.objPatternCompressionImage.Filename;
                string extension = objPattern.objPatternCompressionImage.Extension;

                //string physicalFolderPath = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\PatternCompressionImages\\" + objPattern.ID + "\\";
                string CompressionImagePhysicalPath = GetCompressionImagePhysicalPath(objPattern); // physicalFolderPath + fileName + extension;

                if (File.Exists(CompressionImagePhysicalPath))
                {
                    ImagePath = dataFolderPath + "/PatternCompressionImages/" + objPattern.ID + "/" + fileName + extension;
                }
            }

            return(ImagePath);
        }
        public string Get(int id, int unit = 0) // convertType = 0 : cm / 1 : inch
        {
            try
            {
                PatternBO objPattern = new PatternBO();
                objPattern.ID = id;
                objPattern.GetObject();

                WebServicePattern objWebServicePattern = new WebServicePattern(true);
                string            filePath             = objWebServicePattern.GeneratePDF(objPattern, false, unit.ToString(), GetCompressionImagePhysicalPath(objPattern));

                filePath = filePath.Replace(IndicoConfiguration.AppConfiguration.PathToProjectFolder, IndicoConfiguration.AppConfiguration.SiteHostAddress.Replace("/", ""));
                filePath = filePath.Replace(@"\", "/");

                return(filePath);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void ddlPattern_SelectedIndexChanged(object sender, EventArgs e)
        {
            int id = int.Parse(this.ddlPattern.SelectedValue);

            if (id > 0)
            {
                this.ddlComparePattern.Enabled = true;

                this.Repopulate();

                PatternBO objPattern = new PatternBO();
                objPattern.ID = id;
                objPattern.GetObject();

                this.litPattern1.Text = objPattern.Number + " - " + objPattern.NickName;

                PatternBO objPat = new PatternBO();
                objPat.SizeSet = objPattern.SizeSet;
                objPat.Item    = objPattern.Item;

                List <PatternBO> lstPattern = objPat.SearchObjects().Where(o => o.ID != id).ToList();

                this.ddlComparePattern.Items.Clear();
                this.ddlComparePattern.Items.Add(new ListItem("Select Next Pattern", "0"));

                if (lstPattern.Count > 0)
                {
                    foreach (PatternBO pat in lstPattern)
                    {
                        this.ddlComparePattern.Items.Add(new ListItem(pat.Number + " - " + pat.NickName, pat.ID.ToString()));
                    }
                }
                else
                {
                    this.ddlComparePattern.Enabled = false;
                }

                this.PopulateOriginalPatternSpec(objPattern.ID);
            }
        }
Exemple #16
0
        protected void btnSaveChanges_Click(object sender, EventArgs e)
        {
            ViewState["PopulatePatern"] = false;
            ViewState["PopulateFabric"] = false;

            if (Session["IsRefresh"].ToString() == ViewState["IsRefresh"].ToString())
            {
                int queryId = int.Parse(this.hdnPattern.Value.Trim());
                if (Page.IsValid && queryId > 0)
                {
                    try
                    {
                        using (TransactionScope ts = new TransactionScope())
                        {
                            PatternBO objPattern = new PatternBO(this.ObjContext);
                            objPattern.ID = queryId;
                            objPattern.GetObject();

                            objPattern.ConvertionFactor = decimal.Parse(this.txtConvertionFactor.Text.Trim());
                            objPattern.PriceRemarks     = this.txtRemarks.Text.Trim();

                            this.ObjContext.SaveChanges();
                            ts.Complete();
                        }

                        this.PopulateControls();
                    }
                    catch (Exception ex)
                    {
                        IndicoLogging.log.Error("AddEditIndimanPrice.aspx btnSaveChanges_Click()", ex);
                    }

                    Response.Redirect("/ViewPrices.aspx");
                }
                Session["IsRefresh"] = Server.UrlEncode(System.DateTime.Now.ToString());
            }
        }
        public void DeleteDirectoriesGivenPattern(PatternBO objPattern)
        {
            string deleteImageDirectory = string.Empty;
            string deletePDFDirectory   = string.Empty;

            deleteImageDirectory = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/" + objPattern.Number;
            deletePDFDirectory   = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServicePDF/" + objPattern.Number + ".pdf";
            try
            {
                if (Directory.Exists(deleteImageDirectory))
                {
                    Directory.Delete(deleteImageDirectory, true);
                }

                if (File.Exists(deletePDFDirectory))
                {
                    File.Delete(deletePDFDirectory);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public string GeneratePDF(PatternBO objPattern, bool isWebService, string convertType, string compressionImagePath = "", bool isAllSizes = false)
        {
            string createpdfPath = string.Empty;
            string imagepath     = string.Empty;

            try
            {
                if (isWebService)
                {
                    imagepath = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/" + objPattern.Number.ToString() + "/" + objPattern.Number + ".jpg";
                }
                else
                {
                    List <PatternTemplateImageBO> listPTIs = objPattern.PatternTemplateImagesWhereThisIsPattern.Where(o => o.IsHero).ToList();

                    if (listPTIs.Any())
                    {
                        PatternTemplateImageBO objPatternTemplateImage = listPTIs.Last();
                        imagepath = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + objPattern.ID.ToString() + "/" + objPatternTemplateImage.Filename + objPatternTemplateImage.Extension;
                    }
                }

                imagepath = (File.Exists(imagepath)) ? imagepath : IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";

                createpdfPath = (isWebService) ? IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServicePDF/" + objPattern.Number.ToString() + ".pdf" : IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "\\temp\\" + "GS_" + objPattern.Number.ToString() + ".pdf";;

                //Document document = new Document();
                using (var document = new Document())
                    using (var writer = PdfWriter.GetInstance(document, new FileStream(createpdfPath, FileMode.Create)))
                    {
                        document.AddKeywords("paper airplanes");

                        float marginBottom = 12;
                        float lineHeight   = 14;
                        float pageMargin   = 20;
                        float pageHeight   = iTextSharp.text.PageSize.A4.Width;
                        float pageWidth    = iTextSharp.text.PageSize.A4.Height;

                        document.SetPageSize(new iTextSharp.text.Rectangle(pageWidth, pageHeight));
                        document.SetMargins(0, 0, 0, 0);

                        // Open the document for writing content
                        document.Open();
                        // Get the top layer and write some text
                        contentByte = writer.DirectContent;

                        contentByte.BeginText();
                        string content = string.Empty;

                        // Header
                        contentByte.SetFontAndSize(this.PDFFont, 24);
                        content = "GARMENT SPECIFICATION";
                        contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, content, pageMargin, (pageHeight - pageMargin - lineHeight), 0);

                        // Title
                        contentByte.SetFontAndSize(this.PDFFont, 9);
                        content = "Pattern " + objPattern.Number + " - " + objPattern.NickName;
                        contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, content, pageMargin, (pageHeight - pageMargin - lineHeight - marginBottom), 0);

                        content = objPattern.ModifiedDate.ToLongDateString();
                        contentByte.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, content, (pageWidth - pageMargin), (pageHeight - pageMargin - lineHeight - marginBottom), 0);

                        // Footer
                        contentByte.SetFontAndSize(this.PDFFont, 8);
                        content = "© Copyright " + DateTime.Now.Year.ToString() + ", All rights reserved.";
                        contentByte.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, content, (pageWidth - pageMargin), pageMargin, 0);

                        contentByte.EndText();

                        // Top Line
                        contentByte.SetLineWidth(0.5f);
                        contentByte.SetColorStroke(BaseColor.BLACK);
                        contentByte.MoveTo(pageMargin, (pageHeight - pageMargin - lineHeight - marginBottom - 4));
                        contentByte.LineTo((pageWidth - pageMargin), (pageHeight - pageMargin - lineHeight - marginBottom - 4));
                        contentByte.Stroke();

                        // Bottom Line
                        contentByte.SetLineWidth(0.5f);
                        contentByte.SetColorStroke(BaseColor.BLACK);
                        contentByte.MoveTo(pageMargin, pageMargin + marginBottom);
                        contentByte.LineTo((pageWidth - pageMargin), pageMargin + marginBottom);
                        contentByte.Stroke();

                        if (string.IsNullOrWhiteSpace(compressionImagePath) && objPattern.PatternCompressionImage != 0 && objPattern.objPatternCompressionImage != null)
                        {
                            var fileName  = objPattern.objPatternCompressionImage.Filename;
                            var extension = objPattern.objPatternCompressionImage.Extension;

                            var physicalFolderPath = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\PatternCompressionImages\\" + objPattern.ID + "\\";

                            if (File.Exists(physicalFolderPath + fileName + extension))
                            {
                                var dataFolderPath = Path.Combine(IndicoConfiguration.AppConfiguration.PathToProjectFolder, IndicoConfiguration.AppConfiguration.DataFolderName);
                                compressionImagePath = Path.Combine(dataFolderPath, "PatternCompressionImages", objPattern.ID.ToString(), fileName + extension);
                            }
                        }
                        if ((objPattern.PatternCompressionImage ?? 0) > 0 && !string.IsNullOrWhiteSpace(compressionImagePath))
                        {
                            var specImage = iTextSharp.text.Image.GetInstance(compressionImagePath);
                            specImage.ScaleToFit(pageWidth - (pageMargin * 2), 230f);
                            specImage.SetAbsolutePosition(((pageWidth - specImage.ScaledWidth) / 2), (pageHeight - (pageMargin * 2) - lineHeight - marginBottom - specImage.ScaledHeight));
                            document.Add(specImage);
                        }
                        else
                        {
                            // Draw Hero Image
                            var heroImage = iTextSharp.text.Image.GetInstance(imagepath);
                            heroImage.ScaleToFit(pageWidth - (pageMargin * 2), 270f);
                            heroImage.SetAbsolutePosition(((pageWidth - heroImage.ScaledWidth) / 2), (pageHeight - (pageMargin * 2) - lineHeight - marginBottom - heroImage.ScaledHeight));
                            document.Add(heroImage);

                            var htmlText   = CreateHtml(objPattern, convertType, isAllSizes);
                            var htmlWorker = new HTMLWorker(document);
                            htmlWorker.Parse(new StringReader(htmlText));
                        }

                        document.Close();
                        writer.Close();
                    }
                // PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(createpdfPath, FileMode.Create));
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(createpdfPath);
        }
        public string CreateImages(PatternBO objPattern, string image)
        {
            var    objImageProcess = new ImageProcess();
            string imageSource     = string.Empty;
            string newImageSource  = string.Empty;
            string folderPath      = string.Empty;
            float  tempHeight      = 0;
            float  tempWidth       = 0;

            #region CreateFolderPath

            folderPath = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/" + objPattern.Number.ToString();

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            #endregion

            if (image == "img4")
            {
                List <PatternTemplateImageBO> lstPatternTemplateImage = objPattern.PatternTemplateImagesWhereThisIsPattern.Where(o => o.IsHero == true).ToList();
                newImageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/" + objPattern.Number.ToString() + "/" + objPattern.Number + ".jpg";

                if (lstPatternTemplateImage.Count > 0)
                {
                    foreach (PatternTemplateImageBO ptImageHero in lstPatternTemplateImage)
                    {
                        imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + ptImageHero.Pattern.ToString() + "/" + ptImageHero.Filename + ptImageHero.Extension;

                        if (!File.Exists(imageSource))
                        {
                            imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";
                        }
                    }
                }
                else
                {
                    imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";
                }
                if (File.Exists(newImageSource))
                {
                    File.Delete(newImageSource);
                }
                if (!File.Exists(newImageSource))
                {
                    #region resizeImageDimentions

                    System.Drawing.Image VLOrigImage = System.Drawing.Image.FromFile(imageSource);
                    SizeF origImageSize = VLOrigImage.PhysicalDimension;
                    VLOrigImage.Dispose();

                    tempWidth  = 852;
                    tempHeight = (float)Math.Round(((tempWidth / origImageSize.Width) * origImageSize.Height), 0);

                    #endregion

                    objImageProcess.ResizeWebServiceImages(int.Parse(tempWidth.ToString()), int.Parse(tempHeight.ToString()), imageSource, newImageSource);
                }
            }
            if (image == "img2")
            {
                List <PatternTemplateImageBO> lstPatternTemplateImage = objPattern.PatternTemplateImagesWhereThisIsPattern.Where(o => o.IsHero == false && o.ImageOrder == 2).ToList();
                newImageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/" + objPattern.Number.ToString() + "/" + objPattern.Number + "-2" + ".jpg";

                if (lstPatternTemplateImage.Count > 0)
                {
                    imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + lstPatternTemplateImage[0].Pattern.ToString() + "/" + lstPatternTemplateImage[0].Filename + lstPatternTemplateImage[0].Extension;

                    if (!File.Exists(imageSource))
                    {
                        imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";
                    }
                }
                else
                {
                    imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";
                }

                if (File.Exists(newImageSource))
                {
                    File.Delete(newImageSource);
                }
                if (!File.Exists(newImageSource))
                {
                    #region ResizeImageDimentions

                    System.Drawing.Image VLOrigImage = System.Drawing.Image.FromFile(imageSource);
                    SizeF origImageSize = VLOrigImage.PhysicalDimension;
                    VLOrigImage.Dispose();

                    tempWidth  = 480;
                    tempHeight = (float)Math.Round(((480 / origImageSize.Width) * origImageSize.Height), 0);

                    #endregion

                    objImageProcess.ResizeWebServiceImages(int.Parse(tempWidth.ToString()), int.Parse(tempHeight.ToString()), imageSource, newImageSource);
                }
            }

            if (image == "img3")
            {
                List <PatternTemplateImageBO> lstPatternTemplateImage = objPattern.PatternTemplateImagesWhereThisIsPattern.Where(o => o.IsHero == false && o.ImageOrder == 3).ToList();
                newImageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/" + objPattern.Number.ToString() + "/" + objPattern.Number + "-3" + ".jpg";

                if (lstPatternTemplateImage.Count > 0)
                {
                    imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + lstPatternTemplateImage[0].Pattern.ToString() + "/" + lstPatternTemplateImage[0].Filename + lstPatternTemplateImage[0].Extension;

                    if (!File.Exists(imageSource))
                    {
                        imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";
                    }
                }
                else
                {
                    imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";
                }

                if (File.Exists(newImageSource))
                {
                    File.Delete(newImageSource);
                }

                if (!File.Exists(newImageSource))
                {
                    #region resizeImageDimentions

                    System.Drawing.Image VLOrigImage = System.Drawing.Image.FromFile(imageSource);
                    SizeF origImageSize = VLOrigImage.PhysicalDimension;
                    VLOrigImage.Dispose();

                    tempWidth  = 480;
                    tempHeight = (float)Math.Round(((480 / origImageSize.Width) * origImageSize.Height), 0);

                    #endregion

                    objImageProcess.ResizeWebServiceImages(int.Parse(tempWidth.ToString()), int.Parse(tempHeight.ToString()), imageSource, newImageSource);
                }
            }

            if (image == "img1")
            {
                List <PatternTemplateImageBO> lstPatternTemplateImage = objPattern.PatternTemplateImagesWhereThisIsPattern.Where(o => o.IsHero == false && o.ImageOrder == 1).ToList();
                newImageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/" + objPattern.Number.ToString() + "/" + objPattern.Number + "-1" + ".jpg";

                if (lstPatternTemplateImage.Count > 0)
                {
                    imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/PatternTemplates/" + lstPatternTemplateImage[0].Pattern.ToString() + "/" + lstPatternTemplateImage[0].Filename + lstPatternTemplateImage[0].Extension;

                    if (!File.Exists(imageSource))
                    {
                        imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";
                    }
                }
                else
                {
                    imageSource = IndicoConfiguration.AppConfiguration.PathToProjectFolder + "/" + IndicoConfiguration.AppConfiguration.DataFolderName + "/WebServicePattern/WebServiceImages/gspec-missing.jpg";
                }

                if (File.Exists(newImageSource))
                {
                    File.Delete(newImageSource);
                }

                if (!File.Exists(newImageSource))
                {
                    #region ResizeImageDimentions

                    System.Drawing.Image VLOrigImage = System.Drawing.Image.FromFile(imageSource);
                    SizeF origImageSize = VLOrigImage.PhysicalDimension;
                    VLOrigImage.Dispose();

                    tempWidth  = 480;
                    tempHeight = (float)Math.Round(((480 / origImageSize.Width) * origImageSize.Height), 0);

                    #endregion

                    objImageProcess.ResizeWebServiceImages(int.Parse(tempWidth.ToString()), int.Parse(tempHeight.ToString()), imageSource, newImageSource);
                }
            }
            return(newImageSource);
        }
        public string WriteGramentSpecXML(PatternBO ObjPattern)
        {
            List <SizeChartBO> lstSizeCharts = ObjPattern.SizeChartsWhereThisIsPattern.Where(o => o.objMeasurementLocation.IsSend == true).ToList();
            StringWriter       sw            = new StringWriter();
            string             s             = string.Empty;

            if (lstSizeCharts.Count > 0)
            {
                List <IGrouping <int, SizeChartBO> > lstSizeChartGroup = lstSizeCharts.OrderBy(o => o.objMeasurementLocation.Key).GroupBy(o => o.MeasurementLocation).ToList();

                using (XmlTextWriter writer = new XmlTextWriter(sw))
                {
                    writer.WriteStartDocument();
                    writer.WriteStartElement("xml");
                    writer.WriteStartElement("mdtl");


                    writer.WriteStartElement("szs");


                    foreach (SizeChartBO sizeChart in lstSizeChartGroup[0].ToList())
                    {
                        //bool isPrint = false;

                        /* foreach (var sizeChar in lstSizeChartGroup.Select(m => m.First()).ToList())
                         * {
                         *   List<SizeChartBO> lstSizeChart = ObjPattern.SizeChartsWhereThisIsPattern.Where(m => m.MeasurementLocation == sizeChar.MeasurementLocation && m.Size == sizeChart.Size && m.objMeasurementLocation.IsSend == true).ToList();
                         *
                         *   int valcount = 0;
                         *
                         *   foreach (var item in lstSizeChart)
                         *   {
                         *       if (item.Val == 0)
                         *       {
                         *           valcount++;
                         *       }
                         *   }
                         *
                         *   if (lstSizeChart.Count != valcount)
                         *   {
                         *       isPrint = true;
                         *   }
                         * }*/

                        SizeChartBO objSC = new SizeChartBO();
                        objSC.Size = sizeChart.Size;


                        if (objSC.SearchObjects().Where(o => o.Val == 0).Count() != objSC.SearchObjects().Count())
                        {
                            writer.WriteElementString("sz", sizeChart.objSize.SizeName);
                        }
                    }

                    writer.WriteEndElement();

                    writer.WriteStartElement("mnts");
                    foreach (var sizeChart in lstSizeChartGroup.Select(m => m.First()).ToList())
                    {
                        List <SizeChartBO> lstSizeChart = ObjPattern.SizeChartsWhereThisIsPattern.Where(m => m.MeasurementLocation == sizeChart.MeasurementLocation && m.objMeasurementLocation.IsSend == true).ToList();


                        int count = lstSizeChart.Where(o => o.Val == 0).Count();

                        //foreach (var item in lstSizeChart)
                        //{
                        //    if (item.Val == 0)
                        //    {
                        //        count++;
                        //    }
                        //}


                        if (lstSizeChart.Count != count)
                        {
                            writer.WriteStartElement("mnt");
                            writer.WriteElementString("mpnt", sizeChart.objMeasurementLocation.Key + ". " + sizeChart.objMeasurementLocation.Name);
                            writer.WriteStartElement("unts");
                        }


                        foreach (var values in lstSizeChart.ToList())
                        {
                            //int valueCount = 0;

                            //foreach (var item in lstSizeChart)
                            //{
                            //    if (values.Val == 0)
                            //    {
                            //        valueCount++;
                            //    }
                            //}

                            SizeChartBO objSizeChart = new SizeChartBO();
                            objSizeChart.Size = values.Size;


                            if ((lstSizeChart.Count != count) && (objSizeChart.SearchObjects().Where(o => o.Val == 0).Count() != objSizeChart.SearchObjects().Count()))
                            {
                                writer.WriteElementString("unt", Math.Round(Convert.ToDecimal(values.Val), 0).ToString());
                            }
                        }
                        if (lstSizeChart.Count != count)
                        {
                            writer.WriteEndElement();
                            writer.WriteEndElement();
                        }
                    }

                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteEndElement();

                    writer.Flush();

                    s = sw.ToString().Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", string.Empty);

                    /* string textFilePath = IndicoConfiguration.AppConfiguration.PathToDataFolder + @"\Temp\pattern_" + ObjPattern.Number + ".txt";
                     * System.IO.StreamWriter file = new System.IO.StreamWriter(textFilePath, false);
                     * file.WriteLine(s);
                     * file.Close();*/
                }
            }
            return(s);
        }
        public string CreateHtml(PatternBO objPattern, string convertType, bool tbodyOnly, bool isAllSizes)
        {
            string tbody = "<tr>" +
                           "    <td></td>" +
                           "    <$measurementposition$>" +
                           "</tr>" +
                           "<$records$>";

            string garmentspec = GarmentSpecHtml;

            garmentspec = garmentspec.Replace("<$type$>", (convertType == "0") ? "1.0 cm" : "0.5 inch");

            //List<SizeChartBO> lstSizeCharts = objPattern.SizeChartsWhereThisIsPattern.Where(o => o.objMeasurementLocation.IsSend == true).ToList();
            SizeChartBO objSChart = new SizeChartBO();

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

            if (!isAllSizes)
            {
                lstSizeCharts = objSChart.SearchObjects().Where(o => o.objMeasurementLocation.IsSend == true).ToList();
            }

            if (lstSizeCharts.Count > 0)
            {
                string tabledata = string.Empty;
                string records   = string.Empty;
                string style     = string.Empty;
                List <IGrouping <int, SizeChartBO> > lstSizeChartGroup = lstSizeCharts.OrderBy(o => o.objMeasurementLocation.Key).GroupBy(o => o.MeasurementLocation).ToList();

                foreach (SizeChartBO sizeChart in lstSizeChartGroup[0].ToList())
                {
                    //SizeChartBO objSC = new SizeChartBO();
                    //objSC.Size = sizeChart.Size;

                    //if (objSC.SearchObjects().Where(o => o.Val == 0).Count() != objSC.SearchObjects().Count())
                    //{
                    //    tabledata += "<td align=\"center\" bgcolor=\"#CCCCCC\" style=\"background-color: #CCCCCC; width: 35px; font-weight: bold;\">" + sizeChart.objSize.SizeName + "</td>";
                    //}

                    //if (sizeChart.Val > 0)
                    //{
                    if (tbodyOnly)
                    {
                        tabledata += "<td>" + sizeChart.objSize.SizeName + "</td>";
                    }
                    else
                    {
                        tabledata += "<td align=\"center\" bgcolor=\"#CCCCCC\" style=\"background-color: #CCCCCC; width: 35px; font-weight: bold;\">" + sizeChart.objSize.SizeName + "</td>";
                    }
                    //}
                }

                tbody       = tbody.Replace("<$measurementposition$>", tabledata);
                garmentspec = garmentspec.Replace("<$measurementposition$>", tabledata);
                bool alternativeRow = false;

                var listTR = lstSizeChartGroup.Select(m => m.First()).ToList();
                foreach (var sizeChart in listTR)
                {
                    //List<SizeChartBO> lstSizeChart = objPattern.SizeChartsWhereThisIsPattern.Where(m => m.MeasurementLocation == sizeChart.MeasurementLocation && m.objMeasurementLocation.IsSend == true).ToList();
                    //int count = lstSizeChart.Where(o => o.Val == 0).Count();

                    //if (lstSizeChart.Count != count)
                    //{
                    //    style = (alternativeRow) ? "#CCCCCC" : "#F5F5F5";
                    //    records += "<tr>";
                    //    records += "<td align=\"left\" bgcolor=" + style + " width=\"250\">" + sizeChart.objMeasurementLocation.Key + ". " + sizeChart.objMeasurementLocation.Name + "</td>";
                    //}

                    //if (sizeChart.Val > 0)
                    //{
                    if (tbodyOnly)
                    {
                        records += "<td>" + sizeChart.objMeasurementLocation.Key + ". " + sizeChart.objMeasurementLocation.Name + "</td>";
                    }
                    else
                    {
                        style    = (alternativeRow) ? "#CCCCCC" : "#F5F5F5";
                        records += "<tr>";
                        records += "<td align=\"left\" bgcolor=" + style + " width=\"250\">" + sizeChart.objMeasurementLocation.Key + ". " + sizeChart.objMeasurementLocation.Name + "</td>";
                    }
                    //}

                    //foreach (var values in lstSizeChart.ToList())
                    //{
                    //    SizeChartBO objSizeChart = new SizeChartBO();
                    //    objSizeChart.Size = values.Size;

                    //    if ((lstSizeChart.Count != count) && (objSizeChart.SearchObjects().Where(o => o.Val == 0).Count() != objSizeChart.SearchObjects().Count()))
                    //    {
                    //        records += (convertType == "0") ? "<td align=\"center\" bgcolor=" + style + " style=\"width: 250px;\">" + Math.Round(Convert.ToDecimal(values.Val.ToString()), 0) + "</td>" :
                    //           "<td align=\"center\" bgcolor=" + style + " style=\"width: 250px;\">" +
                    //           Math.Round((values.Val * (decimal)0.39), 0) + "</td>";
                    //    }
                    //}
                    List <SizeChartBO> lstSizeChart = lstSizeCharts.Where(m => m.MeasurementLocation == sizeChart.MeasurementLocation).ToList();
                    foreach (var values in lstSizeChart.ToList())
                    {
                        //SizeChartBO objSizeChart = new SizeChartBO();
                        //objSizeChart.Size = values.Size;

                        //if ((lstSizeChart.Count != count) && (objSizeChart.SearchObjects().Where(o => o.Val == 0).Count() != objSizeChart.SearchObjects().Count()))
                        //{
                        //    records += (convertType == "0") ? "<td align=\"center\" bgcolor=" + style + " style=\"width: 250px;\">" + Math.Round(Convert.ToDecimal(values.Val.ToString()), 0) + "</td>" :
                        //       "<td align=\"center\" bgcolor=" + style + " style=\"width: 250px;\">" +
                        //       Math.Round((values.Val * (decimal)0.39), 0) + "</td>";
                        //}
                        //if (values.Val > 0)
                        //{
                        if (tbodyOnly)
                        {
                            records += "<td><label class=\"cm\">" + Math.Round(Convert.ToDecimal(values.Val.ToString()), 1).ToString() + "</label><label class=\"inches\">" + Math.Round((values.Val * (decimal)0.39), 1).ToString("0.0") + "</label></td>";
                        }
                        else
                        {
                            records += (convertType == "0") ? "<td align=\"center\" bgcolor=" + style + " style=\"width: 250px;\">" + Math.Round(Convert.ToDecimal(values.Val.ToString()), 1) + "</td>" :
                                       "<td align=\"center\" bgcolor=" + style + " style=\"width: 250px;\">" +
                                       Math.Round((values.Val * (decimal)0.39), 1) + "</td>";
                        }
                        //}
                    }

                    records       += "</tr>";
                    alternativeRow = !alternativeRow;
                }
                tbody       = tbody.Replace("<$records$>", records);
                garmentspec = garmentspec.Replace("<$records$>", records);
            }

            if (tbodyOnly)
            {
                return(tbody);
            }
            else
            {
                return(garmentspec);
            }
        }
 public string CreateHtml(PatternBO objPattern, string convertType, bool isAllSizes)
 {
     return(this.CreateHtml(objPattern, convertType, false, isAllSizes));
 }
        // 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);
        }
        private void GetDiffrenceGarmentSpec(int original, int compare)
        {
            PatternBO objOriPattern = new PatternBO();

            objOriPattern.ID = original;
            objOriPattern.GetObject();

            PatternBO objComPattern = new PatternBO();

            objComPattern.ID = compare;
            objComPattern.GetObject();

            List <SizeChartBO> lstDiffrence = new List <SizeChartBO>();

            List <SizeChartBO> lstOriSizeCharts = objOriPattern.SizeChartsWhereThisIsPattern;

            List <SizeChartBO> lstCComSizeCharts = objComPattern.SizeChartsWhereThisIsPattern;

            foreach (SizeChartBO osc in lstOriSizeCharts)
            {
                foreach (SizeChartBO csc in lstCComSizeCharts)
                {
                    if (osc.Size == csc.Size && osc.MeasurementLocation == csc.MeasurementLocation)
                    {
                        decimal difference = (osc.Val - csc.Val);

                        MeasurementLocationBO objM = new MeasurementLocationBO();
                        objM.ID = csc.MeasurementLocation;
                        objM.GetObject();

                        SizeBO objSize = new SizeBO();
                        objSize.ID = csc.Size;
                        objSize.GetObject();

                        SizeChartBO objSizeChart = new SizeChartBO();
                        objSizeChart.ID                     = 0;
                        objSizeChart.Pattern                = csc.Pattern;// Not necessary
                        objSizeChart.MeasurementLocation    = osc.MeasurementLocation;
                        objSizeChart.objPattern             = objComPattern;
                        objSizeChart.Size                   = csc.Size;
                        objSizeChart.objSize                = objSize;
                        objSizeChart.MeasurementLocation    = csc.MeasurementLocation;
                        objSizeChart.objMeasurementLocation = objM;
                        objSizeChart.Val                    = difference;

                        lstDiffrence.Add(objSizeChart);
                    }
                }
            }

            List <IGrouping <int, SizeChartBO> > lstSizeChartGroup = lstDiffrence.OrderBy(o => o.objMeasurementLocation.Key).GroupBy(o => o.MeasurementLocation).ToList();

            if (lstSizeChartGroup.Count > 0)
            {
                this.rptDiffSpecSizeQtyHeader.DataSource = (List <SizeChartBO>)lstSizeChartGroup[0].ToList();
                this.rptDiffSpecSizeQtyHeader.DataBind();

                this.rptDiffSpecML.DataSource = lstSizeChartGroup;
                this.rptDiffSpecML.DataBind();

                this.dvDiffrence.Visible = true;
            }
        }
        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/");
                }
            }
        }
        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;
            }
        }
        private void PopulateDataGrid()
        {
            // Hide Controls
            this.dvEmptyContent.Visible   = false;
            this.dvDataContent.Visible    = false;
            this.dvNoSearchResult.Visible = false;

            // Search text
            this.txtSearch.Value = this.QuerySearchText;
            string searchText = this.txtSearch.Value.ToLower().Trim();

            // Populate GSpecs

            int totalCount = 0;

            List <PatternBO> lstPattern = new List <PatternBO>();

            if (Source != null)
            {
                lstPattern = Source;
            }
            else
            {
                PatternBO objPattern = new PatternBO();
                objPattern.IsActiveWS = true;
                objPattern.IsActive   = true;

                if (this.QueryMainCategory > 0)
                {
                    objPattern.CoreCategory = QueryMainCategory;
                }

                switch (this.QueryCategory.ToLower())
                {
                case "mens":
                    objPattern.Gender   = 1;
                    objPattern.AgeGroup = 1;
                    lstPattern          = objPattern.SearchObjects().ToList();
                    break;

                case "ladies":
                    objPattern.Gender   = 2;
                    objPattern.AgeGroup = 1;
                    lstPattern          = objPattern.SearchObjects().ToList();
                    break;

                case "unisex":
                    objPattern.Gender = 3;
                    lstPattern        = objPattern.SearchObjects().ToList();
                    break;

                case "youth":
                    objPattern.AgeGroup = 2;
                    lstPattern          = objPattern.SearchObjects().ToList();
                    break;

                case "other":
                    lstPattern = objPattern.SearchObjects().Where(m => m.Gender > 3 || m.AgeGroup > 2).ToList();
                    break;

                default:
                    lstPattern = objPattern.SearchObjects().ToList();
                    break;
                }

                if (!string.IsNullOrEmpty(searchText))
                {
                    lstPattern = lstPattern.Where(m => (m.NickName.ToLower() + " " + m.Number.ToLower() + " " + m.objCoreCategory.Name.ToLower() + " " + (string.IsNullOrEmpty(m.Keywords) ? "" : m.Keywords.ToLower())).Contains(searchText)).ToList();
                }
                Source = lstPattern;
            }

            switch (this.SortBy)
            {
            case "Number":
                lstPattern = lstPattern.OrderBy(m => m.Number).ToList();
                break;

            case "Newest":
                lstPattern = lstPattern.OrderByDescending(m => m.ModifiedDate).ToList();
                break;

            case "CoreRange":
                lstPattern = lstPattern.OrderByDescending(m => m.IsCoreRange).ToList();
                break;

            //case "Popular":
            //    lstPattern = lstPattern.OrderBy(m => m.MostPopular ?? 0).ToList();
            //    break;
            //case "Rating":
            //    lstPattern = lstPattern.OrderBy(m => m.Ratings ?? 0).ToList();
            //    break;
            default:
                lstPattern = lstPattern.OrderByDescending(m => m.IsCoreRange).ToList();
                break;
            }

            totalCount = lstPattern.Count;
            int offSet = 0;

            if (lstPattern.Count > 0)
            {
                if (lstPattern.Count < (this.PageSize * 10))
                {
                    offSet = (this.Source.Count > this.PageSize) ? this.PageSize : this.Source.Count;
                }
                else
                {
                    offSet = ((this.Source.Count - ((this.PageNumber - 1) * this.PageSize)) > this.PageSize) ? this.PageSize : (this.Source.Count - ((this.PageNumber - 1) * this.PageSize));
                }

                int recordsLeft    = totalCount - (offSet * (this.PageNumber - 1));
                int nextFetchCount = (this.PageSize > recordsLeft) ? recordsLeft : this.PageSize;

                lstPattern = lstPattern.GetRange(offSet * (this.PageNumber - 1), nextFetchCount);
                this.rptGarmentSpecs.DataSource = lstPattern;
                this.rptGarmentSpecs.DataBind();

                Session["PatternView"] = lstPattern;

                TotalCount = (totalCount == 0) ? TotalCount : totalCount;

                Session["PageCount"] = (TotalCount % PageSize == 0) ? (TotalCount / PageSize) : ((TotalCount / PageSize) + 1);

                this.dvPagingFooter.Visible   = this.dvPagingHeader.Visible = (TotalCount > PageSize);
                this.lbFooterPrevious.Visible = (pageIndex != 1 && pageIndex != 90);
                this.ProcessNumbering(1, Convert.ToInt32(Session["PageCount"]));
                this.SetDisplayCount();
                this.dvDataContent.Visible = true;
            }
            else if ((searchText != string.Empty && searchText != "search"))
            {
                this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty);

                this.dvDataContent.Visible    = true;
                this.dvNoSearchResult.Visible = true;

                this.dvPagingFooter.Visible = this.dvPagingHeader.Visible = false;
            }
            else
            {
                this.dvEmptyContent.Visible = true;
                this.dvPagingFooter.Visible = this.dvPagingHeader.Visible = false;
            }

            this.rptGarmentSpecs.Visible = (lstPattern.Count > 0);
        }