Пример #1
0
        private void btnCloseJob_Click(object sender, EventArgs e)
        {
            RadioButton radChoice = new RadioButton();

            try {
                radChoice = gbContactOutcome.Controls.OfType <RadioButton>().First(r => r.Checked);
            }
            catch (System.Exception err) {
                string a = err.Message;
                MessageBox.Show("Please choose a reason for closing job", msgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            JobContact jobcontact = new JobContact();

            jobcontact.JobID       = Convert.ToInt32(job.JobID);
            jobcontact.LinkID      = job.ClientID;
            jobcontact.AttributeID = Convert.ToInt32(radChoice.Tag);
            jobcontact.Note        = rtbContactNotes.Text;
            job.Notes += Environment.NewLine + "Job Closure Note: " + rtbContactNotes.Text == string.Empty || rtbContactNotes.ForeColor == Color.White ? radChoice.Text : rtbContactNotes.Text;
            job.UpdateJob(false);

            string msg = jobcontact.AddJobContact();

            if (msg == "Successfully updated job")
            {
                MessageBox.Show(msg, msgBoxTitle);
            }
            else
            {
                MessageBox.Show(msg, msgBoxTitle);
            }
            LoadTreeView();
            ResetRightPanel();
        }
Пример #2
0
        private void LoadJobContactDetails(JobContact jobcontact)
        {
            txtJobID.Text = jobcontact.JobID.ToString();
            rtbContactNotes.Clear();
            rtbContactNotes.Text  = "Entered by: " + jobcontact.EnteredBy;
            rtbContactNotes.Text += Environment.NewLine + "Entered at: " + jobcontact.EnteredAt.ToShortDateString() + "  " + jobcontact.EnteredAt.ToShortTimeString().Substring(0, 5);
            rtbContactNotes.Text += Environment.NewLine + (jobcontact.PhoneUsed.ToString() == "*" ? "see below" : "Phone used: " + jobcontact.PhoneUsed.ToString());
            rtbContactNotes.Text += Environment.NewLine + "Notes:";
            rtbContactNotes.Text += Environment.NewLine + jobcontact.Note;

            rtbContactNotes.BackColor = Color.White;
            rtbContactNotes.ForeColor = rtbJobDetailsL1.ForeColor;
        }
Пример #3
0
        public void LoadJobContacts()
        {
            OleDbConnection sqlConnection = new OleDbConnection();

            sqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["TransManager"].ToString();

            using (sqlConnection)
            {
                jobcontacts.Clear();

                sqlConnection.Open();

                OleDbCommand    cmd = new OleDbCommand();
                OleDbDataReader dr;

                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = "SELECT * FROM vwjobAttributes WHERE JobID = @var1 ORDER BY EnteredAt ASC";

                cmd.Parameters.Add(new OleDbParameter("@var1", _jobid));

                cmd.Connection = sqlConnection;
                Log.WriteCommand(cmd);
                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    JobContact jobcontact = new JobContact();
                    jobcontact.JobID          = _jobid;
                    jobcontact.ContactID      = dr.GetInt32(dr.GetOrdinal("JobAttributeID"));
                    jobcontact.AttributeID    = dr.GetInt32(dr.GetOrdinal("AttributeID"));
                    jobcontact.LinkID         = dr.GetInt32(dr.GetOrdinal("LinkID"));
                    jobcontact.LinkName       = dr.GetValue(dr.GetOrdinal("LinkName")).ToString();
                    jobcontact.LinkType       = dr.GetValue(dr.GetOrdinal("LinkType")).ToString();
                    jobcontact.AttributeLevel = dr.GetInt32(dr.GetOrdinal("AttributeLevel"));
                    jobcontact.AttributeID    = dr.GetInt32(dr.GetOrdinal("AttributeID"));
                    jobcontact.PhoneUsed      = dr.GetValue(dr.GetOrdinal("PhoneUsed")).ToString();
                    jobcontact.Note           = dr.GetValue(dr.GetOrdinal("Notes")).ToString();
                    jobcontact.Action         = dr.GetValue(dr.GetOrdinal("AttributeText")).ToString();
                    jobcontact.EnteredAt      = dr.GetDateTime(dr.GetOrdinal("EnteredAt"));
                    jobcontact.EnteredBy      = dr.GetValue(dr.GetOrdinal("EnteredBy")).ToString();
                    jobcontacts.Add(jobcontact);
                }

                sqlConnection.Close();
            }
        }
Пример #4
0
        private void tvJobs_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (tvJobs.SelectedNode.Level > 0)
            {
                job                     = new Job(Convert.ToInt32((tvJobs.SelectedNode.Level == 1) ? tvJobs.SelectedNode.Name : tvJobs.SelectedNode.Parent.Name));
                client                  = new Client(job.ClientID, false);
                lblAdditional.Text      = "Additional Notes";
                lblAdditional.BackColor = Color.Transparent;

                //if (tvJobs.SelectedNode.Level == 1)
                //{

                try {
                    if (job.JobID != Convert.ToInt32(txtJobID.Text.ToString()))
                    {
                        LoadJobDetails(job);
                    }
                }
                catch (SystemException err) {
                    //Error means that txtJobID was not numeric so reload anyhow
                    LoadJobDetails(job);
                }

                //}

                if (tvJobs.SelectedNode.Level == 2)
                {
                    job.LoadJobContacts();
                    JobContact jobcontact = job.jobcontacts.Where(j => j.ContactID == Convert.ToInt32(tvJobs.SelectedNode.Name)).First <JobContact>();
                    LoadJobContactDetails(jobcontact);
                    lblAdditional.Text      = jobcontact.Action;
                    lblAdditional.BackColor = Color.CadetBlue;
                }
                txtJobStatus.Text = job.Status;
                //btnCloseJob.Enabled =  true;
            }
        }
