Beispiel #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();
            }
        }
Beispiel #2
0
 partial void DeleteTContadoresAgua(TContadoresAgua instance);
Beispiel #3
0
 partial void UpdateTContadoresAgua(TContadoresAgua instance);
Beispiel #4
0
 partial void InsertTContadoresAgua(TContadoresAgua instance);