예제 #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>
        /// Get StoreProductInventory By InventoryID
        /// </summary>
        /// <param name="productID"></param>
        /// <returns></returns>
        public StoreProductInventory GetInventoryByInventoryID(long inventoryID)
        {
            StoreProductInventory result = null;

            using (CostarDataContext linq = new CostarDataContext())
            {
                linq.ObjectTrackingEnabled = false;
                result = linq.StoreProductInventories.Where(p => p.InventoryID == inventoryID).SingleOrDefault();
            }
            return(result);
        }
예제 #3
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            if (rpt_list.Items.Count == 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('无数据无法保存.');</script>");
                return;
            }

            foreach (RepeaterItem item in rpt_list.Items)
            {
                HiddenField           invId = (HiddenField)item.FindControl("HiddenField_InventoryID");
                StoreProductInventory inv   = _StoreProductInventoy.GetInventoryByInventoryID(MyCommon.ToInt(invId.Value));

                DropDownList SVTO1 = (DropDownList)item.FindControl("ddl_SVTO1");
                if (SVTO1.SelectedItem != null)
                {
                    inv.Variant1OptionID = MyCommon.ToInt(SVTO1.SelectedItem.Value);
                }
                else
                {
                    inv.Variant1OptionID = null;
                }

                DropDownList SVTO2 = (DropDownList)item.FindControl("ddl_SVTO2");
                if (SVTO2.SelectedItem != null)
                {
                    inv.Variant2OptionID = MyCommon.ToInt(SVTO2.SelectedItem.Value);
                }
                else
                {
                    inv.Variant2OptionID = null;
                }

                TextBox QtyAvail = (TextBox)item.FindControl("txt_QtyAvail");
                inv.QtyAvail = MyCommon.ToInt(QtyAvail.Text);

                TextBox SortOrder = (TextBox)item.FindControl("txt_SortOrder");
                inv.SortOrder = MyCommon.ToInt(SortOrder.Text);

                Label QtySold = (Label)item.FindControl("lbl_QtySold");
                inv.QtySold = MyCommon.ToInt(QtySold.Text);

                Label QtyOnHold = (Label)item.FindControl("lbl_QtyOnHold");
                inv.QtyOnHold = MyCommon.ToInt(QtyOnHold.Text);

                _StoreProductInventoy.SaveProductInventory(inv);
            }

            ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('保存成功.');location.href='ProductList.aspx';</script>");
        }
예제 #4
0
        protected void btn_add_Click(object sender, EventArgs e)
        {
            int addcount = MyCommon.ToInt(this.ddl_count.Value);

            for (int i = 0; i < addcount; i++)
            {
                StoreProductInventory inv = new StoreProductInventory();

                inv.ProductID = long.Parse(this.HiddenField_proId.Value);
                inv.QtyAvail  = 0;
                inv.QtySold   = 0;
                inv.QtyOnHold = 0;
                inv.SortOrder = 0;
                inv.QtyAvail  = 0;

                _StoreProductInventoy.SaveProductInventory(inv);
            }

            BindRepeater(MyCommon.ToInt(this.HiddenField_proId.Value));
        }
예제 #5
0
        protected void btn_add_Click(object sender, EventArgs e)
        {
            int addcount = MyCommon.ToInt(this.ddl_count.Value);

            for (int i = 0; i < addcount; i++)
            {
                StoreProductInventory inv = new StoreProductInventory();

                inv.ProductID = long.Parse(this.HiddenField_proId.Value);
                inv.QtyAvail = 0;
                inv.QtySold = 0;
                inv.QtyOnHold = 0;
                inv.SortOrder = 0;
                inv.QtyAvail = 0;

                _StoreProductInventoy.SaveProductInventory(inv);
            }

            BindRepeater(MyCommon.ToInt(this.HiddenField_proId.Value));
        }
