using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Globalization;
using Stimulsoft.Report.Dictionary;
using Stimulsoft.Report;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Rendering;

namespace Library_Red_Diamonds
{
    public partial class frmsetting : Form
    {
        static SqlConnection con = new SqlConnection(Connection.con);
        public frmsetting()
        {
            InitializeComponent();
        }

        SqlCommand cmd = new SqlCommand();

        private void changesetting()
        {
            cmd = new SqlCommand("EditSetting", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = con;
            cmd.Parameters.AddWithValue("@id", "1");
            cmd.Parameters.AddWithValue("@theme", cmb_theme.Text);
            cmd.Parameters.AddWithValue("@clockstyle", cmb_clock_style.Text);
            cmd.Parameters.AddWithValue("@bgclock", cmb_clock_bg.Text);
            cmd.Parameters.AddWithValue("@bgdate", cmb_date_bg.Text);
            cmd.Parameters.AddWithValue("@bginfo", cmb_info_bg.Text);
            cmd.Parameters.AddWithValue("@bgamar", cmb_amar_bg.Text);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            main main = (main)Application.OpenForms["main"];
            main.theme();
            main.loadinfo();
            main.clockstyle();
            main.bgclock();
            main.bgdate();
            main.bginfo();
            main.bgamar();
            this.Close();
        }

        private void loadsetting()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.Text;
            cmd.Connection = con;
            SqlDataReader Myreader;
            cmd.CommandText = "select * from setting";
            con.Open();
            Myreader = cmd.ExecuteReader();
            if (Myreader.Read())
            {
                cmb_theme.Text = Myreader["theme"].ToString();
                cmb_clock_style.Text = Myreader["clockstyle"].ToString();
                cmb_clock_bg.Text = Myreader["bgclock"].ToString();
                cmb_date_bg.Text = Myreader["bgdate"].ToString();
                cmb_info_bg.Text = Myreader["bginfo"].ToString();
                cmb_amar_bg.Text = Myreader["bgamar"].ToString();
            }
            Myreader.Close();
            con.Close();
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {
            changesetting();
        }

        private void frmsetting_Load(object sender, EventArgs e)
        {
            loadsetting();
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