Пример #5
0
        public string UpdateJob(bool bApptChange)
        {
            try
            {
                OleDbConnection sqlConnection = new OleDbConnection();

                sqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["TransManager"].ToString();

                using (sqlConnection)
                {
                    sqlConnection.Open();

                    OleDbCommand cmd = new OleDbCommand();
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = "UPDATE Jobs SET Notes = @var1, JobDate = @var2, DVCWheelchairNeeded = @var3, JobSourceID = @var4 WHERE JobID = @var5";

                    cmd.Parameters.Add(new OleDbParameter("@var1", _notes));
                    cmd.Parameters.Add(new OleDbParameter("@var2", _jobdate));
                    cmd.Parameters.Add(new OleDbParameter("@var3", _DVCwheelchair));
                    cmd.Parameters.Add(new OleDbParameter("@var4", _sourceid));
                    cmd.Parameters.Add(new OleDbParameter("@var5", _jobid));
                    cmd.Connection = sqlConnection;
                    Log.WriteCommand(cmd);
                    cmd.ExecuteScalar();

                    for (Int32 i = 0; i < this.joblegs.Count; i++)
                    {
                        cmd.Parameters.Clear();
                        if (joblegs[i].JobSequenceID == 0)
                        {
                            cmd.CommandText = "INSERT INTO JobLegs(JobID, LegID, DriverID, DestinationStartID, DestinationEndID, JobPickUpTime, JobAppointmentTime, EnteredBy) SELECT @var1, @var2, @var3, @var4, @var5, @var6, @var7, @var8";
                            cmd.Parameters.Add(new OleDbParameter("@var1", _jobid));
                            cmd.Parameters.Add(new OleDbParameter("@var2", i + 1));
                            cmd.Parameters.Add(new OleDbParameter("@var3", joblegs[i].DriverID));
                            cmd.Parameters.Add(new OleDbParameter("@var4", joblegs[i].PickUpDestinationID));
                            cmd.Parameters.Add(new OleDbParameter("@var5", joblegs[i].DropDestinationID));
                            cmd.Parameters.Add(new OleDbParameter("@var6", joblegs[i].PickUpTime));

                            cmd.Parameters.Add(new OleDbParameter("@var7", joblegs[i].AppointmentTime));
                            cmd.Parameters.Add(new OleDbParameter("@var8", (User.CurrentUserName == null ? "Unknown" : User.CurrentUserName)));
                            cmd.ExecuteScalar();
                        }
                        else
                        {
                            cmd.CommandText = "UPDATE JobLegs SET LegID = @var1, DriverID=@var2, DestinationStartID =@var3, DestinationEndID = @var4, JobPickUpTime = @var5, JobAppointmentTime = @var6 WHERE JobSequenceId = @var7";
                            cmd.Parameters.Add(new OleDbParameter("@var1", i + 1));
                            cmd.Parameters.Add(new OleDbParameter("@var2", joblegs[i].DriverID));
                            cmd.Parameters.Add(new OleDbParameter("@var3", joblegs[i].PickUpDestinationID));
                            cmd.Parameters.Add(new OleDbParameter("@var4", joblegs[i].DropDestinationID));
                            cmd.Parameters.Add(new OleDbParameter("@var5", joblegs[i].PickUpTime));

                            cmd.Parameters.Add(new OleDbParameter("@var6", joblegs[i].AppointmentTime));
                            cmd.Parameters.Add(new OleDbParameter("@var7", joblegs[i].JobSequenceID));
                            Log.WriteCommand(cmd);
                            cmd.ExecuteScalar();
                        }
                        //update job status to 8 if appt change
                        if (bApptChange && i == 0)
                        {
                            JobContact jobcontact = new JobContact();
                            jobcontact.JobID       = _jobid;
                            jobcontact.LinkID      = _clientid;
                            jobcontact.AttributeID = 49;
                            jobcontact.Note        = "Appointment Time Changed - Driver needs to be informed";

                            string msg = jobcontact.AddJobContact();

                            if (msg != "Successfully updated job")
                            {
                                throw new Exception("Failed to update job status");
                            }
                        }
                    }
                }
            }
            catch (SystemException e)
            {
                return(e.Message);
            }

            return("Successfully updated job");
        }
