当前位置: 首页>>代码示例>>C#>>正文


C# DataEntities.AddToProduct方法代码示例

本文整理汇总了C#中Voodoo.Basement.DataEntities.AddToProduct方法的典型用法代码示例。如果您正苦于以下问题:C# DataEntities.AddToProduct方法的具体用法?C# DataEntities.AddToProduct怎么用?C# DataEntities.AddToProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Voodoo.Basement.DataEntities的用法示例。


在下文中一共展示了DataEntities.AddToProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AfterEdit

        public void AfterEdit(JObject obj)
        {
            DataEntities ent = new DataEntities();

            var n = obj.ToObject<Voodoo.Basement.Product>();
            //n.Content = n.Content.AsciiToNative().HtmlDeCode();
            if (n.ID <= 0)
            {
                ent.AddToProduct(n);
            }
            else
            {
                var n_obj = (from l in ent.Product where l.ID == n.ID select l).First();

                PropertyInfo[] ps = n.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
                foreach (PropertyInfo p in ps)
                {
                    object value = p.GetValue(n, null);
                    if (value == null)
                    {
                        continue;
                    }
                    try
                    {
                        p.SetValue(n_obj, value, null);
                    }
                    catch { }

                }

            }
            ent.SaveChanges();

            this.GridPanel1.Store.Primary.CommitChanges();
            this.BindData();
            TabPanel1.SetActiveTab(0);
            FormPanel1.Title = "新增";
            FormPanel1.Reset();
            X.Msg.Notify("消息", "保存成功!").Show();
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:40,代码来源:List.aspx.cs

示例2: Form_Save

        protected void Form_Save(object sender, DirectEventArgs e)
        {
            using (DataEntities ent = new DataEntities())
            {
                var n = new Voodoo.Basement.Product();
                try
                {
                    int id = ID.Text.ToInt32();
                    n = (from l in ent.Product where l.ID == id select l).First();
                }
                catch { }

                n.AddTime = AddTime.Value.ToDateTime();
                n.ClassID = ClassID.SelectedItem.Value.ToInt32();
                n.ClassName = ClassID.SelectedItem.Text;
                n.ClickCount = ClickCount.Value.ToInt32();
                n.Contact = Contact.Text;
                n.Enable = Enable.Checked;
                //n.FaceImage = "";

                n.Intro = Intro.Text;
                n.Name = Name.Text;
                n.OrderIndex = OrderIndex.Value.ToInt32();
                n.Price = Price.Value.ToDecimal();
                n.ProduceLocation = ProduceLocation.Text;
                n.SetTop = SetTop.Checked;
                n.Specification = Specification.Text;
                n.Tel = Tel.Text;
                n.Units = Units.Text;
                if (n.ID <= 0)
                {
                    ent.AddToProduct(n);
                }
                ent.SaveChanges();

                if (FaceImage.HasFile)
                {
                    Class cls = (from l in ent.Class where l.ID == n.ClassID select l).First();
                    string fileName = string.Format("/u/products/{0}.jpg", n.ID);
                    Voodoo.Basement.BasePage.UpLoadImage(FaceImage.PostedFile, fileName, cls.ImageWidth.ToInt32(), cls.ImageHeight.ToInt32());//194, 204
                    n.FaceImage = fileName;
                    ent.SaveChanges();
                }

                if (UpFile.HasFile)
                {
                    var files = from l in ent.File where l.ItemID == n.ID select l;
                    foreach (var f in files)
                    {
                        ent.DeleteObject(f);
                    }

                    string ext = UpFile.FileName.GetFileExtNameFromPath();
                    string fileName = string.Format("/u/products/{0}", UpFile.FileName);
                    Voodoo.Basement.BasePage.UpLoadFile(UpFile.PostedFile, fileName);

                    Voodoo.Basement.File file = new Voodoo.Basement.File();
                    file.ClassID = n.ClassID;
                    file.FileDirectory = "/u/products/";
                    file.FileExtName = ext;
                    file.FileName = UpFile.FileName;
                    file.FilePath = fileName;
                    file.FileSize = UpFile.PostedFile.ContentLength;
                    file.FileType = 0;
                    file.ItemID = n.ID;
                    file.SmallPath = "";
                    file.UpTime = DateTime.Now;
                    ent.AddToFile(file);
                    ent.SaveChanges();
                }

                this.GridPanel1.Store.Primary.CommitChanges();
                this.BindData();
                TabPanel1.SetActiveTab(0);
                FormPanel1.Title = "新增";
                FormPanel1.Reset();
                X.Msg.Notify("消息", "保存成功!").Show();

            }
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:80,代码来源:List.aspx.cs


注:本文中的Voodoo.Basement.DataEntities.AddToProduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。