Ejemplo n.º 1
0
 private void buttonManualConfigure_Click(object sender, EventArgs e)
 {
     this.SettingsLocationSettings = null;
     this.SettingsServerSettings   = null;
     EnableManualConfig            = true;
     this.Close();
 }
Ejemplo n.º 2
0
        public static LocationSettings GetLocationSettings(string DataSource, string Database, string User, string Password, string Location)
        {
            LocationSettings           Settings = null;
            SqlConnectionStringBuilder builder  = new SqlConnectionStringBuilder();

            builder.DataSource     = DataSource;
            builder.InitialCatalog = Database;
            builder.UserID         = User;
            builder.Password       = Password;
            using (SqlConnection connection = new SqlConnection(builder.ConnectionString)){
                SqlCommand Command = new SqlCommand(GET_LOCATION_SETTINGS, connection);
                Command.Parameters.AddWithValue("@loc_code", Location);
                try
                {
                    connection.Open();
                    using (SqlDataReader reader = Command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            Settings = new LocationSettings();
                            Settings.ServerAddress = reader.GetString(0);
                            Settings.Database      = reader.GetString(1);
                            Settings.User          = reader.GetString(2);
                            Settings.Password      = reader.GetString(3);
                        }
                    }
                }
                catch (Exception ex) { throw ex; }
                finally
                {
                    connection.Close();
                }
                return(Settings);
            }
        }
Ejemplo n.º 3
0
        public void Init()
        {
            LocationSettings           Settings = new LocationSettings();
            SqlConnectionStringBuilder builder  = new SqlConnectionStringBuilder();

            builder.DataSource     = this.ServerAddress;
            builder.InitialCatalog = this.Database;
            builder.UserID         = this.User;
            builder.Password       = this.Password;
            using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
            {
                SqlCommand Command = new SqlCommand(AppUpdator.Properties.Resources.INIT_SCRIPTS, connection);
                try
                {
                    connection.Open();
                    Command.Transaction = connection.BeginTransaction();
                    Command.ExecuteNonQuery();
                    Command.Transaction.Commit();
                }
                catch (Exception ex) {
                    Command.Transaction.Rollback();
                    MessageBox.Show("Error in Connection. "
                                    + Environment.NewLine
                                    + "Please Check the Error Message." + Environment.NewLine
                                    + "Please take a screen shot and send to System Administrator" + Environment.NewLine + Environment.NewLine
                                    + ex.Message, "Error Occurred");
                }
                connection.Close();
            }
        }
Ejemplo n.º 4
0
        public void UpdateWarrentySettings(List <XX_EXTENDED_SETTINGS> ExtendedWarrentySettings)
        {
            LocationSettings           Settings = new LocationSettings();
            SqlConnectionStringBuilder builder  = new SqlConnectionStringBuilder();

            builder.DataSource     = this.ServerAddress;
            builder.InitialCatalog = this.Database;
            builder.UserID         = this.User;
            builder.Password       = this.Password;
            using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
            {
                SqlCommand Command = new SqlCommand(AppUpdator.Properties.Resources.REMOVE_WARRENTY_SETTINGS, connection);
                try
                {
                    connection.Open();
                    Command.Transaction = connection.BeginTransaction();
                    Command.ExecuteNonQuery();
                    Command = new SqlCommand(INSERT_WARRENTY_SETTINGS, connection, Command.Transaction);
                    foreach (var wSetting in ExtendedWarrentySettings)
                    {
                        Command.Parameters.Clear();
                        Command.Parameters.AddWithValue("@WARRANTY_YEAR", wSetting.WARRANTY_YEAR.ToString());
                        Command.Parameters.AddWithValue("@DISCOUNT_PERCENTATE", wSetting.DISCOUNT_PERCENTATE.ToString());
                        Command.Parameters.AddWithValue("@BRAND", wSetting.BRAND.ToString());
                        //Command.Parameters.AddWithValue("@BRAND_NAME", wSetting.BRAND_NAME.ToString());
                        Command.Parameters.AddWithValue("@ITEMID", wSetting.ITEMID.ToString());
                        Command.ExecuteNonQuery();
                    }
                    Command.Transaction.Commit();
                }
                catch (Exception ex)
                {
                    if (Command.Transaction != null)
                    {
                        Command.Transaction.Rollback();
                    }
                    throw ex;
                }
            }
        }
Ejemplo n.º 5
0
 private void buttonCancel_Click(object sender, EventArgs e)
 {
     this.SettingsLocationSettings = null;
     this.SettingsServerSettings   = null;
     this.Close();
 }