Пример #1
0
 partial void DeleteTGateways(TGateways instance);
Пример #2
0
 partial void InsertTGateways(TGateways instance);
Пример #3
0
 partial void UpdateTGateways(TGateways instance);
Пример #4
0
        public void Save_GW(object sender, EventArgs e)
        {
            DataClasses1DataContext contador = new DataClasses1DataContext();

            TGateways tGateway = new TGateways();

            try
            {
                tGateway.SerialNumber = (int)txtSerialGW.Number;
                tGateway.Marca        = txtMarcaGW.Text;
                tGateway.Modelo       = txtModeloGW.Text;
                tGateway.IP           = txtIPGW.Text;
                tGateway.Puerto       = txtPuertoGW.Text;

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

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

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

                #endregion

                #region check Serial

                var querydupli = (from c in contador.TGateways where c.SerialNumber == txtSerialGW.Number select c);
                List <TGateways> listaValoresdupli = querydupli.ToList <TGateways>();

                #endregion

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

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

                    Store3.DataBind();
                    X.Msg.Notify("Line Saved Correctly At:", DateTime.Now.ToLongTimeString()).Show();
                    FormPanel3.Reset();
                }
                else
                {
                    X.Msg.Notify("Error Saving", "Serial Number Already exists!").Show();
                }
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }