using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using Microsoft.Dexterity.Applications.DynamicsDictionary;
using Microsoft.Dexterity.Applications.ProjectAccountingDictionary;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Microsoft.Dexterity.Bridge;
using Microsoft.Dexterity.Applications;
using Microsoft.Dexterity.Shell;
namespace ViewAgenciesByJob
{
public partial class ViewAgenciesByJobs : DexUIForm
{
// Create a reference to the Project Billing Entry Window
static PaBillingEntryForm PaBillingEntryForm = ProjectAccounting.Forms.PaBillingEntry;
static PaBillingEntryForm.PaBillingEntryWindow PaBillingEntryWindow = PaBillingEntryForm.PaBillingEntry;
/* Setup PA Billing Entry form so you send back value for Customer ID */
private System.Data.SqlClient.SqlConnection jobconnection;
private System.Data.DataSet AgenciesByJobsDataSet;
private System.Data.SqlClient.SqlCommand AgenciesByJobsCommand;
private System.Data.SqlClient.SqlDataAdapter DataAdapter;
/* Define connection string */
string connectionString = "";
public ViewAgenciesByJobs(string cs)
{
connectionString = cs;
InitializeComponent();
try
{
/* Define the data set for Agencies by Jobs */
jobconnection = new System.Data.SqlClient.SqlConnection(connectionString);
/* Open the connection */
jobconnection.Open();
AgenciesByJobsDataSet = new System.Data.DataSet();
AgenciesByJobsDataSet.CaseSensitive = false;
AgenciesByJobsCommand = new System.Data.SqlClient.SqlCommand();
AgenciesByJobsCommand.Connection = jobconnection;
AgenciesByJobsCommand.CommandText = "SELECT JOBNUMBER,AGENCY FROM JOBS ORDER BY JOBNUMBER";
DataAdapter = new System.Data.SqlClient.SqlDataAdapter();
DataAdapter.SelectCommand = AgenciesByJobsCommand;
DataAdapter.TableMappings.Add("Table", "AgenciesByJobs");
DataAdapter.Fill(AgenciesByJobsDataSet);
dgvAgenciesByJobs.ReadOnly = true;
dgvAgenciesByJobs.RowHeadersVisible = false;
dgvAgenciesByJobs.AllowUserToResizeColumns = false;
dgvAgenciesByJobs.AllowUserToResizeRows = false;
dgvAgenciesByJobs.DataSource = AgenciesByJobsDataSet.Tables["AgenciesByJobs"].DefaultView;
dgvAgenciesByJobs.Columns[0].Width = 85;
dgvAgenciesByJobs.Columns[0].HeaderText = "Job Number";
dgvAgenciesByJobs.Columns[1].Width = 95;
dgvAgenciesByJobs.Columns[1].HeaderText = "Agency Code";
/* Extract customer number value from current row to pass back to Billing Entry screen */
/* CustomerNumber = AgenciesByJobsDataSet.Tables["AgenciesByJobs"].Rows[0]["AGENCY"].ToString(); */
/* CustomerNumber = dgvAgenciesByJobs.CurrentCell.Value.ToString(); */
/* PaBillingEntryWindow.CustomerNumber.Value = dgvAgenciesByJobs.CurrentCell.Value.ToString(); */
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
/* Close the job connection */
try
{
jobconnection.Close();
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Hide();
this.Dispose();
}
private void dgvAgenciesByJobs_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int CurrentRow;
CurrentRow = dgvAgenciesByJobs.CurrentCell.RowIndex;
dgvAgenciesByJobs.CurrentCell = dgvAgenciesByJobs[1, CurrentRow];
PaBillingEntryWindow.CustomerNumber.Value = dgvAgenciesByJobs.CurrentCell.Value.ToString();
}
}
}
AgenciesByJobs.jpg
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.