示例#1
0
        private void Dashboard_Load(object sender, EventArgs e)
        {
            //PrintReceiptPage(sender, e);
            String              xDate          = DateTime.Now.ToString("yyyy-MM-dd");
            DatabaseConnection  xDb            = new DatabaseConnection();
            Backup              xBackUp        = new Backup();
            ConfigResponseModel configResponse = xDb.GetConfig();

            xBackUp.BackUpDatabase(configResponse.BackUpPath);
            BackUpResponseModel backupResponse = xDb.GetBackUpHistory(xDate);

            if (backupResponse.BackUpPath == null)
            {
                string xQry = "insert into backup (date,path) " +
                              " values('" + xDate + "','" + configResponse.BackUpPath.Replace("\\", "\\\\") + "')";
                xDb.DataProcess(xQry);
            }
        }
        public BackUpResponseModel GetBackUpHistory(string xDate)
        {
            BackUpResponseModel model = new BackUpResponseModel();

            using (connection = new MySqlConnection(conString))
            {
                string xQry = "select * from backup where date='" + xDate + "'";
                connection.Open();
                MySqlCommand comm = new MySqlCommand(xQry, connection);

                MySqlDataReader reader = comm.ExecuteReader();

                while (reader.Read())
                {
                    model = new BackUpResponseModel()
                    {
                        Date       = reader.GetDateTime("date"),
                        BackUpPath = reader.GetString("path")
                    };
                }
                connection.Close();
            }
            return(model);
        }