/// <summary> /// Inserts the request to the database. /// </summary> private int UpdateTransaction() { string uid = Application.Current.Resources["uid"].ToString(); string[] dt = pmsutil.GetServerDateTime().Split(null); cDate = Convert.ToDateTime(dt[0]); cTime = DateTime.Parse(dt[1] + " " + dt[2]); curDate = cDate.ToString("yyyy-MM-dd"); curTime = cTime.ToString("HH:mm:ss"); dbman = new DBConnectionManager(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "UPDATE transactions SET status = @status, completion_date = @completion_date, completion_time = @completion_time, completed_by = @completed_by WHERE transaction_id = @transaction_id;"; cmd.Parameters.AddWithValue("@transaction_id", tid); cmd.Parameters.AddWithValue("@status", "Cancelled"); cmd.Parameters.AddWithValue("@completion_date", cDate); cmd.Parameters.AddWithValue("@completion_time", cTime); cmd.Parameters.AddWithValue("@completed_by", uid); cmd.Prepare(); int stat_code = cmd.ExecuteNonQuery(); conn.Close(); return(stat_code); } else { return(0); } } }
/// <summary> /// Inserts the request to the database. /// </summary> private int UpdateTransaction() { string uid = Application.Current.Resources["uid"].ToString(); string[] dt = pmsutil.GetServerDateTime().Split(null); cDate = Convert.ToDateTime(dt[0]); cTime = DateTime.Parse(dt[1] + " " + dt[2]); curDate = cDate.ToString("yyyy-MM-dd"); curTime = cTime.ToString("HH:mm:ss"); dbman = new DBConnectionManager(); try { MySqlCommand cmd = dbman.DBConnect().CreateCommand(); cmd.CommandText = "UPDATE transactions SET status = @status, completion_date = @completion_date, completion_time = @completion_time, completed_by = @completed_by WHERE target_id = @aid;"; cmd.Parameters.AddWithValue("@aid", aid); cmd.Parameters.AddWithValue("@status", "Cancelled"); cmd.Parameters.AddWithValue("@completion_date", cDate); cmd.Parameters.AddWithValue("@completion_time", cTime); cmd.Parameters.AddWithValue("@completed_by", uid); cmd.Prepare(); int stat_code = cmd.ExecuteNonQuery(); dbman.DBClose(); return(stat_code); } catch (MySqlException ex) { Console.WriteLine("Error: {0}", ex.ToString()); return(0); } }
private DataTable GenerateList() { DataTable dtNames = new DataTable(); dtNames.Columns.Add("Time", typeof(string)); dtNames.Columns.Add("Type", typeof(string)); dtNames.Columns.Add("Sponsor", typeof(string)); dtNames.Columns.Add("Additional Info", typeof(string)); dbman = new DBConnectionManager(); pmsutil = new PMSUtil(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { //Year using (MySqlConnection conn2 = new MySqlConnection(dbman.GetConnStr())) { string[] dt = pmsutil.GetServerDateTime().Split(null); DateTime cDate = Convert.ToDateTime(dt[0]); var start = new DateTime(cDate.Year, 1, 1); var end = new DateTime(cDate.Year, 12, 31); conn2.Open(); MySqlCommand cmd = conn2.CreateCommand(); cmd.CommandText = "SELECT * FROM appointments WHERE appointment_date = @date ORDER BY appointment_time ASC;"; cmd.Parameters.AddWithValue("@date", _dt.ToString("yyyy-MM-dd")); cmd.Prepare(); using (MySqlDataReader db_reader = cmd.ExecuteReader()) { while (db_reader.Read()) { if (ReportType.SelectedIndex == 0) { dtNames.Rows.Add(DateTime.Parse(db_reader.GetString("appointment_time")).ToString("hh:mm tt"), GetAType(db_reader.GetString("appointment_type")), db_reader.GetString("requested_by"), db_reader.GetString("remarks")); } else if (ReportType.SelectedIndex == 1) { if (IsCustom(db_reader.GetString("appointment_type")) == false) { dtNames.Rows.Add(DateTime.Parse(db_reader.GetString("appointment_time")).ToString("hh:mm tt"), GetAType(db_reader.GetString("appointment_type")), db_reader.GetString("requested_by"), db_reader.GetString("remarks")); } } else { if (IsCustom(db_reader.GetString("appointment_type")) == true) { dtNames.Rows.Add(DateTime.Parse(db_reader.GetString("appointment_time")).ToString("hh:mm tt"), GetAType(db_reader.GetString("appointment_type")), db_reader.GetString("requested_by"), db_reader.GetString("remarks")); } } } } } } } return(dtNames); }
private void ArchiveItems(object sender, DoWorkEventArgs e) { string uid = Application.Current.Resources["uid"].ToString(); string[] dt = pmsutil.GetServerDateTime().Split(null); cDate = Convert.ToDateTime(dt[0]); cTime = DateTime.Parse(dt[1] + " " + dt[2]); curDate = cDate.ToString("yyyy-MM-dd"); curTime = cTime.ToString("HH:mm:ss"); dbman = new DBConnectionManager(); pmsutil = new PMSUtil(); //TODO try { MySqlCommand cmd = dbman.DBConnect().CreateCommand(); cmd.CommandText = "INSERT INTO archives(book_number, date_archived, time_archived, archived_by)" + "VALUES(@book_number, @date_archived, @time_archived, @archived_by)"; cmd.Parameters.AddWithValue("@book_number", bookNum); cmd.Parameters.AddWithValue("@date_archived", curDate); cmd.Parameters.AddWithValue("@time_archived", curTime); cmd.Parameters.AddWithValue("@archived_by", uid); cmd.Prepare(); int stat_code = cmd.ExecuteNonQuery(); dbman = new DBConnectionManager(); //TODO try { //Phase 1.2 cmd = dbman.DBConnect().CreateCommand(); cmd.CommandText = "UPDATE registers SET status = @status WHERE book_number = @book_number;"; cmd.Parameters.AddWithValue("@book_number", bookNum); cmd.Parameters.AddWithValue("@status", "Archived"); cmd.Prepare(); stat_code = cmd.ExecuteNonQuery(); dbman.DBClose(); } catch (MySqlException ex) { Console.WriteLine("Error: {0}", ex.ToString()); //return 0; } stat_code2 = stat_code; dbman.DBClose(); Phase2(); //return stat_code; } catch (MySqlException ex) { Console.WriteLine("Error: {0}", ex.ToString()); //return 0; } }
/// <summary> /// Interaction logic for the AddRegConfirm button. Gathers and prepares the data /// for database insertion. /// </summary> private void AddRegConfirm(object sender, System.Windows.RoutedEventArgs e) { if (CheckInputs() == true) { switch (RegisterType.SelectedIndex) { case 0: regType = "Baptismal"; break; case 1: regType = "Matrimonial"; break; case 2: regType = "Confirmation"; break; case 3: regType = "Burial"; break; default: regType = "NULL"; break; } bookNum = Convert.ToInt32(BookNo.Value); registerNum = Convert.ToInt32(RegisterNo.Value); book = Book.Text; creationDate = Convert.ToDateTime(CreationDate.Text).ToString("yyyy-MM-dd"); string[] dt = pmsutil.GetServerDateTime().Split(null); cDate = Convert.ToDateTime(dt[0]); cTime = DateTime.Parse(dt[1] + " " + dt[2]); curDate = cDate.ToString("yyyy-MM-dd"); curTime = cTime.ToString("HH:mm:ss"); if (InsertRegister() > 0) { reg1.SyncRegisters(); var metroWindow = (Application.Current.MainWindow as MetroWindow); pmsutil.LogAccount("Added Register Number: " + RegisterNo.Value + " Type: " + regType); MsgSuccess(); this.Close(); } else { MsgFail(); } } else { } }
private void CreateAccountButton_Click(object sender, RoutedEventArgs e) { if (CheckInputs() == true) { dbman = new DBConnectionManager(); pmsutil = new PMSUtil(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { string uid = Application.Current.Resources["uid"].ToString(); string[] dt = pmsutil.GetServerDateTime().Split(null); DateTime cDate = Convert.ToDateTime(dt[0]); DateTime cTime = DateTime.Parse(dt[1] + " " + dt[2]); string curDate = cDate.ToString("yyyy-MM-dd"); string curTime = cTime.ToString("HH:mm:ss"); string pid = pmsutil.GenPriestID(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO residing_priests(priest_id, priest_name, priest_status, created_by, date_created, time_created)" + "VALUES(@priest_id, @priest_name, @priest_status, @created_by, @date_created, @time_created)"; cmd.Prepare(); cmd.Parameters.AddWithValue("@priest_id", pid); cmd.Parameters.AddWithValue("@priest_name", PriestName.Text); cmd.Parameters.AddWithValue("@priest_status", Status.Text); cmd.Parameters.AddWithValue("@created_by", uid); cmd.Parameters.AddWithValue("@date_created", curDate); cmd.Parameters.AddWithValue("@time_created", curTime); int stat_code = cmd.ExecuteNonQuery(); conn.Close(); if (stat_code > 0) { _caller.SyncPriest(); pmsutil.LogAccount("Added priest - Name: " + PriestName.Text); MsgSuccess(); this.Close(); } else { MsgFail(); } } else { } } } else { } }
private void CreateAccountButton_Click(object sender, RoutedEventArgs e) { if (CheckDupli() == true) { MsgDupli(); } else { dbman = new DBConnectionManager(); pmsutil = new PMSUtil(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { string uid = Application.Current.Resources["uid"].ToString(); string[] dt = pmsutil.GetServerDateTime().Split(null); DateTime cDate = Convert.ToDateTime(dt[0]); DateTime cTime = DateTime.Parse(dt[1] + " " + dt[2]); string curDate = cDate.ToString("yyyy-MM-dd"); string curTime = cTime.ToString("HH:mm:ss"); string selTime = HourPicker.Text + ":" + MinutePicker.Text + " " + ModePicker.Text; string tid = pmsutil.GenTimeSlotID(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO timeslots(timeslot_id, timeslot, status)" + "VALUES(@timeslot_id, @timeslot, @status)"; cmd.Prepare(); cmd.Parameters.AddWithValue("@timeslot_id", tid); cmd.Parameters.AddWithValue("@timeslot", DateTime.Parse(selTime).ToString("HH:mm:ss")); cmd.Parameters.AddWithValue("@status", Status.Text); int stat_code = cmd.ExecuteNonQuery(); conn.Close(); if (stat_code > 0) { _caller.SyncTimeSlots(); pmsutil.LogAccount("Added Timeslot: " + DateTime.Parse(selTime).ToString("HH:mm:ss")); MsgSuccess(); this.Close(); } else { MsgFail(); } } else { } } } }
private DataTable GenerateList() { DataTable dtNames = new DataTable(); if (ListType.SelectedIndex == 2) { dtNames.Columns.Add("No", typeof(string)); dtNames.Columns.Add("Time", typeof(string)); dtNames.Columns.Add("Type", typeof(string)); dtNames.Columns.Add("Sponsor", typeof(string)); dtNames.Columns.Add("Venue", typeof(string)); dtNames.Columns.Add("Remarks", typeof(string)); dbman = new DBConnectionManager(); pmsutil = new PMSUtil(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { //Year using (MySqlConnection conn2 = new MySqlConnection(dbman.GetConnStr())) { string[] dt = pmsutil.GetServerDateTime().Split(null); DateTime cDate = Convert.ToDateTime(dt[0]); conn2.Open(); MySqlCommand cmd = conn2.CreateCommand(); cmd.CommandText = "SELECT * FROM appointments WHERE appointment_date > @min AND appointment_date < @max ORDER BY appointment_date ASC;"; cmd.Parameters.AddWithValue("@min", DateTime.Parse(ListMinDate.SelectedDate.ToString())); cmd.Parameters.AddWithValue("@max", DateTime.Parse(ListMaxDate.SelectedDate.ToString())); cmd.Prepare(); using (MySqlDataReader db_reader = cmd.ExecuteReader()) { int count = 1; while (db_reader.Read()) { if (ListType.SelectedIndex == 0) { dtNames.Rows.Add(count, DateTime.Parse(db_reader.GetString("appointment_time")).ToString("hh:mm tt"), GetAType(db_reader.GetString("appointment_type")), db_reader.GetString("requested_by"), db_reader.GetString("venue"), db_reader.GetString("remarks")); } else if (ListType.SelectedIndex == 1) { if (IsCustom(db_reader.GetString("appointment_type")) == false) { dtNames.Rows.Add(count, DateTime.Parse(db_reader.GetString("appointment_time")).ToString("hh:mm tt"), GetAType(db_reader.GetString("appointment_type")), db_reader.GetString("requested_by"), db_reader.GetString("venue"), db_reader.GetString("remarks")); } } else { if (IsCustom(db_reader.GetString("appointment_type")) == true) { dtNames.Rows.Add(count, DateTime.Parse(db_reader.GetString("appointment_time")).ToString("hh:mm tt"), GetAType(db_reader.GetString("appointment_type")), db_reader.GetString("requested_by"), db_reader.GetString("venue"), db_reader.GetString("remarks")); } } count++; } } } } } } else { dtNames.Columns.Add("No", typeof(string)); dtNames.Columns.Add("Time", typeof(string)); dtNames.Columns.Add("Type", typeof(string)); dtNames.Columns.Add("Sponsor", typeof(string)); dtNames.Columns.Add("Remarks", typeof(string)); dbman = new DBConnectionManager(); pmsutil = new PMSUtil(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { //Year using (MySqlConnection conn2 = new MySqlConnection(dbman.GetConnStr())) { string[] dt = pmsutil.GetServerDateTime().Split(null); DateTime cDate = Convert.ToDateTime(dt[0]); conn2.Open(); MySqlCommand cmd = conn2.CreateCommand(); cmd.CommandText = "SELECT * FROM appointments WHERE appointment_date > @min AND appointment_date < @max ORDER BY appointment_date ASC;"; cmd.Parameters.AddWithValue("@min", DateTime.Parse(ListMinDate.SelectedDate.ToString())); cmd.Parameters.AddWithValue("@max", DateTime.Parse(ListMaxDate.SelectedDate.ToString())); cmd.Prepare(); using (MySqlDataReader db_reader = cmd.ExecuteReader()) { int count = 1; while (db_reader.Read()) { if (ListType.SelectedIndex == 0) { dtNames.Rows.Add(count, DateTime.Parse(db_reader.GetString("appointment_time")).ToString("hh:mm tt"), GetAType(db_reader.GetString("appointment_type")), db_reader.GetString("requested_by"), db_reader.GetString("remarks")); } else if (ListType.SelectedIndex == 1) { if (IsCustom(db_reader.GetString("appointment_type")) == false) { dtNames.Rows.Add(count, DateTime.Parse(db_reader.GetString("appointment_time")).ToString("hh:mm tt"), GetAType(db_reader.GetString("appointment_type")), db_reader.GetString("requested_by"), db_reader.GetString("remarks")); } } else { if (IsCustom(db_reader.GetString("appointment_type")) == true) { dtNames.Rows.Add(count, DateTime.Parse(db_reader.GetString("appointment_time")).ToString("hh:mm tt"), GetAType(db_reader.GetString("appointment_type")), db_reader.GetString("requested_by"), db_reader.GetString("remarks")); } } count++; } } } } } } return(dtNames); }
private void GenerateDailyReport() { pmsutil = new PMSUtil(); string[] dt = pmsutil.GetServerDateTime().Split(null); DateTime cDate = Convert.ToDateTime(dt[0]); DateTime cTime = DateTime.Parse(dt[1] + " " + dt[2]); PdfDocument pdfDoc = new PdfDocument(); PdfPageBase page = pdfDoc.Pages.Add(); var stream = this.GetType().GetTypeInfo().Assembly.GetManifestResourceStream("PMS.Assets.st_raphael_logo_dark.png"); PdfImage logo = PdfImage.FromStream(stream); float _width = 200; float height = 80; float x = (page.Canvas.ClientSize.Width - _width) / 2; page.Canvas.DrawImage(logo, 0, -25, _width, height); page.Canvas.DrawString("Peñaranda St, Legazpi Port District", new PdfFont(PdfFontFamily.TimesRoman, 13f), new PdfSolidBrush(Color.Black), 245, 0); page.Canvas.DrawString("Legazpi City, Albay", new PdfFont(PdfFontFamily.TimesRoman, 13f), new PdfSolidBrush(Color.Black), 280, 20); page.Canvas.DrawLine(new PdfPen(Color.Black), new PointF(1, 49), new PointF(530, 49)); page.Canvas.DrawString("PMS Scheduling Module Report", new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(Color.Black), 350, 52); page.Canvas.DrawString("Generated on: " + DateTime.Now.ToString("MMMM dd, yyyy hh:mm tt"), new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(Color.Black), 10, 52); page.Canvas.DrawString("Type: " + ListType.Text, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 380, 90); page.Canvas.DrawLine(new PdfPen(Color.Black), new PointF(1, 70), new PointF(530, 70)); if (ListType.SelectedIndex == 1) { page.Canvas.DrawString(cDate.ToString("MMMM dd, yyyy").ToUpper() + " (" + cDate.ToString("dddd").ToUpper() + ")", new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(Color.Black), 10, 90); } else { page.Canvas.DrawString(DateTime.Parse(ListMinDate.SelectedDate.ToString()).ToString("MMMM dd, yyyy").ToUpper() + " TO " + DateTime.Parse(ListMaxDate.SelectedDate.ToString()).ToString("MMMM dd, yyyy").ToUpper(), new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(Color.Black), 10, 90); } PdfTable table = new PdfTable(); table.Style.CellPadding = 2; table.Style.DefaultStyle.Font = new PdfTrueTypeFont(new Font("Times New Roman", 11f)); table.Style.AlternateStyle = new PdfCellStyle(); table.Style.AlternateStyle.Font = new PdfTrueTypeFont(new Font("Times New Roman", 11f)); table.Style.HeaderSource = PdfHeaderSource.ColumnCaptions; table.Style.HeaderStyle.Font = new PdfFont(PdfFontFamily.TimesRoman, 13f); table.Style.HeaderStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Center); table.Style.ShowHeader = true; table.DataSourceType = PdfTableDataSourceType.TableDirect; table.DataSource = GenerateList(); //Set the width of column float width = page.Canvas.ClientSize.Width - (table.Columns.Count + 1); table.Columns[0].Width = width * 0.24f * width; table.Columns[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); table.Columns[1].Width = width * 0.21f * width; table.Columns[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); table.Columns[2].Width = width * 0.24f * width; table.Columns[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); table.Columns[3].Width = width * 0.24f * width; table.Columns[3].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); table.Columns[4].Width = width * 0.24f * width; table.Columns[4].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); if (ListType.SelectedIndex == 2) { table.Columns[5].Width = width * 0.24f * width; table.Columns[5].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); } table.Draw(page, new PointF(10, 120)); string fname = "Scheduling_Report-" + ListType.Text + "-" + DateTime.Now.ToString("MMM_dd_yyyy") + ".pdf"; //save pdfDoc.SaveToFile(@"..\..\" + fname); //launch the pdf document System.Diagnostics.Process.Start(@"..\..\" + fname); }
internal void GenReport3Phase2() { string[] dt = pmsutil.GetServerDateTime().Split(null); DateTime cDate = Convert.ToDateTime(dt[0]); DateTime cTime = DateTime.Parse(dt[1] + " " + dt[2]); //create a new pdf document PdfDocument pdfDoc = new PdfDocument(); PdfPageBase page = pdfDoc.Pages.Add(); var stream = this.GetType().GetTypeInfo().Assembly.GetManifestResourceStream("PMS.Assets.st_raphael_logo_dark.png"); PdfImage logo = PdfImage.FromStream(stream); float _width = 200; float height = 80; float x = (page.Canvas.ClientSize.Width - _width) / 2; page.Canvas.DrawImage(logo, 0, -25, _width, height); page.Canvas.DrawString("Peñaranda St, Legazpi Port District", new PdfFont(PdfFontFamily.TimesRoman, 13f), new PdfSolidBrush(System.Drawing.Color.Black), 245, 0); page.Canvas.DrawString("Legazpi City, Albay", new PdfFont(PdfFontFamily.TimesRoman, 13f), new PdfSolidBrush(System.Drawing.Color.Black), 280, 20); page.Canvas.DrawLine(new PdfPen(System.Drawing.Color.Black), new PointF(1, 49), new PointF(530, 49)); page.Canvas.DrawString("PMS Index Report", new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 350, 52); page.Canvas.DrawString("Generated on: " + DateTime.Now.ToString("MMMM dd, yyyy hh:mm tt"), new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 10, 52); page.Canvas.DrawLine(new PdfPen(System.Drawing.Color.Black), new PointF(1, 70), new PointF(530, 70)); page.Canvas.DrawString(_name.ToUpper(), new PdfFont(PdfFontFamily.TimesRoman, 18f, PdfFontStyle.Bold), new PdfSolidBrush(System.Drawing.Color.Black), 10, 85); //page.Canvas.DrawLine(new PdfPen(System.Drawing.Color.Black), new PointF(10, 115), new PointF(330, 115)); page.Canvas.DrawString("Birth Details", new PdfFont(PdfFontFamily.TimesRoman, 12f, PdfFontStyle.Bold), new PdfSolidBrush(System.Drawing.Color.Black), 10, 125); page.Canvas.DrawString("Age: " + _age, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 10, 150); page.Canvas.DrawString("Residence: " + _residence, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 10, 170); page.Canvas.DrawString("Residence: " + _residence, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 10, 190); page.Canvas.DrawString("Parents: " + _parent1 + " & " + _parent2, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 10, 210); page.Canvas.DrawString("Burial Details", new PdfFont(PdfFontFamily.TimesRoman, 12f, PdfFontStyle.Bold), new PdfSolidBrush(System.Drawing.Color.Black), 300, 125); page.Canvas.DrawString("Date of Death: " + _deathDate, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 300, 150); page.Canvas.DrawString("Burial Date: " + _burialDate, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 300, 170); page.Canvas.DrawString("Cause of Death: " + _causeOfDeath, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 300, 190); page.Canvas.DrawString("Sacrament: " + _sacrament, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 300, 210); page.Canvas.DrawString("Place of Interment: ", new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 300, 230); page.Canvas.DrawString(_interment, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 300, 250); page.Canvas.DrawString("Location: ", new PdfFont(PdfFontFamily.TimesRoman, 12f, PdfFontStyle.Bold), new PdfSolidBrush(System.Drawing.Color.Black), 300, 280); page.Canvas.DrawString("Block: " + _block, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 300, 300); page.Canvas.DrawString("Lot: " + _lot, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 300, 320); page.Canvas.DrawString("Plot: " + _plot, new PdfFont(PdfFontFamily.TimesRoman, 12f), new PdfSolidBrush(System.Drawing.Color.Black), 300, 340); page.Canvas.DrawString("Near the Location", new PdfFont(PdfFontFamily.TimesRoman, 14f), new PdfSolidBrush(System.Drawing.Color.Black), 10, 360); DataTable dtNames = new DataTable(); dtNames.Columns.Add("Name", typeof(string)); dtNames.Columns.Add("Lot", typeof(string)); dtNames.Columns.Add("Plot", typeof(string)); dbman = new DBConnectionManager(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM records, burial_records, burial_directory WHERE records.record_id = burial_records.record_id AND burial_records.record_id = burial_directory.record_id AND burial_directory.block = @block AND burial_directory.lot = @lot;"; cmd.Parameters.AddWithValue("@block", _block); cmd.Parameters.AddWithValue("@lot", _lot); MySqlDataReader db_reader = cmd.ExecuteReader(); while (db_reader.Read()) { if (db_reader.GetString("record_id") != _rid) { dtNames.Rows.Add(db_reader.GetString("recordholder_fullname"), db_reader.GetString("lot"), db_reader.GetString("plot")); } } } } PdfTable table = new PdfTable(); table.Style.CellPadding = 2; //table.Style.DefaultStyle.BackgroundBrush = PdfBrushes.SkyBlue; table.Style.DefaultStyle.Font = new PdfTrueTypeFont(new Font("Times New Roman", 11f)); table.Style.AlternateStyle = new PdfCellStyle { //table.Style.AlternateStyle.BackgroundBrush = PdfBrushes.LightYellow; Font = new PdfTrueTypeFont(new Font("Times New Roman", 11f)) }; table.Style.HeaderSource = PdfHeaderSource.ColumnCaptions; //table.Style.HeaderStyle.BackgroundBrush = PdfBrushes.CadetBlue; table.Style.HeaderStyle.Font = new PdfFont(PdfFontFamily.TimesRoman, 13f); table.Style.HeaderStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Center); table.Style.ShowHeader = true; table.DataSourceType = PdfTableDataSourceType.TableDirect; table.DataSource = dtNames; //Set the width of column float width = page.Canvas.ClientSize.Width - (table.Columns.Count + 1); table.Columns[0].Width = width * 0.24f * width; table.Columns[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); table.Columns[1].Width = width * 0.21f * width; table.Columns[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); table.Columns[2].Width = width * 0.24f * width; table.Columns[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); table.Draw(page, new PointF(10, 380)); //save pdfDoc.SaveToFile(@"..\..\index_report.pdf"); //launch the pdf document System.Diagnostics.Process.Start(@"..\..\index_report.pdf"); }
private void CreateAccountButton_Click(object sender, RoutedEventArgs e) { if (CheckInputs() == true) { if (AccountType.SelectedIndex == 4) { priv = "6"; if (Priv1.IsChecked == true) { priv += "2"; } if (Priv2.IsChecked == true) { priv += "3"; } if (Priv3.IsChecked == true) { priv += "4"; } dbman = new DBConnectionManager(); pmsutil = new PMSUtil(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { string uid = Application.Current.Resources["uid"].ToString(); string[] dt = pmsutil.GetServerDateTime().Split(null); DateTime cDate = Convert.ToDateTime(dt[0]); DateTime cTime = DateTime.Parse(dt[1] + " " + dt[2]); string curDate = cDate.ToString("yyyy-MM-dd"); string curTime = cTime.ToString("HH:mm:ss"); string accID = pmsutil.GenAccountID(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO accounts(account_id, user_name, pass_key, account_type)" + "VALUES(@account_id, @user_name, @pass_key, @account_type)"; cmd.Prepare(); cmd.Parameters.AddWithValue("@account_id", accID); cmd.Parameters.AddWithValue("@user_name", Username.Text); cmd.Parameters.AddWithValue("@pass_key", SecurePasswordHasher.Hash(Password.Text)); cmd.Parameters.AddWithValue("@account_type", Convert.ToInt32(priv)); int stat_code = cmd.ExecuteNonQuery(); conn.Close(); conn.Open(); cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO accounts_info(account_id, name, date_created, time_created, creator)" + "VALUES(@account_id, @emp_name, @date_created, @time_created, @creator)"; cmd.Prepare(); cmd.Parameters.AddWithValue("@account_id", accID); cmd.Parameters.AddWithValue("@emp_name", Username.Text); cmd.Parameters.AddWithValue("@date_created", curDate); cmd.Parameters.AddWithValue("@time_created", curTime); cmd.Parameters.AddWithValue("@creator", uid); stat_code = cmd.ExecuteNonQuery(); conn.Close(); if (stat_code > 0) { _caller.SyncAccounts(); MsgSuccess(); pmsutil.LogAccount("Created an account - Username: "******" Type: " + Convert.ToInt32(priv)); this.Close(); } else { MsgFail(); } } else { } } } else { dbman = new DBConnectionManager(); pmsutil = new PMSUtil(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { string uid = Application.Current.Resources["uid"].ToString(); string[] dt = pmsutil.GetServerDateTime().Split(null); DateTime cDate = Convert.ToDateTime(dt[0]); DateTime cTime = DateTime.Parse(dt[1] + " " + dt[2]); string curDate = cDate.ToString("yyyy-MM-dd"); string curTime = cTime.ToString("HH:mm:ss"); string accID = pmsutil.GenAccountID(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO accounts(account_id, user_name, pass_key, account_type)" + "VALUES(@account_id, @user_name, @pass_key, @account_type)"; cmd.Prepare(); cmd.Parameters.AddWithValue("@account_id", accID); cmd.Parameters.AddWithValue("@user_name", Username.Text); cmd.Parameters.AddWithValue("@pass_key", SecurePasswordHasher.Hash(Password.Text)); cmd.Parameters.AddWithValue("@account_type", Convert.ToInt32(AccountType.SelectedIndex + 1)); int stat_code = cmd.ExecuteNonQuery(); conn.Close(); conn.Open(); cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO accounts_info(account_id, name, date_created, time_created, creator)" + "VALUES(@account_id, @emp_name, @date_created, @time_created, @creator)"; cmd.Prepare(); cmd.Parameters.AddWithValue("@account_id", accID); cmd.Parameters.AddWithValue("@emp_name", Username.Text); cmd.Parameters.AddWithValue("@date_created", curDate); cmd.Parameters.AddWithValue("@time_created", curTime); cmd.Parameters.AddWithValue("@creator", uid); stat_code = cmd.ExecuteNonQuery(); conn.Close(); if (stat_code > 0) { MsgSuccess(); pmsutil.LogAccount("Created an account - Username: "******" Type: " + Convert.ToInt32(priv)); this.Close(); } else { MsgFail(); } } else { } } } } else { } }