//Модификация настройки в базе
        public bool ModifySetupApp(SetupApp setup, out string error)
        {
            error = string.Empty;
            if (conn == null)
            {
                error = "conn == null";
                return(false);
            }
            if (setup == null)
            {
                error = "setup == null";
                return(false);
            }
            SqlCommand command = new SqlCommand(spSetupAppUpdate, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Connection  = conn;
            command.Parameters.AddWithValue("@inSetupApp_Type", setup.SetupApp_Type);
            command.Parameters.AddWithValue("@inSetupApp_ValueDigit", setup.SetupApp_ValueDigit);
            command.Parameters.AddWithValue("@inSetupApp_ValueString", setup.SetupApp_ValueString);
            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        //Сохранение настройки указанного типа
        private bool SaveSetup(SetupAppRepository repository, SetupApp AddModifySetup, out string error)
        {
            error = string.Empty;
            SetupApp setup = repository.GetSetupById(AddModifySetup.SetupApp_Type, out error);

            if (error != string.Empty)
            {
                return(false);
            }
            if (setup != null)
            {
                setup.SetupApp_ValueDigit  = AddModifySetup.SetupApp_ValueDigit;
                setup.SetupApp_ValueString = AddModifySetup.SetupApp_ValueString;
                if (!repository.ModifySetupApp(setup, out error))
                {
                    return(false);
                }
            }
            else
            {
                setup = new SetupApp();
                setup.SetupApp_Type        = AddModifySetup.SetupApp_Type;
                setup.SetupApp_ValueDigit  = AddModifySetup.SetupApp_ValueDigit;
                setup.SetupApp_ValueString = AddModifySetup.SetupApp_ValueString;
                if (!repository.AddSetupApp(setup, out error))
                {
                    return(false);
                }
            }
            return(true);
        }
        public async void SaveConfig()
        {
            if (string.IsNullOrEmpty(this.Host))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Debe especificar una dirección IP",
                    "ok");

                return;
            }
            if (this.Port <= 0)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Escriba un puerto válido",
                    "ok");

                return;
            }
            if (string.IsNullOrEmpty(this.Maquina))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Escriba un número válido de máquina",
                    "ok");

                return;
            }
            if (await ValidateOptions())
            {
                int      respSetupApp, respSetupMain;
                SetupApp setupApp = new SetupApp();
                setupApp.Id              = 1;
                setupApp.IdApp           = 33;
                setupApp.IdMaquina       = Convert.ToInt32(this.Maquina);
                setupApp.IdHost          = this.Host;
                setupApp.IdPort          = Convert.ToInt32(this.Port);
                setupApp.IntranetRoomDig = this.Host + ":" + this.Port;
                respSetupApp             = await App.DatabaseSetUp.SaveItemAsync(setupApp);

                respSetupMain = await App.DatabaseSetUp.SaveListItemMainAsync(CsOptions);

                if (respSetupApp == 1 && respSetupMain > 0)
                {
                    await Application.Current.MainPage.DisplayAlert("MyOrder", "Operación exitosa, reinicie la aplicación", "Ok");

                    await Application.Current.MainPage.Navigation.PopAsync();
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Setup Alerta", "Imposible grabar", "ok");
                }
            }
        }
