Пример #1
0
        public void Save_Contador(object sender, EventArgs e)
        {
            DataClasses1DataContext contador = new DataClasses1DataContext();

            TContadoresAgua tcounter = new TContadoresAgua();

            try
            {
                tcounter.SerialN = (int)txtSerial.Number;
                tcounter.Marca   = txtMarca.Text;
                tcounter.Modelo  = txtModelo.Text;

                #region ADD ID VALUE
                var query = (from c in contador.TContadoresAgua
                             select c);

                List <TContadoresAgua> listaValores = query.ToList <TContadoresAgua>();
                var maxID = 0;

                if (listaValores.Count != 0)
                {
                    maxID       = listaValores.Max(x => x.Id);
                    tcounter.Id = maxID++;
                    tcounter.Id = maxID++;
                }
                else
                {
                    maxID = 1;
                }
                #endregion


                #region check Serial
                var querydupli = (from c in contador.TContadoresAgua where c.SerialN == txtSerial.Number select c);
                List <TContadoresAgua> listaValoresdupli = querydupli.ToList <TContadoresAgua>();
                #endregion


                if (listaValoresdupli.Count == 0)
                {
                    var result = contador.GetTable <TContadoresAgua>(); // get table

                    result.InsertOnSubmit(tcounter);
                    contador.SubmitChanges();
                    // Response.Write("Saved Successfully...");

                    Store1.DataBind();
                    X.Msg.Notify("Line Saved Correctly At:", DateTime.Now.ToLongTimeString()).Show();
                    FormPanel1.Reset();
                }
                else
                {
                    X.Msg.Notify("Error Saving", "Serial Number Already exists!").Show();
                }
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }
Пример #2
0
        public void AfterEdit(JObject obj)
        {
            DataEntities ent = new DataEntities();

            var n = obj.ToObject <Voodoo.Basement.Message>();

            //n.Content = n.Content.AsciiToNative().HtmlDeCode();
            if (n.ID <= 0)
            {
                ent.AddToMessage(n);
            }
            else
            {
                var n_obj = (from l in ent.Message 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();

            StringBuilder sb = new StringBuilder();


            this.GridPanel1.Store.Primary.CommitChanges();
            this.BindData();
            TabPanel1.SetActiveTab(0);
            FormPanel1.Title = "新增";
            FormPanel1.Reset();
            X.Msg.Notify("消息", "保存成功!").Show();
        }
Пример #3
0
        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();
            }
        }
Пример #4
0
 protected void imgPay_Click(object sender, EventArgs e)
 {
     FormPanel1.Reset();
     window1.Show();
 }
Пример #5
0
 /// <summary>
 /// 京东收货确认
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnJDIsConfirm_Click(object sender, EventArgs e)
 {
     FormPanel1.Reset();
     window1.Show();
 }