예제 #6
0
        protected void btn_continue_Click(object sender, EventArgs e)
        {
            if (!this.ProductYes.Checked && !this.ProductNo.Checked)
            {
                MyCommon.Alert("请选择产品属性.");
                return;
            }
            if (this.ProductYes.Checked)
            {
                int Variant1 = MyCommon.ToInt(this.ddl_Vaiant1.SelectedValue);
                int Variant2 = MyCommon.ToInt(this.ddl_Vaiant2.SelectedValue);

                if (Variant1 == 0 && Variant2 == 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('请选择属性.');</script>");
                    return;
                }
                if (_StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value)).Variant1TypeID == Variant1 &&
                    _StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value)).Variant2TypeID == Variant2)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('选择的属性与现有属性相同,请重新选择.');</script>");
                    return;
                }
                if (Variant1 == Variant2)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('选择的两种属性相同,请重新选择.');</script>");
                    return;
                }
                if (Variant1 > 0)
                {
                    if (_StoreVariantTypeOptions.GetStoreVariantTypeOptionByVariantTypeID(Variant1).Count == 0)
                    {
                        string name = _StoreVariantTypes.GetStoreVariantTypeByID(Variant1).GroupName;
                        ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('属性1[" + name + "]中无数据,请添加.');</script>");
                        VaiantNo.Style.Value   = "display: none;";
                        VaiantYes.Style.Value  = "display: block;";
                        div_detail.Style.Value = "display: block;";
                        return;
                    }
                }
                if (Variant2 > 0)
                {
                    if (_StoreVariantTypeOptions.GetStoreVariantTypeOptionByVariantTypeID(Variant2).Count == 0)
                    {
                        string name = _StoreVariantTypes.GetStoreVariantTypeByID(Variant2).GroupName;
                        ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('属性2[" + name + "]中无数据,请添加.');</script>");
                        VaiantNo.Style.Value   = "display: none;";
                        VaiantYes.Style.Value  = "display: block;";
                        div_detail.Style.Value = "display: block;";
                        return;
                    }
                }
            }

            StoreProductInventory inv = new StoreProductInventory();

            inv.ProductID = MyCommon.ToLong(this.HiddenField_proId.Value);
            inv.QtyAvail  = 0;
            inv.QtySold   = 0;
            inv.QtyOnHold = 0;
            inv.SortOrder = 0;

            if (this.ProductNo.Checked)
            {
                _StoreProductInventoy.DelProductInventoryByProduct(MyCommon.ToLong(this.HiddenField_proId.Value));

                inv.QtyAvail = MyCommon.ToInt(this.ProductNum.Text);
                _StoreProductInventoy.SaveProductInventory(inv);

                StoreProduct product = _StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value));
                product.Variant1TypeID = null;
                product.Variant2TypeID = null;
                _StoreProduct.SaveProduct(product);
                MyCommon.Alert("保存库存数量成功.", "ProductList.aspx");
            }

            if (this.ProductYes.Checked)
            {
                int Variant1 = MyCommon.ToInt(this.ddl_Vaiant1.SelectedValue);
                int Variant2 = MyCommon.ToInt(this.ddl_Vaiant2.SelectedValue);

                //当修改一个属性,清空库存
                if (_StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value)).Variant1TypeID != Variant1 ||
                    _StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value)).Variant2TypeID != Variant2)
                {
                    _StoreProductInventoy.DelProductInventoryByProduct(MyCommon.ToLong(this.HiddenField_proId.Value));
                }
                _StoreProductInventoy.SaveProductInventory(inv);

                StoreProduct product = _StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value));
                if (Variant1 == 0)
                {
                    product.Variant1TypeID = null;
                }
                else
                {
                    product.Variant1TypeID = Variant1;
                }
                if (Variant2 == 0)
                {
                    product.Variant2TypeID = null;
                }
                else
                {
                    product.Variant2TypeID = Variant2;
                }
                _StoreProduct.SaveProduct(product);

                ShowVariant(Variant1, Variant2);
                BindRepeater(MyCommon.ToInt(this.HiddenField_proId.Value));

                VaiantNo.Style.Value  = "display: none;";
                VaiantYes.Style.Value = "display: block;";
                ProductNum.Text       = "0";
            }
        }
