using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using CommonLayer;
using mgh;

namespace Grocery
{
    public partial class FrmSetting : Form
    {
        public FrmSetting()
        {
            InitializeComponent();

        }

        private void FrmSetting_Load(object sender, EventArgs e)
        {
            try
            {
                Settings.LoadSettings();
                txtcon.Text = Settings.ConnectionString;
                txtname.Text = Settings.Name;
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ex.Message, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }

        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                Settings.WriteSettings(txtcon.Text, txtname.Text);
                Settings.LoadSettings();
                txtcon.Text = Settings.ConnectionString;
                txtname.Text = Settings.Name;
                FarsiMessagbox.Show("تنظیمات ذخیره شد", "تنظیمات", FMessageBoxButtons.Ok, FMessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ex.Message, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
    }
}
