Click here to Skip to main content
15,908,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
here is my code;

C#
namespace SDKTrackit
{
    public partial class Form1 : Form
    {
       string connString = ConfigurationManager.ConnectionStrings["load"].ConnectionString.ToString();
       private SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["track"].ToString());
       
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DatabaseContext.Initialise("NFS_INDUSTRIAL", "EvolutionCommon", "ANGELICA-NB", "TrackitTest", "trackit", "DE07110052", "2328785");

            SqlConnection con = new SqlConnection(connString);
            con.Open();

            
            SqlCommand comm = new SqlCommand("timesheetProc", con);
            SqlCommand comm1 = new SqlCommand("ECSflag", con);
            SqlCommand comm2 = new SqlCommand("ECSLinesUpdate", con);

            SqlDataAdapter adpt = new SqlDataAdapter(comm);
            DataTable data = new DataTable();
            adpt.Fill(data);

            
            

            foreach (DataRow row in data.Rows)
            {
                string clientName = row["client_name"].ToString();
                string accountCode = row["account_code"].ToString();
                string projectCode = row["project_code"].ToString();
                int taskID = Convert.ToInt32(row["task_id"]);
                
                int flag = Convert.ToInt32(row["flag"]);
                int projectLink = Convert.ToInt32(row["project_link"]);

                

            

                JobCard jc = new JobCard();

                jc.PostingMethod = JobPostingMethod.CompletedContract;

                jc.Status = Pastel.Evolution.JobCard.JobStatus.Active;

                 jc.Account = new Customer(accountCode);
                   

                 JobDetail jd = new JobDetail();
    
                 jd.TransactionCode = new JobTransactionCode(JobDetail.TransactionSource.Inventory, "ST");

                 jd.Status = Pastel.Evolution.JobCard.JobStatus.Active;

                 jd.InventoryItem = new InventoryItem(taskID);

                 jd.Project = new Project(projectLink); //My error is here;im unable to assign a project to the job card
                                                      
                       

                jd.Warehouse = new Warehouse("CPT");

                jd.UnitSellingPrice = jd.InventoryItem.SellingPrices[jc.Account.DefaultPriceListID].PriceIncl;

                jd.Quantity = 2;

                jc.Detail.Add(jd);



               jc.Save();

              
                      

           }
            comm.ExecuteNonQuery();
            
            con.Close();

            MessageBox.Show("Job Card Created");
            
        }
    }
}

It works, however, I am unable to assign a project to the job card using this code. I have to manually assign the project to the job card in pastel..
Is there any way that i can assign a project to the job card automatically when the code runs?
Posted
Updated 31-Aug-14 21:35pm
v3
Comments
Richard MacCutchan 1-Sep-14 3:14am    
You need to explain where, in the above code, the error occurs.
Member 10774831 1-Sep-14 3:37am    
Okay.. i have just commented where my error occurs.. the program just terminates when it gets there.
Richard MacCutchan 1-Sep-14 3:44am    
Sorry that tells us nothing. Use your debugger to gather some proper information in order to help people to understand what may be happening.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900