Пример #6
0
        public string AddJob()
        {
            try {
                OleDbConnection sqlConnection = new OleDbConnection();

                sqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["TransManager"].ToString();

                using (sqlConnection)
                {
                    sqlConnection.Open();

                    OleDbCommand cmd = new OleDbCommand();
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = "INSERT INTO Jobs(ClientID, Notes, JobDate, DVCWheelchairNeeded, JobSourceID, EnteredBy) SELECT @var1, @var2, @var3, @var4, @var5, @var6";

                    cmd.Parameters.Add(new OleDbParameter("@var1", _clientid));
                    cmd.Parameters.Add(new OleDbParameter("@var2", _notes));
                    cmd.Parameters.Add(new OleDbParameter("@var3", _jobdate));
                    cmd.Parameters.Add(new OleDbParameter("@var4", _DVCwheelchair));
                    cmd.Parameters.Add(new OleDbParameter("@var5", _sourceid));
                    cmd.Parameters.Add(new OleDbParameter("@var6", (User.CurrentUserName == null ? "Unknown" : User.CurrentUserName)));
                    cmd.Connection = sqlConnection;

                    Log.WriteCommand(cmd);
                    cmd.ExecuteScalar();

                    cmd.CommandText = "select @@IDENTITY";

                    _jobid = (int)cmd.ExecuteScalar();
                    Int32 i;

                    for (i = 0; i < this.joblegs.Count; i++)
                    {
                        cmd.Parameters.Clear();
                        cmd.CommandText = "INSERT INTO JobLegs(JobID, LegID, DriverID, DestinationStartID, DestinationEndID, JobPickUpTime, JobAppointmentTime, EnteredBy) SELECT @var1, @var2, @var3, @var4, @var5, @var6, @var7, @var8";
                        cmd.Parameters.Add(new OleDbParameter("@var1", _jobid));
                        cmd.Parameters.Add(new OleDbParameter("@var2", i + 1));
                        cmd.Parameters.Add(new OleDbParameter("@var3", joblegs[i].DriverID));
                        cmd.Parameters.Add(new OleDbParameter("@var4", joblegs[i].PickUpDestinationID));
                        cmd.Parameters.Add(new OleDbParameter("@var5", joblegs[i].DropDestinationID));
                        cmd.Parameters.Add(new OleDbParameter("@var6", joblegs[i].PickUpTime));

                        cmd.Parameters.Add(new OleDbParameter("@var7", joblegs[i].AppointmentTime));
                        cmd.Parameters.Add(new OleDbParameter("@var8", (User.CurrentUserName == null ? "Unknown" : User.CurrentUserName)));
                        Log.WriteCommand(cmd);
                        cmd.ExecuteScalar();
                    }

                    //If job is sourced by driver we will need to record contacts for both
                    //driver and client to bring status up to date.
                    if (_sourceid == 2)
                    {
                        JobContact jobcontact = new JobContact();
                        jobcontact.JobID       = _jobid;
                        jobcontact.LinkID      = joblegs[0].DriverID;
                        jobcontact.AttributeID = 21;
                        jobcontact.Note        = "Driver phoned this job through.";
                        jobcontact.PhoneUsed   = "*";
                        jobcontact.AddJobContact();

                        //add the client contact.
                        jobcontact.LinkID      = _clientid;
                        jobcontact.AttributeID = 26;
                        jobcontact.Note        = "Driver phoned this job through - already arranged with client.";
                        jobcontact.PhoneUsed   = "*";
                        jobcontact.AddJobContact();
                    }
                }
            }
            catch (SystemException e)
            {
                return(e.Message);
            }

            return("Successfully added job");
        }