Esempio n. 1
0
        private void ActxtWorkers_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            try
            {
                bool empExists = false;
                foreach (var i in WorkerList)
                {
                    if (actxtWorkers.Text == i.empNAME)
                    {
                        empExists = true;
                    }
                }
                if (actxtWorkers.Text != "" && empExists == false)
                {
                    Employee emp = new Employee();
                    emp.empNAME   = actxtWorkers.Text;
                    emp.empMobile = GetEmployees.getEmpNumber(actxtWorkers.Text);
                    WorkerList.Add(emp);

                    lvSelectedEmps.Adapter = new SelectEmpAdapter(this, WorkerList);
                }
                else
                {
                    Toast.MakeText(this, "Duplicate found.", ToastLength.Long).Show();
                }
                actxtWorkers.Text = "";
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Something went wrong:" + ex.Message, ToastLength.Long).Show();
            }
        }
Esempio n. 2
0
        private void BtnSendAll_Click(object sender, EventArgs e)
        {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);

            alertDialog.SetMessage("Are you sure you want to send all?");
            alertDialog.SetPositiveButton("Yes", delegate
            {
                //loop to go through set jobs and send all the texts at once
                foreach (var job in jobsPlanList)
                {
                    if (job.TextSENT == null)
                    {
                        job.TextSENT = DateTime.Now.ToString("yyyy-MM-dd" + "T" + "HH:mm:ss");                      //adding the text sent timestamp
                        try
                        {
                            objplan.ExecutePutRequest(job);
                        }
                        catch (Exception ex)
                        {
                            Toast.MakeText(this, "Something went wrong: " + ex.Message, ToastLength.Long).Show();
                        }

                        WorkersMSG = "";
                        foreach (var emp in job.EmployeeJobs)
                        {
                            WorkersMSG = WorkersMSG + emp.EmpNAME + ", ";
                        }

                        foreach (var emp in job.EmployeeJobs)
                        {
                            empMobile = GetEmployees.getEmpNumber(emp.EmpNAME);

                            txtMsg = "Team: " + WorkersMSG + "\n" + "Client: " + job.AssignCLIENT + "\n" + "Job Number: " + job.AssignJOBNUM + "\n" + "Area: " + job.AssignAREA + "\nTrucks: " + job.AssignTRUCK + "\n" + "Date: " + Convert.ToDateTime(job.AssignSTARTTIME).ToShortDateString() + "\nStart time: " + Convert.ToDateTime(job.AssignSTARTTIME).TimeOfDay + "\n\nNote: " + job.AssignINSTRUCTIONS;

                            var parts = SmsManager.Default.DivideMessage(txtMsg);
                            SmsManager.Default.SendMultipartTextMessage(empMobile, null, parts, null, null);
                        }
                    }
                }
                jobsPlanList   = objplan.ExecuteGetRequest();
                lvPlan.Adapter = new PlanAdapter(this, jobsPlanList);
            });
            alertDialog.SetNegativeButton("Cancel", delegate
            {
                alertDialog.Dispose();
            });
            alertDialog.Show();
        }
Esempio n. 3
0
        private void ActxtWorkers_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            try
            {
                bool empExists = false;
                foreach (var i in WorkerList)
                {
                    if (actxtWorkers.Text == i.empNAME)
                    {
                        empExists = true;
                    }
                }
                if (actxtWorkers.Text != "" && empExists == false)
                {
                    Employee emp = new Employee();
                    emp.empNAME   = actxtWorkers.Text;
                    emp.empMobile = GetEmployees.getEmpNumber(actxtWorkers.Text);

                    EmployeeJob tempej = new EmployeeJob();
                    tempej.AssignID = ej.AssignID;
                    tempej.EmpNAME  = actxtWorkers.Text;

                    if (objjob.AddEmployeeToJobs(tempej))
                    {
                        WorkerList.Add(emp);
                        lvSelectedEmps.Adapter = new SelectEmpAdapter(this, WorkerList);
                        Toast.MakeText(this, "Worker added to the Job", ToastLength.Long).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "Something went wrong !!! Cannot add worker to jobs , try the website", ToastLength.Long).Show();
                    }
                }
                else
                {
                    Toast.MakeText(this, "Duplicate found.", ToastLength.Long).Show();
                }
                actxtWorkers.Text = "";
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Something went wrong:" + ex.Message, ToastLength.Long).Show();
            }
        }
