/// <summary>
 /// Inserts the request to the database.
 /// </summary>
 private int InsertEntry()
 {
     dbman = new DBConnectionManager();
     //TODO
     try
     {
         string       recID = pmsutil.GenRecordID();
         MySqlCommand cmd   = dbman.DBConnect().CreateCommand();
         cmd.CommandText =
             "INSERT INTO records(record_id, book_number, page_number, entry_number, record_date, recordholder_fullname, parent1_fullname, parent2_fullname)" +
             "VALUES(@record_id, @book_number, @page_number, @entry_number, @record_date, @recordholder_fullname, @parent1_fullname, @parent2_fullname)";
         cmd.Prepare();
         cmd.Parameters.AddWithValue("@record_id", recID);
         cmd.Parameters.AddWithValue("@book_number", bookNum);
         cmd.Parameters.AddWithValue("@page_number", pageNum);
         cmd.Parameters.AddWithValue("@entry_number", entryNum);
         cmd.Parameters.AddWithValue("@record_date", marriageDate);
         cmd.Parameters.AddWithValue("@recordholder_fullname", fullName1);
         cmd.Parameters.AddWithValue("@parent1_fullname", parent1);
         cmd.Parameters.AddWithValue("@parent2_fullname", parent2);
         int stat_code = cmd.ExecuteNonQuery();
         dbman.DBClose();
         //Phase 2
         cmd             = dbman.DBConnect().CreateCommand();
         cmd.CommandText =
             "INSERT INTO matrimonial_records(record_id, recordholder2_fullname, parent1_fullname2, parent2_fullname2, status1, status2, age1, age2, place_of_origin1, place_of_origin2, residence1, residence2, witness1, witness2, witness1address, witness2address, stipend, minister, remarks)" +
             "VALUES(@record_id, @recordholder2_fullname, @parent1_fullname2, @parent2_fullname2, @status1, @status2, @age1, @age2, @place_of_origin1, @place_of_origin2, @residence1, @residence2, @witness1, @witness2, @witness1address, @witness2address, @stipend, @minister, @remarks)";
         cmd.Prepare();
         cmd.Parameters.AddWithValue("@record_id", recID);
         cmd.Parameters.AddWithValue("@recordholder2_fullname", fullName2);
         cmd.Parameters.AddWithValue("@parent1_fullname2", parent3);
         cmd.Parameters.AddWithValue("@parent2_fullname2", parent4);
         cmd.Parameters.AddWithValue("@status1", status1);
         cmd.Parameters.AddWithValue("@status2", status2);
         cmd.Parameters.AddWithValue("@age1", age1);
         cmd.Parameters.AddWithValue("@age2", age2);
         cmd.Parameters.AddWithValue("@place_of_origin1", hometown1);
         cmd.Parameters.AddWithValue("@place_of_origin2", hometown2);
         cmd.Parameters.AddWithValue("@residence1", residence1);
         cmd.Parameters.AddWithValue("@residence2", residence2);
         cmd.Parameters.AddWithValue("@witness1", sponsor1);
         cmd.Parameters.AddWithValue("@witness2", sponsor2);
         cmd.Parameters.AddWithValue("@witness1address", residence3);
         cmd.Parameters.AddWithValue("@witness2address", residence4);
         cmd.Parameters.AddWithValue("@stipend", stipend);
         cmd.Parameters.AddWithValue("@minister", minister);
         cmd.Parameters.AddWithValue("@remarks", remarks);
         stat_code = cmd.ExecuteNonQuery();
         dbman.DBClose();
         string tmp = pmsutil.LogRecord(recID, "LOGC-01");
         return(stat_code);
     }
     catch (MySqlException ex)
     {
         Console.WriteLine("Error: {0}", ex.ToString());
         return(0);
     }
 }
        private int PrintEntry()
        {
            string[] bspl  = MarriageDate.Text.Split('/');
            string   bsuff = GetDaySuffix(int.Parse(bspl[1]));
            string   bmon  = PrepMonth(int.Parse(bspl[0]));

            Document doc = new Document();

            doc.LoadFromFile("Data\\temp_marriage.docx");
            doc.Replace("name", FullName1.Text, true, true);
            doc.Replace("name2", FullName2.Text, true, true);
            doc.Replace("age", Age1.Value.ToString(), true, true);
            doc.Replace("age2", Age2.Value.ToString(), true, true);
            doc.Replace("nationality", "Filipino", true, true);
            doc.Replace("nationality2", "Filipino", true, true);
            doc.Replace("residence", Residence1.Text, true, true);
            doc.Replace("residence2", Residence2.Text, true, true);
            doc.Replace("civil", Status1.Text, true, true);
            doc.Replace("civil2", Status2.Text, true, true);
            doc.Replace("father", Parent1.Text, true, true);
            doc.Replace("father2", Parent3.Text, true, true);
            doc.Replace("mother", Parent2.Text, true, true);
            doc.Replace("mother2", Parent4.Text, true, true);
            doc.Replace("witness", Sponsor1.Text, true, true);
            doc.Replace("witness2", Sponsor2.Text, true, true);
            doc.Replace("place", "St. Raphael Parish", true, true);
            doc.Replace("date", bmon + " " + bspl[1] + bsuff + ", " + bspl[2], true, true);
            doc.Replace("priest", Minister.Text, true, true);
            doc.Replace("sign", Signatory.Text, true, true);
            //doc.Replace("no", EntryNum.Value.ToString(), true, true);
            doc.Replace("no", bookNum.ToString(), true, true);
            doc.Replace("page", PageNum.Value.ToString(), true, true);
            string[] date = DateTime.Now.ToStrin­g("MMMM,d,yyyy").Spl­it(',');
            doc.Replace("month", date[0], true, true);
            date[1] = date[1] + GetDaySuffix(int.Parse(date[1]));
            doc.Replace("days", date[1], true, true);
            doc.Replace("YY", date[2].Remove(0, 2), true, true);
            doc.SaveToFile("Data\\print.docx", FileFormat.Docx);

            //Load Document
            Document document = new Document();

            document.LoadFromFile(@"Data\\print.docx");

            //Convert Word to PDF
            document.SaveToFile("Output\\print_file.pdf", FileFormat.PDF);

            System.Diagnostics.Process.Start("Output\\print_file.pdf");

            string tmp = pmsutil.LogRecord(recordID, "LOGC-03");

            pmsutil.InsertTransaction("Matrimonial Cert.", "Unpaid", recordID, Convert.ToDouble(PrintingFee.Value));
            return(1);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Inserts the request to the database.
        /// </summary>
        private int PrintEntry()
        {
            string[] bspl = BurialDate.Text.Split('/');
            string   bmon = PrepMonth(int.Parse(bspl[0]));

            string[] dspl = DeathDate.Text.Split('/');
            string   dmon = PrepMonth(int.Parse(dspl[0]));

            Document doc = new Document();

            doc.LoadFromFile("Data\\temp_death.docx");
            doc.Replace("name", fullName, true, true);
            doc.Replace("age", Convert.ToString(age), true, true);
            doc.Replace("nationality", Nationality.Text, true, true);
            doc.Replace("residence", residence1, true, true);
            doc.Replace("civil", status, true, true);
            doc.Replace("father", p1, true, true);
            doc.Replace("mother", p2, true, true);
            doc.Replace("spouse", spouse, true, true);
            doc.Replace("date_of_birth", bmon + " " + bspl[1] + ", " + bspl[2], true, true);
            doc.Replace("cause_of_death", causeOfDeath, true, true);
            doc.Replace("date_of_burial", dmon + " " + dspl[1] + ", " + dspl[2], true, true);
            doc.Replace("place_of_burial", intermentPlace, true, true);
            doc.Replace("priest", minister, true, true);
            doc.Replace("sign", Signatory.Text, true, true);
            doc.Replace("no", Convert.ToString(entryNum), true, true);
            doc.Replace("page", Convert.ToString(pageNum), true, true);
            string[] date = DateTime.Now.ToString("MMMM,d,yyyy").Split(',');;
            doc.Replace("month", date[0], true, true);
            doc.Replace("day", date[1], true, true);
            doc.Replace("YY", date[2].Remove(0, 2), true, true);
            doc.SaveToFile("Data\\print.docx", FileFormat.Docx);

            //Load Document
            Document document = new Document();

            document.LoadFromFile(@"Data\\print.docx");

            //Convert Word to PDF
            document.SaveToFile("Output\\print_file.pdf", FileFormat.PDF);

            System.Diagnostics.Process.Start("Output\\print_file.pdf");

            //Reference
            string tmp = pmsutil.LogRecord(recordID, "LOGC-03");

            pmsutil.InsertTransaction("Burial Cert.", "Unpaid", recordID, Convert.ToDouble(PrintingFee.Value));
            return(1);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Inserts the request to the database.
 /// </summary>
 private int InsertEntry()
 {
     dbman = new DBConnectionManager();
     //TODO
     try
     {
         string       recID = pmsutil.GenRecordID();
         MySqlCommand cmd   = dbman.DBConnect().CreateCommand();
         cmd.CommandText =
             "INSERT INTO records(record_id, book_number, page_number, entry_number, record_date, recordholder_fullname, parent1_fullname, parent2_fullname)" +
             "VALUES(@record_id, @book_number, @page_number, @entry_number, @record_date, @recordholder_fullname, @parent1_fullname, @parent2_fullname)";
         cmd.Prepare();
         cmd.Parameters.AddWithValue("@record_id", recID);
         cmd.Parameters.AddWithValue("@book_number", bookNum);
         cmd.Parameters.AddWithValue("@page_number", pageNum);
         cmd.Parameters.AddWithValue("@entry_number", entryNum);
         cmd.Parameters.AddWithValue("@record_date", confirmationDate);
         cmd.Parameters.AddWithValue("@recordholder_fullname", fullName);
         cmd.Parameters.AddWithValue("@parent1_fullname", parent1);
         cmd.Parameters.AddWithValue("@parent2_fullname", parent2);
         int stat_code = cmd.ExecuteNonQuery();
         dbman.DBClose();
         //Phase 2
         cmd             = dbman.DBConnect().CreateCommand();
         cmd.CommandText =
             "INSERT INTO confirmation_records(record_id, age, parochia, province, place_of_baptism, sponsor, sponsor2, stipend, minister, remarks)" +
             "VALUES(@record_id, @age, @parish, @province, @place_of_baptism, @sponsor, @sponsor2, @stipend, @minister, @remarks)";
         cmd.Prepare();
         cmd.Parameters.AddWithValue("@record_id", recID);
         cmd.Parameters.AddWithValue("@age", age);
         cmd.Parameters.AddWithValue("@parish", parish);
         cmd.Parameters.AddWithValue("@province", province);
         cmd.Parameters.AddWithValue("@place_of_baptism", baptismPlace);
         cmd.Parameters.AddWithValue("@sponsor", sponsor1);
         cmd.Parameters.AddWithValue("@sponsor2", sponsor2);
         cmd.Parameters.AddWithValue("@stipend", stipend);
         cmd.Parameters.AddWithValue("@minister", minister);
         cmd.Parameters.AddWithValue("@remarks", remarks);
         stat_code = cmd.ExecuteNonQuery();
         dbman.DBClose();
         string tmp = pmsutil.LogRecord(recID, "LOGC-01");
         return(stat_code);
     }
     catch (MySqlException ex)
     {
         Console.WriteLine("Error: {0}", ex.ToString());
         return(0);
     }
 }
Ejemplo n.º 5
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                DataTable dt = new DataTable();
                dt = ((DataView)databap.ItemsSource).ToTable();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dbman   = new DBConnectionManager();
                    pmsutil = new PMSUtil();
                    using (conn = new MySqlConnection(dbman.GetConnStr()))
                    {
                        conn.Open();
                        if (conn.State == ConnectionState.Open)
                        {
                            bool doProceed = false;
                            //Check inputs
                            for (int _tmp = 0; _tmp < 12; _tmp++)
                            {
                                if (String.IsNullOrEmpty(dt.Rows[i][i].ToString()) == true)
                                {
                                    doProceed = false;
                                }
                                else
                                {
                                    doProceed = true;
                                }
                            }
                            if (doProceed == true)
                            {
                                App.Current.Dispatcher.Invoke((Action) delegate                                // <--- HERE
                                {
                                    PBar.Visibility         = Visibility.Visible;
                                    CancelButton1.IsEnabled = false;
                                    ConfirmBtn.IsEnabled    = false;

                                    string recID     = pmsutil.GenRecordID();
                                    MySqlCommand cmd = dbman.DBConnect().CreateCommand();
                                    cmd.CommandText  =
                                        "INSERT INTO records(record_id, book_number, page_number, entry_number, record_date, recordholder_fullname, parent1_fullname, parent2_fullname)" +
                                        "VALUES(@record_id, @book_number, @page_number, @entry_number, @record_date, @recordholder_fullname, @parent1_fullname, @parent2_fullname)";
                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@record_id", recID);
                                    cmd.Parameters.AddWithValue("@book_number", _bookNum);
                                    cmd.Parameters.AddWithValue("@page_number", PageNum.Value);
                                    cmd.Parameters.AddWithValue("@entry_number", Convert.ToInt32(dt.Rows[i][0].ToString()));
                                    cmd.Parameters.AddWithValue("@record_date", dt.Rows[i][1].ToString());
                                    cmd.Parameters.AddWithValue("@recordholder_fullname", dt.Rows[i][2].ToString());
                                    cmd.Parameters.AddWithValue("@parent1_fullname", dt.Rows[i][6].ToString());
                                    cmd.Parameters.AddWithValue("@parent2_fullname", dt.Rows[i][7].ToString());
                                    int stat_code = cmd.ExecuteNonQuery();
                                    dbman.DBClose();

                                    cmd             = dbman.DBConnect().CreateCommand();
                                    cmd.CommandText =
                                        "INSERT INTO baptismal_records(record_id, birthday, legitimacy, place_of_birth, sponsor1, sponsor2, stipend, minister, remarks)" +
                                        "VALUES(@record_id, @birthday, @legitimacy, @place_of_birth, @sponsor1, @sponsor2, @stipend, @minister, @remarks)";
                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@record_id", recID);
                                    cmd.Parameters.AddWithValue("@birthday", dt.Rows[i][3].ToString());
                                    cmd.Parameters.AddWithValue("@legitimacy", dt.Rows[i][4].ToString());
                                    cmd.Parameters.AddWithValue("@place_of_birth", dt.Rows[i][5].ToString());
                                    cmd.Parameters.AddWithValue("@sponsor1", dt.Rows[i][8].ToString());
                                    cmd.Parameters.AddWithValue("@sponsor2", dt.Rows[i][9].ToString());
                                    cmd.Parameters.AddWithValue("@stipend", Convert.ToDouble(dt.Rows[i][10].ToString()));
                                    cmd.Parameters.AddWithValue("@minister", dt.Rows[i][11].ToString());
                                    cmd.Parameters.AddWithValue("@remarks", dt.Rows[i][12].ToString());
                                    stat_code = cmd.ExecuteNonQuery();
                                    dbman.DBClose();
                                    string tmp = pmsutil.LogRecord(recID, "LOGC-01");
                                    //return stat_code;
                                    _statcode = stat_code;

                                    PBar.Visibility         = Visibility.Hidden;
                                    CancelButton1.IsEnabled = true;
                                    ConfirmBtn.IsEnabled    = true;
                                });
                            }
                            else
                            {
                                _statcode = 601;
                            }
                        }
                        else
                        {
                        }
                    }
                }
                this.Close();
            }
            catch
            {
            }
        }
        /// <summary>
        /// Inserts the request to the database.
        /// </summary>
        private int InsertEntry()
        {
            int ret = 0;

            dbman = new DBConnectionManager();
            using (conn = new MySqlConnection(dbman.GetConnStr()))
            {
                conn.Open();
                if (conn.State == ConnectionState.Open)
                {
                    using (MySqlConnection conn2 = new MySqlConnection(dbman.GetConnStr()))
                    {
                        conn2.Open();
                        MySqlCommand cmd = conn2.CreateCommand();
                        cmd.CommandText = "SELECT * FROM records, registers WHERE records.record_id = @rid AND records.book_number = registers.book_number LIMIT 1;";
                        cmd.Parameters.AddWithValue("@rid", recordID);
                        cmd.Prepare();
                        using (MySqlDataReader db_reader = cmd.ExecuteReader())
                        {
                            while (db_reader.Read())
                            {
                                if (db_reader.GetString("status") == "Archived")
                                {
                                    using (MySqlConnection conn3 = new MySqlConnection(dbman.GetConnStr()))
                                    {
                                        conn3.Open();
                                        try
                                        {
                                            MySqlCommand cmd2 = conn3.CreateCommand();
                                            cmd2.CommandText =
                                                "UPDATE records SET page_number = @page_number, entry_number = @entry_number, record_date = @record_date, recordholder_fullname = @recordholder_fullname, parent1_fullname = @parent1_fullname, parent2_fullname = @parent2_fullname WHERE record_id = @record_id;";
                                            cmd2.Parameters.AddWithValue("@record_id", recordID);
                                            cmd2.Parameters.AddWithValue("@page_number", pageNum);
                                            cmd2.Parameters.AddWithValue("@entry_number", entryNum);
                                            cmd2.Parameters.AddWithValue("@record_date", deathDate);
                                            cmd2.Parameters.AddWithValue("@recordholder_fullname", fullName);
                                            cmd2.Parameters.AddWithValue("@parent1_fullname", parent1);
                                            cmd2.Parameters.AddWithValue("@parent2_fullname", parent2);
                                            cmd2.Prepare();
                                            int stat_code = cmd2.ExecuteNonQuery();
                                            conn3.Close();

                                            conn3.Open();
                                            string path = @"\archive.db";
                                            pmsutil = new PMSUtil();
                                            if (pmsutil.CheckArchiveDrive(path) != "dc")
                                            {
                                                SQLiteConnectionStringBuilder connectionString = new SQLiteConnectionStringBuilder
                                                {
                                                    FailIfMissing = true,
                                                    DataSource    = pmsutil.CheckArchiveDrive(path)
                                                };

                                                //Copy the selected register's record to the archive drive
                                                using (SQLiteConnection connection = new SQLiteConnection(connectionString.ToString()))
                                                {
                                                    // open the connection:
                                                    connection.Open();

                                                    SQLiteCommand command = new SQLiteCommand(null, connection)
                                                    {
                                                        CommandText = "UPDATE burial_records SET burial_date = @burial_date, age = @age, status = @status, residence = @residence, residence2 = @residence2, sacrament = @sacrament, cause_of_death = @cause_of_death, place_of_interment = @place_of_interment, stipend = @stipend, minister = @minister, remarks = @remarks WHERE record_id = @record_id;"
                                                    };
                                                    command.Parameters.Add(new SQLiteParameter("@record_id", recordID));
                                                    command.Parameters.Add(new SQLiteParameter("@record_id", recordID));
                                                    command.Parameters.Add(new SQLiteParameter("@burial_date", burialDate));
                                                    command.Parameters.Add(new SQLiteParameter("@age", age));
                                                    command.Parameters.Add(new SQLiteParameter("@status", status));
                                                    command.Parameters.Add(new SQLiteParameter("@residence", residence1));
                                                    command.Parameters.Add(new SQLiteParameter("@residence2", residence2));
                                                    command.Parameters.Add(new SQLiteParameter("@sacrament", sacrament));
                                                    command.Parameters.Add(new SQLiteParameter("@cause_of_death", causeOfDeath));
                                                    command.Parameters.Add(new SQLiteParameter("@place_of_interment", intermentPlace));
                                                    command.Parameters.Add(new SQLiteParameter("@stipend", stipend));
                                                    command.Parameters.Add(new SQLiteParameter("@minister", minister));
                                                    command.Parameters.Add(new SQLiteParameter("@remarks", remarks));
                                                    // Call Prepare after setting the Commandtext and Parameters.
                                                    command.Prepare();
                                                    command.ExecuteNonQuery();
                                                }
                                            }
                                            else
                                            {
                                            }
                                            conn3.Close();
                                            string tmp = pmsutil.LogRecord(recordID, "LOGC-02");
                                        }
                                        catch (MySqlException ex)
                                        {
                                            Console.WriteLine("Error: {0}", ex.ToString());
                                            return(0);
                                        }
                                    }
                                }
                                else
                                {
                                    using (MySqlConnection conn3 = new MySqlConnection(dbman.GetConnStr()))
                                    {
                                        conn3.Open();
                                        try
                                        {
                                            string       recID = pmsutil.GenRecordID();
                                            MySqlCommand cmd2  = dbman.DBConnect().CreateCommand();
                                            cmd2.CommandText =
                                                "UPDATE records SET page_number = @page_number, entry_number = @entry_number, record_date = @record_date, recordholder_fullname = @recordholder_fullname, parent1_fullname = @parent1_fullname, parent2_fullname = @parent2_fullname WHERE record_id = @record_id;";
                                            cmd2.Prepare();
                                            cmd2.Parameters.AddWithValue("@record_id", recordID);
                                            cmd2.Parameters.AddWithValue("@page_number", pageNum);
                                            cmd2.Parameters.AddWithValue("@entry_number", entryNum);
                                            cmd2.Parameters.AddWithValue("@record_date", deathDate);
                                            cmd2.Parameters.AddWithValue("@recordholder_fullname", fullName);
                                            cmd2.Parameters.AddWithValue("@parent1_fullname", parent1);
                                            cmd2.Parameters.AddWithValue("@parent2_fullname", parent2);
                                            int stat_code = cmd2.ExecuteNonQuery();
                                            conn3.Close();

                                            conn3.Open();
                                            cmd2             = dbman.DBConnect().CreateCommand();
                                            cmd2.CommandText =
                                                "UPDATE burial_records SET burial_date = @burial_date, age = @age, status = @status, residence = @residence, residence2 = @residence2, sacrament = @sacrament, cause_of_death = @cause_of_death, place_of_interment = @place_of_interment, stipend = @stipend, minister = @minister, remarks = @remarks WHERE record_id = @record_id;";
                                            cmd2.Prepare();
                                            cmd2.Parameters.AddWithValue("@record_id", recordID);
                                            cmd2.Parameters.AddWithValue("@burial_date", burialDate);
                                            cmd2.Parameters.AddWithValue("@age", age);
                                            cmd2.Parameters.AddWithValue("@status", status);
                                            cmd2.Parameters.AddWithValue("@residence", residence1);
                                            cmd2.Parameters.AddWithValue("@residence2", residence2);
                                            cmd2.Parameters.AddWithValue("@sacrament", sacrament);
                                            cmd2.Parameters.AddWithValue("@cause_of_death", causeOfDeath);
                                            cmd2.Parameters.AddWithValue("@place_of_interment", intermentPlace);
                                            cmd2.Parameters.AddWithValue("@stipend", stipend);
                                            cmd2.Parameters.AddWithValue("@minister", minister);
                                            cmd2.Parameters.AddWithValue("@remarks", remarks);
                                            stat_code = cmd2.ExecuteNonQuery();
                                            conn3.Close();
                                            string tmp = pmsutil.LogRecord(recordID, "LOGC-02");
                                            return(stat_code);
                                        }
                                        catch (MySqlException ex)
                                        {
                                            Console.WriteLine("Error: {0}", ex.ToString());
                                            return(0);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return(ret);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Inserts the request to the database.
        /// </summary>
        private int InsertEntry()
        {
            dbman = new DBConnectionManager();
            using (conn = new MySqlConnection(dbman.GetConnStr()))
            {
                conn.Open();
                //TODO
                try
                {
                    string       recID = pmsutil.GenRecordID();
                    MySqlCommand cmd   = conn.CreateCommand();
                    cmd.CommandText =
                        "INSERT INTO records(record_id, book_number, page_number, entry_number, record_date, recordholder_fullname, parent1_fullname, parent2_fullname)" +
                        "VALUES(@record_id, @book_number, @page_number, @entry_number, @record_date, @recordholder_fullname, @parent1_fullname, @parent2_fullname)";
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@record_id", recID);
                    cmd.Parameters.AddWithValue("@book_number", bookNum);
                    cmd.Parameters.AddWithValue("@page_number", pageNum);
                    cmd.Parameters.AddWithValue("@entry_number", entryNum);
                    cmd.Parameters.AddWithValue("@record_date", deathDate);
                    cmd.Parameters.AddWithValue("@recordholder_fullname", fullName);
                    cmd.Parameters.AddWithValue("@parent1_fullname", parent1);
                    cmd.Parameters.AddWithValue("@parent2_fullname", parent2);
                    int stat_code = cmd.ExecuteNonQuery();
                    conn.Close();

                    conn.Open();
                    //Phase 2
                    cmd             = conn.CreateCommand();
                    cmd.CommandText =
                        "INSERT INTO burial_records(record_id, burial_date, age, status, residence, residence2, sacrament, cause_of_death, place_of_interment, stipend, minister, remarks)" +
                        "VALUES(@record_id, @burial_date, @age, @status, @residence, @residence2, @sacrament, @cause_of_death, @place_of_interment, @stipend, @minister, @remarks)";
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@record_id", recID);
                    cmd.Parameters.AddWithValue("@burial_date", burialDate);
                    cmd.Parameters.AddWithValue("@age", age);
                    cmd.Parameters.AddWithValue("@status", status);
                    cmd.Parameters.AddWithValue("@residence", residence1);
                    cmd.Parameters.AddWithValue("@residence2", residence2);
                    cmd.Parameters.AddWithValue("@sacrament", sacrament);
                    cmd.Parameters.AddWithValue("@cause_of_death", causeOfDeath);
                    cmd.Parameters.AddWithValue("@place_of_interment", intermentPlace);
                    cmd.Parameters.AddWithValue("@stipend", stipend);
                    cmd.Parameters.AddWithValue("@minister", minister);
                    cmd.Parameters.AddWithValue("@remarks", remarks);
                    stat_code = cmd.ExecuteNonQuery();
                    conn.Close();

                    conn.Open();
                    string dirID   = pmsutil.GenDirectoryID();
                    string block   = "Not Specified";
                    string lot     = "Not Specified";
                    string plot    = "Not Specified";
                    string rconnum = "Not Specified";
                    byte[] ImageData;
                    //Phase 3
                    if (!string.IsNullOrWhiteSpace(Block.Text))
                    {
                        block = Block.Text;
                    }
                    if (!string.IsNullOrWhiteSpace(Lot.Text))
                    {
                        lot = Lot.Text;
                    }
                    if (!string.IsNullOrWhiteSpace(Plot.Text))
                    {
                        plot = Plot.Text;
                    }
                    if (!string.IsNullOrWhiteSpace(RContactNo.Text))
                    {
                        rconnum = RContactNo.Text;
                    }
                    if (!string.IsNullOrWhiteSpace(imageURI))
                    {
                        FileStream   fs = new FileStream(imageURI, FileMode.Open, FileAccess.Read);
                        BinaryReader br = new BinaryReader(fs);
                        ImageData = br.ReadBytes((int)fs.Length);
                        br.Close();
                        fs.Close();
                    }
                    else
                    {
                        ImageData = null;
                    }
                    cmd             = conn.CreateCommand();
                    cmd.CommandText =
                        "INSERT INTO burial_directory(directory_id, record_id, block, lot, plot, gravestone, relative_contact_number)" +
                        "VALUES(@directory_id, @record_id, @block, @lot, @plot, @gravestone, @relative_contact_number)";
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@directory_id", dirID);
                    cmd.Parameters.AddWithValue("@record_id", recID);
                    cmd.Parameters.AddWithValue("@block", block);
                    cmd.Parameters.AddWithValue("@lot", lot);
                    cmd.Parameters.AddWithValue("@plot", plot);
                    cmd.Parameters.AddWithValue("@gravestone", ImageData);
                    cmd.Parameters.AddWithValue("@relative_contact_number", rconnum);
                    stat_code = cmd.ExecuteNonQuery();
                    conn.Close();

                    string tmp = pmsutil.LogRecord(recID, "LOGC-01");
                    return(stat_code);
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine("Error: {0}", ex.ToString());
                    return(0);
                }
            }
        }
Ejemplo n.º 8
0
        private void BatchPrint(object sender, DoWorkEventArgs e)
        {
            int    tick      = 0;
            int    total     = _items.Count;
            string signature = "";
            string purpose   = "";
            double fee       = 0d;

            App.Current.Dispatcher.Invoke((Action) delegate            // <--- HERE
            {
                QueueCounter.Content      = tick + "/" + total;
                QueuePBar.IsIndeterminate = true;

                signature = Signatory.Text;
                purpose   = Purpose.Text;
                fee       = Convert.ToDouble(PrintingFee.Value);
            });

            for (int i = 0; i < _items.Count; i++)
            {
                App.Current.Dispatcher.Invoke((Action) delegate                // <--- HERE
                {
                    QueueCounter.Content = tick + "/" + total;
                });
                RecordEntryMatrimonial recordx = (RecordEntryMatrimonial)_items[i];

                string[] bspl  = DateTime.Parse(recordx.MarriageDate + "," + recordx.MarriageYear).ToString("MM/dd/yyyy").Split('/');
                string   bsuff = GetDaySuffix(int.Parse(bspl[1]));
                string   bmon  = PrepMonth(int.Parse(bspl[0]));

                Document doc = new Document();
                doc.LoadFromFile("Data\\temp_marriage.docx");
                doc.Replace("name", recordx.FullName1, true, true);
                doc.Replace("name2", recordx.FullName2, true, true);
                doc.Replace("age", recordx.Age1.ToString(), true, true);
                doc.Replace("age2", recordx.Age2.ToString(), true, true);
                doc.Replace("nationality", "Filipino", true, true);
                doc.Replace("nationality2", "Filipino", true, true);
                doc.Replace("residence", recordx.Residence1, true, true);
                doc.Replace("residence2", recordx.Residence2, true, true);
                doc.Replace("civil", recordx.Status1, true, true);
                doc.Replace("civil2", recordx.Status2, true, true);
                doc.Replace("father", recordx.Parent1, true, true);
                doc.Replace("father2", recordx.Parent3, true, true);
                doc.Replace("mother", recordx.Parent2, true, true);
                doc.Replace("mother2", recordx.Parent4, true, true);
                doc.Replace("witness", recordx.Witness1, true, true);
                doc.Replace("witness2", recordx.Witness2, true, true);
                doc.Replace("place", "St. Raphael Parish", true, true);
                doc.Replace("date", bmon + " " + bspl[1] + bsuff + ", " + bspl[2], true, true);
                doc.Replace("priest", recordx.Minister, true, true);
                doc.Replace("sign", signature, true, true);
                doc.Replace("page", GetPNum(recordx.RecordID).ToString(), true, true);
                doc.Replace("no", GetBNum(recordx.RecordID).ToString(), true, true);
                string[] date = DateTime.Now.ToStrin­g("MMMM,d,yyyy").Spl­it(',');
                doc.Replace("month", date[0], true, true);
                date[1] = date[1] + GetDaySuffix(int.Parse(date[1]));
                doc.Replace("days", date[1], true, true);
                doc.Replace("YY", date[2].Remove(0, 2), true, true);
                doc.SaveToFile("Data\\print-" + i + ".docx", FileFormat.Docx);

                //Load Document
                Document document = new Document();
                document.LoadFromFile(@"Data\\print-" + i + ".docx");

                //Convert Word to PDF
                document.SaveToFile("Output\\print_file-" + i + ".pdf", FileFormat.PDF);

                App.Current.Dispatcher.Invoke((Action) delegate                // <--- HERE
                {
                    if (SkipPreview.IsChecked == true)
                    {
                        Spire.Pdf.PdfDocument docx = new Spire.Pdf.PdfDocument();
                        docx.LoadFromFile(@"Output\\print_file-" + i + ".pdf");
                        docx.PrintDocument.Print();
                    }
                    else
                    {
                        System.Diagnostics.Process.Start("Output\\print_file-" + i + ".pdf");
                    }


                    //Reference
                    string tmp = pmsutil.LogRecord(recordx.RecordID, "LOGC-03");
                });
                pmsutil.InsertTransaction("Matrimonial Cert.", "Paying", recordx.RecordID, Convert.ToDouble(pmsutil.GetPrintFee("Matrimonial")));
                tick++;
            }
        }
Ejemplo n.º 9
0
        private void BatchPrint(object sender, DoWorkEventArgs e)
        {
            int    tick      = 0;
            int    total     = _items.Count;
            string signature = "";
            string purpose   = "";
            double fee       = 0d;

            App.Current.Dispatcher.Invoke((Action) delegate            // <--- HERE
            {
                QueueCounter.Content      = tick + "/" + total;
                QueuePBar.IsIndeterminate = true;

                signature = Signatory.Text;
                purpose   = Purpose.Text;
                fee       = Convert.ToDouble(PrintingFee.Value);
            });

            for (int i = 0; i < _items.Count; i++)
            {
                App.Current.Dispatcher.Invoke((Action) delegate                // <--- HERE
                {
                    QueueCounter.Content = tick + "/" + total;
                });
                RecordEntryBurial recordx = (RecordEntryBurial)_items[i];

                string[] bspl = DateTime.Parse(recordx.BurialDate + "," + recordx.BurialYear).ToString("MM/dd/yyyy").Split('/');
                string   bmon = PrepMonth(int.Parse(bspl[0]));

                string[] dspl = DateTime.Parse(recordx.DeathDate + "," + recordx.DeathYear).ToString("MM/dd/yyyy").Split('/');
                string   dmon = PrepMonth(int.Parse(dspl[0]));

                Document doc = new Document();
                doc.LoadFromFile("Data\\temp_death.docx");
                doc.Replace("name", recordx.FullName, true, true);
                doc.Replace("age", Convert.ToString(recordx.Age), true, true);
                doc.Replace("nationality", "Filipino", true, true);
                doc.Replace("residence", recordx.Residence1, true, true);
                doc.Replace("civil", recordx.Status, true, true);

                if (string.IsNullOrEmpty(recordx.Parent2))
                {
                    doc.Replace("father", " ", true, true);
                    doc.Replace("mother", " ", true, true);
                    doc.Replace("spouse", recordx.Parent1, true, true);
                }
                else
                {
                    doc.Replace("father", recordx.Parent1, true, true);
                    doc.Replace("mother", recordx.Parent2, true, true);
                    doc.Replace("spouse", " ", true, true);
                }
                doc.Replace("date_of_birth", bmon + " " + bspl[1] + ", " + bspl[2], true, true);
                doc.Replace("cause_of_death", recordx.CauseOfDeath, true, true);
                doc.Replace("date_of_burial", dmon + " " + dspl[1] + ", " + dspl[2], true, true);
                doc.Replace("place_of_burial", recordx.PlaceOfInterment, true, true);
                doc.Replace("priest", recordx.Minister, true, true);
                doc.Replace("sign", signature, true, true);
                doc.Replace("no", recordx.EntryNumber.ToString(), true, true);
                doc.Replace("page", GetPNum(recordx.RecordID).ToString(), true, true);
                string[] date = DateTime.Now.ToString("MMMM,d,yyyy").Split(',');;
                doc.Replace("month", date[0], true, true);
                doc.Replace("day", date[1], true, true);
                doc.SaveToFile("Data\\print-" + i + ".docx", FileFormat.Docx);

                //Load Document
                Document document = new Document();
                document.LoadFromFile(@"Data\\print-" + i + ".docx");

                //Convert Word to PDF
                document.SaveToFile("Output\\print_file-" + i + ".pdf", FileFormat.PDF);

                App.Current.Dispatcher.Invoke((Action) delegate                // <--- HERE
                {
                    if (SkipPreview.IsChecked == true)
                    {
                        Spire.Pdf.PdfDocument docx = new Spire.Pdf.PdfDocument();
                        docx.LoadFromFile(@"Output\\print_file-" + i + ".pdf");
                        docx.PrintDocument.Print();
                    }
                    else
                    {
                        System.Diagnostics.Process.Start("Output\\print_file-" + i + ".pdf");
                    }


                    //Reference
                    string tmp = pmsutil.LogRecord(recordx.RecordID, "LOGC-03");
                });
                pmsutil.InsertTransaction("Burial Cert.", "Paying", recordx.RecordID, Convert.ToDouble(pmsutil.GetPrintFee("Burial")));

                tick++;
            }
        }
Ejemplo n.º 10
0
        private async void DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                DataTable dt = new DataTable();
                dt = ((DataView)databur.ItemsSource).ToTable();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dbman   = new DBConnectionManager();
                    pmsutil = new PMSUtil();
                    using (conn = new MySqlConnection(dbman.GetConnStr()))
                    {
                        conn.Open();
                        if (conn.State == ConnectionState.Open)
                        {
                            bool doProceed = false;
                            //Check inputs
                            for (int _tmp = 0; _tmp < 12; _tmp++)
                            {
                                if (String.IsNullOrEmpty(dt.Rows[i][i].ToString()) == true)
                                {
                                    doProceed = false;
                                }
                                else
                                {
                                    doProceed = true;
                                }
                            }
                            if (doProceed == true)
                            {
                                App.Current.Dispatcher.Invoke((Action) delegate                                // <--- HERE
                                {
                                    string recID     = pmsutil.GenRecordID();
                                    MySqlCommand cmd = dbman.DBConnect().CreateCommand();
                                    cmd.CommandText  =
                                        "INSERT INTO records(record_id, book_number, page_number, entry_number, record_date, recordholder_fullname, parent1_fullname, parent2_fullname)" +
                                        "VALUES(@record_id, @book_number, @page_number, @entry_number, @record_date, @recordholder_fullname, @parent1_fullname, @parent2_fullname)";
                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@record_id", recID);
                                    cmd.Parameters.AddWithValue("@book_number", _bookNum);
                                    cmd.Parameters.AddWithValue("@page_number", PageNum.Value);
                                    cmd.Parameters.AddWithValue("@entry_number", dt.Rows[i][0].ToString());
                                    cmd.Parameters.AddWithValue("@record_date", dt.Rows[i][1].ToString());
                                    cmd.Parameters.AddWithValue("@recordholder_fullname", dt.Rows[i][3].ToString());
                                    cmd.Parameters.AddWithValue("@parent1_fullname", dt.Rows[i][6].ToString());
                                    cmd.Parameters.AddWithValue("@parent2_fullname", dt.Rows[i][7].ToString());
                                    int stat_code = cmd.ExecuteNonQuery();
                                    dbman.DBClose();
                                    //Phase 2
                                    cmd             = conn.CreateCommand();
                                    cmd.CommandText =
                                        "INSERT INTO burial_records(record_id, burial_date, age, status, residence, residence2, sacrament, cause_of_death, place_of_interment, stipend, minister, remarks)" +
                                        "VALUES(@record_id, @burial_date, @age, @status, @residence, @residence2, @sacrament, @cause_of_death, @place_of_interment, @stipend, @minister, @remarks)";
                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@record_id", recID);
                                    cmd.Parameters.AddWithValue("@burial_date", dt.Rows[i][2].ToString());
                                    cmd.Parameters.AddWithValue("@age", dt.Rows[i][4].ToString());
                                    cmd.Parameters.AddWithValue("@status", dt.Rows[i][5].ToString());
                                    cmd.Parameters.AddWithValue("@residence", dt.Rows[i][8].ToString());
                                    cmd.Parameters.AddWithValue("@residence2", dt.Rows[i][9].ToString());
                                    cmd.Parameters.AddWithValue("@sacrament", dt.Rows[i][10].ToString());
                                    cmd.Parameters.AddWithValue("@cause_of_death", dt.Rows[i][11].ToString());
                                    cmd.Parameters.AddWithValue("@place_of_interment", dt.Rows[i][12].ToString());
                                    cmd.Parameters.AddWithValue("@stipend", dt.Rows[i][13].ToString());
                                    cmd.Parameters.AddWithValue("@minister", dt.Rows[i][14].ToString());
                                    cmd.Parameters.AddWithValue("@remarks", dt.Rows[i][15].ToString());
                                    stat_code = cmd.ExecuteNonQuery();
                                    conn.Close();

                                    conn.Open();
                                    string dirID = pmsutil.GenDirectoryID();

                                    cmd             = conn.CreateCommand();
                                    cmd.CommandText =
                                        "INSERT INTO burial_directory(directory_id, record_id, block, lot, plot, relative_contact_number)" +
                                        "VALUES(@directory_id, @record_id, @block, @lot, @plot, @relative_contact_number)";
                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@directory_id", dirID);
                                    cmd.Parameters.AddWithValue("@record_id", recID);
                                    cmd.Parameters.AddWithValue("@block", dt.Rows[i][16].ToString());
                                    cmd.Parameters.AddWithValue("@lot", dt.Rows[i][17].ToString());
                                    cmd.Parameters.AddWithValue("@plot", dt.Rows[i][18].ToString());
                                    cmd.Parameters.AddWithValue("@relative_contact_number", dt.Rows[i][19].ToString());
                                    stat_code = cmd.ExecuteNonQuery();
                                    conn.Close();

                                    _statcode  = stat_code;
                                    string tmp = pmsutil.LogRecord(recID, "LOGC-01");
                                    //return stat_code;
                                });
                            }
                            else
                            {
                                _statcode = 601;
                            }
                        }
                        else
                        {
                        }
                    }
                }
                this.Close();
            }
            catch
            {
            }
        }
Ejemplo n.º 11
0
        private void BatchPrint(object sender, DoWorkEventArgs e)
        {
            int    tick      = 0;
            int    total     = _items.Count;
            string signature = "";
            string purpose   = "";
            double fee       = 0d;

            App.Current.Dispatcher.Invoke((Action) delegate            // <--- HERE
            {
                QueueCounter.Content      = tick + "/" + total;
                QueuePBar.IsIndeterminate = true;

                signature = Signatory.Text;
                purpose   = Purpose.Text;
                fee       = Convert.ToDouble(PrintingFee.Value);
            });

            for (int i = 0; i < _items.Count; i++)
            {
                App.Current.Dispatcher.Invoke((Action) delegate                // <--- HERE
                {
                    QueueCounter.Content = tick + "/" + total;
                });
                RecordEntryConfirmation recordx = (RecordEntryConfirmation)_items[i];

                string x1;

                string[] spl  = DateTime.Parse(recordx.ConfirmationDate + "," + recordx.ConfirmationYear).ToString("MM/dd/yyyy").Split('/');
                string   suff = GetDaySuffix(int.Parse(spl[1]));
                string   mon  = PrepMonth(int.Parse(spl[0]));
                if (int.Parse(spl[2]) > 1999)
                {
                    x1     = "";
                    spl[2] = spl[2].Remove(0, 2);
                }
                else
                {
                    x1 = "X";
                }

                Document doc = new Document();
                doc.LoadFromFile("Data\\temp_confirmation.docx");
                doc.Replace("name", recordx.FullName, true, true);
                doc.Replace("day", int.Parse(spl[1]) + suff, true, true);
                doc.Replace("month", mon, true, true);
                doc.Replace("X", x1, true, true);
                doc.Replace("year", spl[2], true, true);
                doc.Replace("by", recordx.Minister, true, true);
                doc.Replace("no", recordx.EntryNumber.ToString(), true, true);
                doc.Replace("book", GetBNum(recordx.RecordID).ToString(), true, true);
                doc.Replace("page", GetPNum(recordx.RecordID).ToString(), true, true);
                doc.Replace("no", recordx.EntryNumber.ToString(), true, true);
                doc.Replace("priest", recordx.Minister, true, true);
                doc.Replace("purpose", purpose, true, true);
                doc.Replace("date", DateTime.Now.ToString("MMMM d, yyyy"), true, true);
                doc.SaveToFile("Data\\print-" + i + ".docx", FileFormat.Docx);

                //Load Document
                Document document = new Document();
                document.LoadFromFile(@"Data\\print-" + i + ".docx");

                //Convert Word to PDF
                document.SaveToFile("Output\\print_file-" + i + ".pdf", FileFormat.PDF);

                App.Current.Dispatcher.Invoke((Action) delegate                // <--- HERE
                {
                    if (SkipPreview.IsChecked == true)
                    {
                        Spire.Pdf.PdfDocument docx = new Spire.Pdf.PdfDocument();
                        docx.LoadFromFile(@"Output\\print_file-" + i + ".pdf");
                        docx.PrintDocument.Print();
                    }
                    else
                    {
                        System.Diagnostics.Process.Start("Output\\print_file-" + i + ".pdf");
                    }


                    if (Purpose.SelectedIndex == 0)
                    {
                        //Reference
                        string tmp = pmsutil.LogRecord(recordx.RecordID, "LOGC-03");
                    }
                    else
                    {
                        //Marriage
                        string tmp = pmsutil.LogRecord(recordx.RecordID, "LOGC-04");
                    }
                });
                pmsutil.InsertTransaction("Confirmation Cert.", "Paying", recordx.RecordID, Convert.ToDouble(pmsutil.GetPrintFee("Confirmation")));
                tick++;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Inserts the request to the database.
        /// </summary>
        private int PrintEntry()
        {
            string x1;

            string[] spl  = ConfirmationDate.Text.Split('/');
            string   suff = GetDaySuffix(int.Parse(spl[1]));
            string   mon  = PrepMonth(int.Parse(spl[0]));

            if (int.Parse(spl[2]) > 1999)
            {
                x1     = "";
                spl[2] = spl[2].Remove(0, 2);
            }
            else
            {
                x1 = "X";
            }

            Document doc = new Document();

            doc.LoadFromFile("Data\\temp_confirmation.docx");
            doc.Replace("name", fullName, true, true);
            doc.Replace("day", int.Parse(spl[1]) + suff, true, true);
            doc.Replace("month", mon, true, true);
            doc.Replace("X", x1, true, true);
            doc.Replace("year", spl[2], true, true);
            doc.Replace("by", minister, true, true);
            doc.Replace("no", entryNum.ToString(), true, true);
            doc.Replace("page", pageNum.ToString(), true, true);
            doc.Replace("book", bookNum.ToString(), true, true);
            doc.Replace("priest", Signatory.Text, true, true);
            doc.Replace("purpose", Purpose.Text, true, true);
            doc.Replace("date", DateTime.Now.ToString("MMMM d, yyyy"), true, true);
            doc.SaveToFile("Data\\print.docx", FileFormat.Docx);

            //Load Document
            Document document = new Document();

            document.LoadFromFile(@"Data\\print.docx");

            //Convert Word to PDF
            document.SaveToFile("Output\\print_file.pdf", FileFormat.PDF);

            System.Diagnostics.Process.Start("Output\\print_file.pdf");

            if (Purpose.SelectedIndex == 0)
            {
                //Reference
                string tmp = pmsutil.LogRecord(recordID, "LOGC-03");
            }
            else
            {
                //Marriage
                string tmp = pmsutil.LogRecord(recordID, "LOGC-04");
            }
            if (Purpose.SelectedIndex == 0)
            {
                //Reference
                string tmp = pmsutil.LogRecord(recordID, "LOGC-03");
            }
            else
            {
                //Marriage
                string tmp = pmsutil.LogRecord(recordID, "LOGC-04");
            }
            pmsutil.InsertTransaction("Confirmation Cert.", "Unpaid", recordID, Convert.ToDouble(PrintingFee.Value));
            return(1);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Inserts the request to the database.
        /// </summary>
        private int PrintEntry()
        {
            string x1, x2;

            string[] bspl  = birthDate.Split('/');
            string   bsuff = GetDaySuffix(int.Parse(bspl[1]));
            string   bmon  = PrepMonth(int.Parse(bspl[0]));

            if (int.Parse(bspl[2]) > 1999)
            {
                x1      = "";
                bspl[2] = bspl[2].Remove(0, 2);
            }
            else
            {
                x1 = "X";
            }

            string[] dspl  = baptismDate.Split('/');
            string   dsuff = GetDaySuffix(int.Parse(dspl[1]));
            string   dmon  = PrepMonth(int.Parse(dspl[0]));

            if (int.Parse(dspl[2]) > 1999)
            {
                x2      = "";
                dspl[2] = dspl[2].Remove(0, 2);
            }
            else
            {
                x2 = "X";
            }

            Document doc = new Document();

            doc.LoadFromFile("Data\\temp_baptismal.docx");
            doc.Replace("name", fullName, true, true);
            doc.Replace("father", parent1, true, true);
            doc.Replace("mother", parent2, true, true);
            doc.Replace("born", birthPlace, true, true);
            doc.Replace("day1", int.Parse(bspl[1]) + bsuff, true, true);
            doc.Replace("month1", bmon, true, true);
            doc.Replace("X1", x1, true, true);
            //doc.Replace("year1", bspl[2], true, true);
            doc.Replace("year1", DateTime.Parse(birthDate).ToString("yyyy"), true, true);
            doc.Replace("day2", int.Parse(dspl[1]) + dsuff, true, true);
            doc.Replace("month2", dmon, true, true);
            doc.Replace("X2", x2, true, true);
            doc.Replace("year2", DateTime.Parse(baptismDate).ToString("yyyy"), true, true);
            doc.Replace("church", pmsutil.GetChurchName(), true, true);
            doc.Replace("by", Signatory.Text, true, true);
            doc.Replace("sponsor1", sponsor1, true, true);
            doc.Replace("sponsor2", sponsor2, true, true);
            doc.Replace("book", bookNum.ToString(), true, true);
            doc.Replace("page", pageNum.ToString(), true, true);
            doc.Replace("no", entryNum.ToString(), true, true);
            doc.Replace("priest", minister, true, true);
            doc.Replace("purpose", Purpose.Text, true, true);
            doc.Replace("date", DateTime.Now.ToString("MMMM d, yyyy"), true, true);
            doc.SaveToFile("Data\\print.docx", FileFormat.Docx);

            //Load Document
            Document document = new Document();

            document.LoadFromFile(@"Data\\print.docx");

            //Convert Word to PDF
            document.SaveToFile("Output\\print_file.pdf", FileFormat.PDF);

            System.Diagnostics.Process.Start("Output\\print_file.pdf");


            if (Purpose.SelectedIndex == 0)
            {
                //Reference
                string tmp = pmsutil.LogRecord(recordID, "LOGC-03");
            }
            else
            {
                //Marriage
                string tmp = pmsutil.LogRecord(recordID, "LOGC-04");
            }
            pmsutil.InsertTransaction("Baptismal Cert.", "Unpaid", recordID, Convert.ToDouble(PrintingFee.Value));
            return(1);
        }
Ejemplo n.º 14
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                DataTable dt = new DataTable();
                dt = ((DataView)datamat.ItemsSource).ToTable();
                //MessageBox.Show(dt.Rows[0][0].ToString());

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dbman   = new DBConnectionManager();
                    pmsutil = new PMSUtil();
                    using (conn = new MySqlConnection(dbman.GetConnStr()))
                    {
                        conn.Open();
                        if (conn.State == ConnectionState.Open)
                        {
                            bool doProceed = false;
                            //Check inputs
                            for (int _tmp = 0; _tmp < 12; _tmp++)
                            {
                                if (String.IsNullOrEmpty(dt.Rows[i][i].ToString()) == true)
                                {
                                    doProceed = false;
                                }
                                else
                                {
                                    doProceed = true;
                                }
                            }
                            if (doProceed == true)
                            {
                                App.Current.Dispatcher.Invoke((Action) delegate                                // <--- HERE
                                {
                                    string recID     = pmsutil.GenRecordID();
                                    MySqlCommand cmd = conn.CreateCommand();
                                    cmd.CommandText  =
                                        "INSERT INTO records(record_id, book_number, page_number, entry_number, record_date, recordholder_fullname, parent1_fullname, parent2_fullname)" +
                                        "VALUES(@record_id, @book_number, @page_number, @entry_number, @record_date, @recordholder_fullname, @parent1_fullname, @parent2_fullname)";
                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@record_id", recID);
                                    cmd.Parameters.AddWithValue("@book_number", _bookNum);
                                    cmd.Parameters.AddWithValue("@page_number", PageNum.Value);
                                    cmd.Parameters.AddWithValue("@entry_number", Convert.ToInt32(dt.Rows[i][0].ToString()));
                                    cmd.Parameters.AddWithValue("@record_date", dt.Rows[i][1].ToString());
                                    cmd.Parameters.AddWithValue("@recordholder_fullname", dt.Rows[i][2].ToString());
                                    cmd.Parameters.AddWithValue("@parent1_fullname", dt.Rows[i][12].ToString());
                                    cmd.Parameters.AddWithValue("@parent2_fullname", dt.Rows[i][13].ToString());
                                    int stat_code = cmd.ExecuteNonQuery();
                                    conn.Close();

                                    conn.Open();
                                    //Phase 2
                                    cmd             = dbman.DBConnect().CreateCommand();
                                    cmd.CommandText =
                                        "INSERT INTO matrimonial_records(record_id, recordholder2_fullname, parent1_fullname2, parent2_fullname2, status1, status2, age1, age2, place_of_origin1, place_of_origin2, residence1, residence2, witness1, witness2, witness1address, witness2address, stipend, minister, remarks)" +
                                        "VALUES(@record_id, @recordholder2_fullname, @parent1_fullname2, @parent2_fullname2, @status1, @status2, @age1, @age2, @place_of_origin1, @place_of_origin2, @residence1, @residence2, @witness1, @witness2, @witness1address, @witness2address, @stipend, @minister, @remarks)";
                                    cmd.Prepare();
                                    cmd.Parameters.AddWithValue("@record_id", recID);
                                    cmd.Parameters.AddWithValue("@recordholder2_fullname", dt.Rows[i][3].ToString());
                                    cmd.Parameters.AddWithValue("@parent1_fullname2", dt.Rows[i][14].ToString());
                                    cmd.Parameters.AddWithValue("@parent2_fullname2", dt.Rows[i][15].ToString());
                                    cmd.Parameters.AddWithValue("@status1", dt.Rows[i][6].ToString());
                                    cmd.Parameters.AddWithValue("@status2", dt.Rows[i][7].ToString());
                                    cmd.Parameters.AddWithValue("@age1", dt.Rows[i][4].ToString());
                                    cmd.Parameters.AddWithValue("@age2", dt.Rows[i][5].ToString());
                                    cmd.Parameters.AddWithValue("@place_of_origin1", dt.Rows[i][8].ToString());
                                    cmd.Parameters.AddWithValue("@place_of_origin2", dt.Rows[i][9].ToString());
                                    cmd.Parameters.AddWithValue("@residence1", dt.Rows[i][10].ToString());
                                    cmd.Parameters.AddWithValue("@residence2", dt.Rows[i][11].ToString());
                                    cmd.Parameters.AddWithValue("@witness1", dt.Rows[i][16].ToString());
                                    cmd.Parameters.AddWithValue("@witness2", dt.Rows[i][17].ToString());
                                    cmd.Parameters.AddWithValue("@witness1address", dt.Rows[i][18].ToString());
                                    cmd.Parameters.AddWithValue("@witness2address", dt.Rows[i][19].ToString());
                                    cmd.Parameters.AddWithValue("@stipend", Convert.ToDouble(dt.Rows[i][20].ToString()));
                                    cmd.Parameters.AddWithValue("@minister", dt.Rows[i][21].ToString());
                                    cmd.Parameters.AddWithValue("@remarks", dt.Rows[i][22].ToString());
                                    stat_code = cmd.ExecuteNonQuery();

                                    conn.Close();
                                    string tmp = pmsutil.LogRecord(recID, "LOGC-01");
                                    _statcode  = stat_code;
                                    //return stat_code;
                                });
                            }
                            else
                            {
                                _statcode = 601;
                            }
                        }
                        else
                        {
                        }
                    }
                }
                this.Close();
            }
            catch
            {
            }
        }