private void GenerateItemCodeAndSKU()
 {
     List<Color> Style_Colors = new List<Color>();
     List<Size> Style_Sizes = new List<Size>();
     string CodeSeries = "";
     CodeSeries = hfStartSeries.Value;
     string BrandStartSeries = GetBrandStartSeries();
     int count = 0;
     for (int i = 0; i < ColorchkBxs.Items.Count; i++)
     {
         if (ColorchkBxs.Items[i].Selected)
         {
             ColorchkBxs.Items[i].Attributes.Add("style", "Font-weight:bold;");
             Style_Colors.Add(new Color { ColorCode = ColorchkBxs.Items[i].Value, ColorDescription = txtStyleDescription.Text });
             for (int j = 0; j < SizeschkBxs.Items.Count; j++)
             {
                 if (SizeschkBxs.Items[j].Selected)
                 {
                     SKU sku = new SKU();
                     count++;
                     string sn = "";
                     sku.ItemCode = txtStyleNumber.Text + "-" + ColorchkBxs.Items[i].Value + "-" + SizeschkBxs.Items[j].Value;
                     if (CodeSeries == START_CODE)
                     {
                         sn = (long.Parse(((BrandStartSeries) + CodeSeries)) +
                               Compute(SIZE_COUNT, COLOR_COUNT) + count).ToString();
                     }
                     else
                     {
                         sn = (long.Parse((CodeSeries)) +
                               Compute(SIZE_COUNT, COLOR_COUNT) + count).ToString();
                     }
                     sku.SKUNumber = (long.Parse(sn)).ToString();
                     sku.ItemColor = ColorchkBxs.Items[i].Text;
                     sku.ItemSize = SizeschkBxs.Items[j].Value;
                     sku.ItemBrand = dlBrandsForStyleNumber.SelectedItem.Text;
                     sku.ItemAPTYPE = rdioTopOrBottom.SelectedValue;
                     list.Add(sku);
                 }
             }
             COLOR_COUNT = COLOR_COUNT + 1;
         }
     }
     for (int j = 0; j < SizeschkBxs.Items.Count; j++)
     {
         if (SizeschkBxs.Items[j].Selected)
         {
             Style_Sizes.Add(new Size { SizeCode = SizeschkBxs.Items[j].Value });
         }
     }
     foreach (SKU sku in list)
     {
         decimal SRP = 0;
         if (txtSRP.Text != string.Empty)
         {
             SRP = decimal.Parse(txtSRP.Text);
         }
         var Product = new Product{
             Description = txtStyleDescription.Text,
             StyleNumber = txtStyleNumber.Text,
             ItemCode = sku.ItemCode,
             SKUBarcode = sku.SKUNumber,
             IsActive = "Yes",
             DateCreated = DateTime.Now ,
             Size = sku.ItemSize,
             AP_TYPE = sku.ItemAPTYPE ,
             Brand = sku.ItemBrand,
             Color = sku.ItemColor,
             SRP =SRP
         };
         PM.Save(Product);
     }
     StyleColorManager.Save(new ItemStyle { StyleNumber = txtStyleNumber.Text },Style_Colors);
     StyleSizeManager.Save(new ItemStyle { StyleNumber = txtStyleNumber.Text }, Style_Sizes);
 }
 private void PreviewGenerate()
 {
     string CodeSeries = "";
     CodeSeries = hfStartSeries.Value;
     string BrandStartSeries = GetBrandStartSeries();
     int count = 0;
     for (int i = 0; i < ColorchkBxs.Items.Count; i++)
     {
         if (ColorchkBxs.Items[i].Selected)
         {
             if (ColorchkBxs.Items[i].Text == "White")
             {
                 ColorchkBxs.Items[i].Attributes.Add("style", "Font-weight:bold;background-color:White; color:Black;");
             }
             else
             {
                 ColorchkBxs.Items[i].Attributes.Add("style", "Font-weight:bold;background-color:" + ColorchkBxs.Items[i].Text + "; color:White;");
             }
             for (int j = 0; j < SizeschkBxs.Items.Count; j++)
             {
                 if (SizeschkBxs.Items[j].Selected)
                 {
                     SKU sku = new SKU();
                     count++;
                     string sn = "";
                     sku.ItemCode = txtStyleNumber.Text + "-" + ColorchkBxs.Items[i].Value + "-" + SizeschkBxs.Items[j].Value;
                     if (CodeSeries == START_CODE)
                     {
                         sn = (long.Parse(((BrandStartSeries) + CodeSeries)) +
                               Compute(SIZE_COUNT, COLOR_COUNT) + count).ToString();
                     }
                     else
                     {
                         sn = (long.Parse((CodeSeries)) +
                               Compute(SIZE_COUNT, COLOR_COUNT) + count).ToString();
                     }
                     sku.SKUNumber = (long.Parse(sn)).ToString();
                     sku.ItemColor = ColorchkBxs.Items[i].Text;
                     sku.ItemSize = SizeschkBxs.Items[j].Text;
                     sku.ItemBrand = dlBrandsForStyleNumber.SelectedItem.Text;
                     sku.ItemAPTYPE = rdioTopOrBottom.SelectedValue;
                     list.Add(sku);
                 }
             }
             COLOR_COUNT = COLOR_COUNT + 1;
         }
     }
     for (int i = 0; i < SizeschkBxs.Items.Count; i++)
     {
         if (SizeschkBxs.Items[i].Selected)
         {
             SizeschkBxs.Items[i].Attributes.Add("style", "Font-weight:bold;");
             SIZE_COUNT = SIZE_COUNT + 1;
         }
     }
     rptrSKU.DataSource = list;
     rptrSKU.DataBind();
 }
 private void PreviewGenerate()
 {
     string CodeSeries = "";
     CodeSeries = hfStartSeries.Value;
     string BrandStartSeries =  hfBrandStartSeries.Value;
     int count = 0;
     for (int i = 0; i < ColorchkBxs.Items.Count; i++)
     {
         if (ColorchkBxs.Items[i].Selected)
         {
             if (ColorchkBxs.Items[i].Text == "White")
             {
                 ColorchkBxs.Items[i].Attributes.Add("style", "Font-weight:bold;background-color:White; color:Black;");
             }
             else
             {
                 ColorchkBxs.Items[i].Attributes.Add("style", "Font-weight:bold;background-color:" + ColorchkBxs.Items[i].Text + "; color:White;");
             }
             for (int j = 0; j < SizeschkBxs.Items.Count; j++)
             {
                 if (SizeschkBxs.Items[j].Selected)
                 {
                     SKU sku = new SKU();
                     count++;
                     string sn = "";
                     sku.ItemCode = txtStyleNumber.Text + "-" + ColorchkBxs.Items[i].Value + "-" + SizeschkBxs.Items[j].Value;
                     if (CodeSeries == START_CODE)
                     {
                         sn = (long.Parse(((BrandStartSeries) + CodeSeries)) +
                               Compute(SIZE_COUNT, COLOR_COUNT) + count).ToString();
                     }
                     else
                     {
                         sn = (long.Parse((CodeSeries)) +
                               Compute(SIZE_COUNT, COLOR_COUNT) + count).ToString();
                     }
                     sku.SKUNumber = (long.Parse(sn)).ToString();
                     list.Add(sku);
                 }
             }
             COLOR_COUNT = COLOR_COUNT + 1;
         }
     }
     for (int i = 0; i < SizeschkBxs.Items.Count; i++)
     {
         if (SizeschkBxs.Items[i].Selected)
         {
             SizeschkBxs.Items[i].Attributes.Add("style", "Font-weight:bold;");
             SIZE_COUNT = SIZE_COUNT + 1;
         }
     }
     if (CheckIfGeneratedIsExisted(list) == true)
     {
         lblErrorGenerated.Text = "WARNING: SOME GENERATED ITEM IS ALREADY CREATED!" +"\n" +"PLEASE REFER FROM ABOVE LIST!";
         pnlError.Visible = true;
         btnGenerate.Enabled = false;
         return;
     }
     else
     {
         lblErrorGenerated.Text = string.Empty;
         pnlError.Visible = false;
         btnGenerate.Enabled = true;
     }
     this.Repeater1.DataSource = list;
     Repeater1.DataBind();
 }