public void Delete(Product product)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, product);
     }
 }
 public void Save(Product product)
 {
     using (DbManager db = new DbManager())
     {
         if (product.RecordNo != 0)
         {
             Accessor.Query.Update(db, product);
         }
         else
         {
             Accessor.Query.Insert(db, product);
         }
     }
 }
 protected void btnSaveUpdate_Click(object sender, EventArgs e)
 {
     product = PM.GetProductByKey(long.Parse(gvProductList.SelectedRow.Cells[2].Text));
     string StyleNumber, Description, ItemCode;
     StyleNumber = string.Concat(dlBrandUpdate.SelectedValue, "-", dlSexUpdate.SelectedValue, "-", this.rdioTopOrBottomUpdate.SelectedValue,
                                 "-", dlGarments.SelectedValue, "-", txtSKUBarcodeUpdate.Text);
     Description = string.Concat(dlBrandUpdate.SelectedValue, "-", dlCategoryUpdate.Text, "-", dlGarmentUpdate.SelectedValue);
     ItemCode = string.Concat(StyleNumber, "-", dlColorUpdate.SelectedValue, "-", dlSizeUpdate.SelectedValue);
     product.StyleNumber = StyleNumber;
     product.Description = Description;
     product.ItemCode = ItemCode;
     product.SKUBarcode = txtSKUBarcodeUpdate.Text;
     PM.Save(product);
     LoadAllProducts();
 }
        protected void btnSaveProductCategory_Click(object sender, EventArgs e)
        {
            string StyleNumber,Description,ItemCode;
            StyleNumber = string.Concat(dlBrands.SelectedValue, "-", dlSex.SelectedValue, "-", this.rdioTopOrBottom.SelectedValue,
                                        "-", dlGarments.SelectedValue, "-", txtSKUBarcode.Text);
            Description = string.Concat(dlBrands.SelectedValue, "-", dlCategory.Text, "-", dlGarments.SelectedValue);
            ItemCode = string.Concat(StyleNumber, "-", dlColors.SelectedValue, "-", dlSizes.SelectedValue);

            for(int i =1; i<=int.Parse(txtItems.Text); i++)
            {
                var product_category = new Product
                {
                    StyleNumber = StyleNumber,
                    Description = Description,
                    ItemCode = ItemCode,
                    DateCreated = DateTimeOffset.Now,
                    IsActive = "Yes",
                    SKUBarcode =(long.Parse(txtSKUBarcode.Text)+i).ToString()
                };
                PM.Save(product_category);
            }
            LoadAllProducts();
        }
 private List<Product> GetSelectedSKUToCancel()
 {
     List<Product> list = new List<Product>();
     foreach (GridViewRow row in this.gvSKUDetails.Rows)
     {
         CheckBox ck = ((CheckBox)row.FindControl("chkSKUs"));
         if (ck.Checked)
         {
             Product product = new Product();
             product.ItemCode = row.Cells[2].Text;
             product.SKUBarcode = row.Cells[3].Text;
             product.RecordNo = long.Parse(ck.Text);
             list.Add(product);
         }
         else
         {
             //Code if it is not checked ......may not be required
         }
     }
     return list;
 }
 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);
 }