Exemplo n.º 4
0
        private async void CreateRegInitial(int id)
        {
            try
            {
                switch (id)
                {
                case 1:
                    SetupApp setupApp = new SetupApp();
                    setupApp.Id              = 0;
                    setupApp.IdApp           = 33;
                    setupApp.IdLugar         = 1;
                    setupApp.IdMaquina       = 1;
                    setupApp.IntranetRoomDig = string.IsNullOrEmpty(Application.Current.Resources["APISecurity"].ToString()) ? "192.168.0.2:49800" : Application.Current.Resources["APISecurity"].ToString();
                    await App.DatabaseSetUp.SaveItemAsync(setupApp);

                    break;

                case 2:
                    List <SetupMain> setupMains = new List <SetupMain>()
                    {
                        new SetupMain {
                            IdOption = 1, NameOption = "Cíclicos", IsMain = true, Icon = "Ic_scanner", IsVisible = true
                        },
                        new SetupMain {
                            IdOption = 2, NameOption = "Recibo de Mercancia", IsMain = false, Icon = "Ic_recibo", IsVisible = true
                        },
                        new SetupMain {
                            IdOption = 3, NameOption = "Inventario Periódico", IsMain = false, Icon = "Ic_conteo", IsVisible = true
                        },
                        new SetupMain {
                            IdOption = 4, NameOption = "Producto", IsMain = false, Icon = "Ic_crear", IsVisible = true
                        },
                        new SetupMain {
                            IdOption = -1, NameOption = "Configuración", IsMain = false, Icon = "Ic_config", IsVisible = true
                        },
                        new SetupMain {
                            IdOption = -2, NameOption = "Acerca de", IsMain = false, Icon = "Ic_acerca_de", IsVisible = true
                        },
                        new SetupMain {
                            IdOption = -3, NameOption = "Cerrar Sesión", IsMain = false, Icon = "Ic_cerrar_sesion", IsVisible = true
                        }
                    };
                    await App.DatabaseSetUp.SaveListItemMainAsync(setupMains);

                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Main CreateRegInitial", ex.ToString(), "Ok");
            }
        }
        //Зачитать все настройки
        public List <SetupApp> GetAllSetups(out string error)
        {
            error = string.Empty;
            List <SetupApp> setups = new List <SetupApp>();

            if (conn == null)
            {
                error = "conn == null";
                return(setups);
            }

            SqlCommand command = new SqlCommand(spSetupAppSelect, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Connection  = conn;
            SqlDataReader reader = null;

            try
            {
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    SetupApp addSetup = new SetupApp();
                    FillDataRec(reader, addSetup);
                    //for (int i = 0; i < reader.FieldCount; i++)
                    //{
                    //    switch (reader.GetName(i))
                    //    {
                    //        case "SetupApp_Type":
                    //            addSetup.SetupApp_Type = reader.GetInt32(i);
                    //            break;
                    //        case "SetupApp_ValueDigit":
                    //            addSetup.SetupApp_ValueDigit = reader.GetInt32(i);
                    //            break;
                    //        case "SetupApp_ValueString":
                    //            addSetup.SetupApp_ValueString = reader.GetString(i);
                    //            break;
                    //    }
                    //}
                    setups.Add(addSetup);
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(setups);
        }
Exemplo n.º 6
0
 public Task <int> SaveItemAsync(SetupApp item)
 {
     if (item.Id != 0)
     {
         return(database.UpdateAsync(item));
     }
     else
     {
         return(database.InsertAsync(item));
     }
 }
        //Получить настройку по id(типу)
        public SetupApp GetSetupById(int SetupApp_Type, out string error)
        {
            error = string.Empty;
            SetupApp resSetup = null;

            if (conn == null)
            {
                error = "conn == null";
                return(null);
            }
            SqlCommand command = new SqlCommand(spSetupAppSelect, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Connection  = conn;
            command.Parameters.AddWithValue("@inSetupApp_Type", SetupApp_Type);
            SqlDataReader reader = null;

            try
            {
                reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    resSetup = new SetupApp();
                    FillDataRec(reader, resSetup);
                    //for (int i = 0; i < reader.FieldCount; i++)
                    //{
                    //    switch (reader.GetName(i))
                    //    {
                    //        case "SetupApp_ValueDigit":
                    //            resSetup.SetupApp_ValueDigit = reader.GetInt32(i);
                    //            break;
                    //        case "SetupApp_ValueString":
                    //            resSetup.SetupApp_ValueString = reader.GetString(i);
                    //            break;
                    //    }
                    //}
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(resSetup);
        }
        private void FillDataRec(SqlDataReader reader, SetupApp setup)
        {
            int resInt = 0;

            if (int.TryParse(reader["SetupApp_Type"].ToString(), out resInt))
            {
                setup.SetupApp_Type = resInt;
            }
            if (int.TryParse(reader["SetupApp_ValueDigit"].ToString(), out resInt))
            {
                setup.SetupApp_ValueDigit = resInt;
            }
            setup.SetupApp_ValueString = reader["SetupApp_ValueString"].ToString();
        }
 public async void Instance()
 {
     try
     {
         SetupApp mySetUp = MainViewModel.GetInstance().mySetUpApp;
         CsOptions    = MainViewModel.GetInstance().MySetUpMain;
         this.Maquina = (mySetUp.IdMaquina).ToString();
         this.Host    = mySetUp.IdHost.ToString();
         this.Port    = mySetUp.IdPort;
     }
     catch (Exception ex)
     {
         await Application.Current.MainPage.DisplayAlert("Config Instance", ex.ToString(), "Ok");
     }
 }
Exemplo n.º 10
0
        private void SaveSetupsApp()
        {
            SetupProgram.PathToSQLFile            = txbSqlPath.Text;
            SetupProgram.PathToDBFFile            = txbDbfPath.Text;
            SetupProgram.IsNeedConvertCp1252To866 = cbConvertCp1252To866.Checked;
            SetupProgram.YearSalary = int.Parse(txbYear.Text);
            SetupProgram.CmpUSREOU  = tbCmpUSREOU.Text;
            SetupProgram.CmpNm      = tbCmpNm.Text;

            string             error;
            SetupAppRepository repository = new SetupAppRepository(SetupProgram.Connection);

            //Сохранение настройки "Путь к dbf файлу"
            if (dictMod[txbSqlPath] != txbSqlPath.Text)
            {
                SetupApp dbfSetup = new SetupApp
                {
                    SetupApp_Type        = (int)SetupAppType.PathToDBFFile,
                    SetupApp_ValueDigit  = 0,
                    SetupApp_ValueString = SetupProgram.PathToDBFFile
                };
                if (!SaveSetup(repository, dbfSetup, out error))
                {
                    MessageBox.Show("Помилка збереження налаштування 'Шлях до dbf файлів'.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
            }
            //Сохранение настройки "Путь к sql файлу"
            if (dictMod[txbSqlPath] != txbSqlPath.Text)
            {
                SetupApp sqlSetup = new SetupApp
                {
                    SetupApp_Type        = (int)SetupAppType.PathToSQLFile,
                    SetupApp_ValueDigit  = 0,
                    SetupApp_ValueString = SetupProgram.PathToSQLFile
                };
                if (!SaveSetup(repository, sqlSetup, out error))
                {
                    MessageBox.Show("Помилка збереження налаштування 'Шлях до sql файлів'.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
            }
            //Сохранение настройки "Конвертация текста (cp1252 -> cp866)"
            if (dictMod[cbConvertCp1252To866] != cbConvertCp1252To866.Checked.ToString())
            {
                SetupApp ConvertCpSetup = new SetupApp
                {
                    SetupApp_Type        = (int)SetupAppType.ConvertCp1252To866,
                    SetupApp_ValueDigit  = SetupProgram.IsNeedConvertCp1252To866 ? 1 : 0,
                    SetupApp_ValueString = string.Empty
                };
                if (!SaveSetup(repository, ConvertCpSetup, out error))
                {
                    MessageBox.Show("Помилка збереження налаштування 'Конвертація тексту (cp1252 -> cp866)'.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
            }
            //Сохранение настройки "Кількість років відображення РЛ"
            if (dictMod[txbYear] != txbYear.Text)
            {
                SetupApp ConvertCpSetup = new SetupApp
                {
                    SetupApp_Type        = (int)SetupAppType.YearSalary,
                    SetupApp_ValueDigit  = SetupProgram.YearSalary,
                    SetupApp_ValueString = string.Empty
                };
                if (!SaveSetup(repository, ConvertCpSetup, out error))
                {
                    MessageBox.Show("Помилка збереження налаштування 'Кількість років відображення РЛ'.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
            }
            //Сохранение настройки "ЕГРПОУ предприятия"
            if (dictMod[tbCmpUSREOU] != tbCmpUSREOU.Text)
            {
                SetupApp cmpUSREOU = new SetupApp
                {
                    SetupApp_Type        = (int)SetupAppType.CmpUSREOU,
                    SetupApp_ValueDigit  = 0,
                    SetupApp_ValueString = SetupProgram.CmpUSREOU
                };
                if (!SaveSetup(repository, cmpUSREOU, out error))
                {
                    MessageBox.Show("Помилка збереження налаштування 'ЄДРПОУ підприємства'.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
            }
            //Сохранение настройки "Название предприятия"
            if (dictMod[tbCmpNm] != tbCmpNm.Text)
            {
                SetupApp cmpNm = new SetupApp
                {
                    SetupApp_Type        = (int)SetupAppType.CmpNm,
                    SetupApp_ValueDigit  = 0,
                    SetupApp_ValueString = SetupProgram.CmpNm
                };
                if (!SaveSetup(repository, cmpNm, out error))
                {
                    MessageBox.Show("Помилка збереження налаштування 'Назва підприємства'.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
            }
        }
Exemplo n.º 11
0
 public Task <int> DeleteItemAsync(SetupApp item)
 {
     return(database.DeleteAsync(item));
 }