Пример #1
0
        /// <summary>
        /// Add or Edit StoreProductInventory
        /// </summary>
        /// <param name="product"></param>
        public void SaveProductInventory(StoreProductInventory proInv)
        {
            using (CostarDataContext dc = _conn.GetContext())
            {
                if (proInv.InventoryID > 0)
                {
                    dc.StoreProductInventories.Attach(proInv, true);
                }
                if (proInv.InventoryID == 0)
                {
                    dc.StoreProductInventories.InsertOnSubmit(proInv);
                }
                dc.SubmitChanges();
            }

            //using (CostarDataContext linq = new CostarDataContext())
            //{
            //    if (proInv.InventoryID > 0)
            //    {
            //        StoreProductInventory inv = linq.StoreProductInventories.Where(c => c.InventoryID == proInv.InventoryID).SingleOrDefault();
            //        Common.CommonClass.CopyObjectProperty(proInv, inv);
            //    }
            //    else
            //    {
            //        linq.StoreProductInventories.InsertOnSubmit(proInv);
            //    }
            //    linq.SubmitChanges();
            //}
        }
Пример #2
0
 /// <summary>
 /// Delete StoreProductInventory
 /// </summary>
 /// <param name="product"></param>
 public void DelProductInventoryByProduct(long productID)
 {
     using (CostarDataContext linq = new CostarDataContext())
     {
         linq.StoreProductInventories.DeleteAllOnSubmit(linq.StoreProductInventories.Where(c => c.ProductID == productID));
         linq.SubmitChanges();
     }
 }
Пример #3
0
 public void DelProductColor(long productID)
 {
     using (CostarDataContext linq = new CostarDataContext())
     {
         linq.StoreProductColors.DeleteOnSubmit(linq.StoreProductColors.Where(c => c.ProductID == productID).Single());
         linq.SubmitChanges();
     }
 }
Пример #4
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            using (CostarDataContext linq = new CostarDataContext())
            {
                int ShippingOptionID = MyCommon.ToInt(Request["ShippingOptionID"]);

                StoreShippingOption shipping;
                if (this.HiddenField1.Value == "add")
                {
                    shipping = new StoreShippingOption();
                }
                else
                {
                    shipping = linq.StoreShippingOptions.Where(c => c.ShippingOptionID == ShippingOptionID).SingleOrDefault();
                }

                shipping.Name        = this.txt_Name.Text;
                shipping.Instruction = this.txt_Description.Text;
                shipping.IsActive    = this.CheckBox_Active.Checked;

                decimal price = 0;
                decimal.TryParse(this.txt_Price.Text, out price);

                switch (this.ddl_Per.SelectedValue)
                {
                case "0":
                    shipping.PerItemFlatRate  = price;
                    shipping.PerKGRate        = null;
                    shipping.PerOrderFlatRate = null;
                    break;

                case "1":
                    shipping.PerItemFlatRate  = null;
                    shipping.PerKGRate        = null;
                    shipping.PerOrderFlatRate = price;
                    break;

                case "2":
                    shipping.PerItemFlatRate  = null;
                    shipping.PerKGRate        = price;
                    shipping.PerOrderFlatRate = null;
                    break;
                }

                if (this.HiddenField1.Value == "add")
                {
                    linq.StoreShippingOptions.InsertOnSubmit(shipping);
                }

                linq.SubmitChanges();

                MyCommon.Alert("保存成功.", "StoreShippingManage.aspx");
            }
        }
Пример #5
0
 public void SaveProduct(StoreProduct product)
 {
     using (CostarDataContext dc = _conn.GetContext())
     {
         if (product.ProductID > 0)
         {
             dc.StoreProducts.Attach(product, true);
         }
         if (product.ProductID == 0)
         {
             product.AddeDate = DateTime.Now;
             dc.StoreProducts.InsertOnSubmit(product);
         }
         dc.SubmitChanges();
     }
 }