private void ConfirmPayment_Click(object sender, System.Windows.RoutedEventArgs e) { dbman = new DBConnectionManager(); pmsutil = new PMSUtil(); using (conn = new MySqlConnection(dbman.GetConnStr())) { conn.Open(); if (conn.State == ConnectionState.Open) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "DELETE FROM residing_priests WHERE priest_id = @pid LIMIT 1;"; cmd.Parameters.AddWithValue("@pid", pid); cmd.Prepare(); int stat_code = cmd.ExecuteNonQuery(); conn.Close(); if (stat_code > 0) { priests.SyncPriest(); MsgSuccess(); this.Close(); } else { InfoArea.Foreground = new SolidColorBrush(Colors.Red); InfoArea.Content = "Unable to Delete Selected Priest!"; } } } }
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 EditPriestButton_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) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "UPDATE residing_priests SET priest_name = @priest_name, priest_status = @priest_status WHERE priest_id = @pid"; cmd.Prepare(); cmd.Parameters.AddWithValue("@pid", pid); cmd.Parameters.AddWithValue("@priest_name", PriestName.Text); cmd.Parameters.AddWithValue("@priest_status", Status.Text); int stat_code = cmd.ExecuteNonQuery(); conn.Close(); if (stat_code > 0) { _caller.SyncPriest(); pmsutil.LogAccount("Edited Priest: " + PriestName.Text); MsgSuccess(); this.Close(); } else { MsgFail(); } } else { } } } else { } }