Esempio n. 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.EditPlanItem);

            WorkerList = new List <Employee>();
            //JobTime = Intent.GetStringExtra("AssignSTARTTIME");
            //JobInstructions = Intent.GetStringExtra("AssignINSTRUCTIONS");
            ////JobDate = Intent.GetStringExtra("JobDate");
            //JobTruckNo = Intent.GetStringExtra("AssignTRUCK");
            //JobName = Intent.GetStringExtra("AssignWork");
            JobID = Intent.GetIntExtra("AssignID", 0);
            //JobClient = Intent.GetStringExtra("AssignCLIENT");
            //JobNumber = Intent.GetIntExtra("AssignJOBNUM", 0);
            //JobArea = Intent.GetStringExtra("AssignAREA");
            ej = objplan.ExecuteGetSelectedRequest(JobID);


            JobDate = Convert.ToDateTime(ej.AssignSTARTTIME).ToShortDateString();
            JobTime = Convert.ToString(Convert.ToDateTime(ej.AssignSTARTTIME).TimeOfDay);
            Button btnBackE = FindViewById <Button>(Resource.Id.btnBackE);

            actxtWorkers    = FindViewById <AutoCompleteTextView>(Resource.Id.actxtWorker);
            btnSave         = FindViewById <Button>(Resource.Id.btnSaveEdited);
            btnDate         = FindViewById <Button>(Resource.Id.btnSelectDate);
            btnTime         = FindViewById <Button>(Resource.Id.btnSelectTime);
            txtSelectedJob  = FindViewById <TextView>(Resource.Id.txtSelectedJob);
            txtArea         = FindViewById <EditText>(Resource.Id.txtArea);
            txtTruckNo      = FindViewById <EditText>(Resource.Id.txtTruckNumbers);
            txtNote         = FindViewById <EditText>(Resource.Id.txtNote);
            lvSelectedEmps  = FindViewById <ListView>(Resource.Id.lvCurrentWorkers);
            txtArea.Text    = ej.AssignAREA;
            txtTruckNo.Text = ej.AssignTRUCK;                                         //showing values in correct areas
            txtNote.Text    = ej.AssignINSTRUCTIONS;

            txtSelectedJob.Text = ej.AssignJOBNUM + " - " + ej.AssignWORK + " - " + ej.AssignCLIENT;
            btnDate.Text        = "Date: " + Convert.ToDateTime(ej.AssignSTARTTIME).ToShortDateString();
            btnTime.Text        = "Start time: " + Convert.ToString(Convert.ToDateTime(ej.AssignSTARTTIME).TimeOfDay);


            foreach (var w in ej.EmployeeJobs)
            {
                Employee emp = new Employee();
                emp.empID     = w.employeeJOBSID;               // storing the employee jobs ID
                emp.empNAME   = w.EmpNAME;
                emp.empMobile = GetEmployees.getEmpNumber(w.EmpNAME);
                WorkerList.Add(emp);

                lvSelectedEmps.Adapter = new SelectEmpAdapter(this, WorkerList);
            }

            var workerAdapter = new ArrayAdapter <string>(this, Resource.Layout.list_item, GetEmployees.getEmpNames());        //autocomplete textbox

            actxtWorkers.Adapter          = workerAdapter;
            btnDate.Click                += BtnDate_Click;
            btnTime.Click                += BtnTime_Click;
            actxtWorkers.ItemClick       += ActxtWorkers_ItemClick;
            lvSelectedEmps.ItemLongClick += LvSelectedEmps_ItemLongClick;
            btnSave.Click                += BtnSave_Click;
            btnBackE.Click               += BtnBack_Click;
        }