예제 #7
0
        protected void btn_continue_Click(object sender, EventArgs e)
        {
            if (!this.ProductYes.Checked && !this.ProductNo.Checked)
            {
                MyCommon.Alert("请选择产品属性.");
                return;
            }
            if (this.ProductYes.Checked)
            {
                int Variant1 = MyCommon.ToInt(this.ddl_Vaiant1.SelectedValue);
                int Variant2 = MyCommon.ToInt(this.ddl_Vaiant2.SelectedValue);

                if (Variant1 == 0 && Variant2 == 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('请选择属性.');</script>");
                    return;
                }
                if (_StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value)).Variant1TypeID == Variant1 &&
                    _StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value)).Variant2TypeID == Variant2)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('选择的属性与现有属性相同,请重新选择.');</script>");
                    return;
                }
                if(Variant1==Variant2)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('选择的两种属性相同,请重新选择.');</script>");
                    return;
                }
                if (Variant1 > 0)
                {
                    if (_StoreVariantTypeOptions.GetStoreVariantTypeOptionByVariantTypeID(Variant1).Count == 0)
                    {
                        string name = _StoreVariantTypes.GetStoreVariantTypeByID(Variant1).GroupName;
                        ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('属性1[" + name + "]中无数据,请添加.');</script>");
                        VaiantNo.Style.Value = "display: none;";
                        VaiantYes.Style.Value = "display: block;";
                        div_detail.Style.Value = "display: block;";
                        return;
                    }
                }
                if (Variant2 > 0)
                {
                    if (_StoreVariantTypeOptions.GetStoreVariantTypeOptionByVariantTypeID(Variant2).Count == 0)
                    {
                        string name = _StoreVariantTypes.GetStoreVariantTypeByID(Variant2).GroupName;
                        ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script type='text/javascript'>alert('属性2[" + name + "]中无数据,请添加.');</script>");
                        VaiantNo.Style.Value = "display: none;";
                        VaiantYes.Style.Value = "display: block;";
                        div_detail.Style.Value = "display: block;";
                        return;
                    }
                }
            }

            StoreProductInventory inv = new StoreProductInventory();
            inv.ProductID = MyCommon.ToLong(this.HiddenField_proId.Value);
            inv.QtyAvail = 0;
            inv.QtySold = 0;
            inv.QtyOnHold = 0;
            inv.SortOrder = 0;

            if (this.ProductNo.Checked)
            {
                _StoreProductInventoy.DelProductInventoryByProduct(MyCommon.ToLong(this.HiddenField_proId.Value));

                inv.QtyAvail = MyCommon.ToInt(this.ProductNum.Text);
                _StoreProductInventoy.SaveProductInventory(inv);

                StoreProduct product = _StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value));
                product.Variant1TypeID = null;
                product.Variant2TypeID = null;
                _StoreProduct.SaveProduct(product);
                MyCommon.Alert("保存库存数量成功.", "ProductList.aspx");
            }

            if (this.ProductYes.Checked)
            {
                int Variant1 = MyCommon.ToInt(this.ddl_Vaiant1.SelectedValue);
                int Variant2 = MyCommon.ToInt(this.ddl_Vaiant2.SelectedValue);

                //当修改一个属性,清空库存
                if (_StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value)).Variant1TypeID != Variant1 ||
                    _StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value)).Variant2TypeID != Variant2)
                {
                    _StoreProductInventoy.DelProductInventoryByProduct(MyCommon.ToLong(this.HiddenField_proId.Value));
                }
                _StoreProductInventoy.SaveProductInventory(inv);

                StoreProduct product = _StoreProduct.GetProductByID(MyCommon.ToLong(this.HiddenField_proId.Value));
                if (Variant1 == 0) product.Variant1TypeID = null;
                else product.Variant1TypeID = Variant1;
                if (Variant2 == 0) product.Variant2TypeID = null;
                else product.Variant2TypeID = Variant2;
                _StoreProduct.SaveProduct(product);

                ShowVariant(Variant1, Variant2);
                BindRepeater(MyCommon.ToInt(this.HiddenField_proId.Value));

                VaiantNo.Style.Value = "display: none;";
                VaiantYes.Style.Value = "display: block;";
                ProductNum.Text = "0";
            }
        }