Esempio n. 1
0
        private void crewButton_Click(object sender, EventArgs e)
        {
            string selectedJobID = this.extendedDataGridView1.SelectedCells[0].Value.ToString();
            string jobID = "";

            if (this.extendedDataGridView1.SelectedCells.Count == 1)
                jobID = this.extendedDataGridView1.SelectedCells[0].Value.ToString();

            //if only one is selected, send it JobID to initialize
            AddCrewDialog dlg = new AddCrewDialog(jobID);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    foreach (DataGridViewRow dataGridViewRow in extendedDataGridView1.SelectedRows)
                    {
                        jobID = dataGridViewRow.Cells[0].Value.ToString();
                        if (jobID != "") dlg.UpdateCreateCrew(jobID);
                    }
                    //refresh the data as it has been changed by the dialog
                    crewNameTableAdapter.FillBy(this.mMSDataSet.CrewName, Convert.ToInt32(selectedJobID));
                }
                catch (Exception exe)
                {
                    MMSUtility.LogFile(exe.Message, e.ToString(), ((Control)sender).Name, exe.LineNumber(), "ScheduleView");
                }
            }
        }
Esempio n. 2
0
        //add crew via datagrid multi-select
        private void assignCrewButton_Click(object sender, EventArgs e)
        {
            bool bRefesh4Step = false;
            string jobID = "";
            string propID = "";
            if (extendedDataGridView1.SelectedRows.Count == 1)
            {
                jobID = extendedDataGridView1.SelectedCells[0].Value.ToString();
            }

            AddCrewDialog dlg = new AddCrewDialog(jobID);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    foreach (DataGridViewRow dataGridViewRow in extendedDataGridView1.SelectedRows)
                    {
                        jobID = dataGridViewRow.Cells[0].Value.ToString();
                        propID = dataGridViewRow.Cells[10].Value.ToString();
                        string szCrewKey = dlg.UpdateCreateCrew(jobID);

                        //get crewkey and update each job assigned
                        customerJobTableAdapter.UpdateCrewKey(szCrewKey, Convert.ToInt32(jobID));
                        if (dlg.AssignDate)
                        {
                            customerJobTableAdapter.UpdateJobDate(dlg.selecteddate, Convert.ToInt32(jobID));

                            if (dataGridViewRow.Cells[12].Value.ToString() == "True") //is it fourstep?
                            {
                                //add date to fourstep job
                                if (dataGridViewRow.Cells[24].Value.ToString() == "True") //step 4
                                {
                                    serviceTableAdapter.UpdateStep4DateProp(dlg.selecteddate, Convert.ToInt32(propID));
                                    bRefesh4Step = true;
                                }
                                else if (dataGridViewRow.Cells[23].Value.ToString() == "True") //step 3
                                {
                                    serviceTableAdapter.UpdateStep3DateProp(dlg.selecteddate, Convert.ToInt32(propID));
                                    bRefesh4Step = true;
                                }
                                else if (dataGridViewRow.Cells[22].Value.ToString() == "True") //step 2
                                {
                                    serviceTableAdapter.UpdateStep2DateProp(dlg.selecteddate, Convert.ToInt32(propID));
                                    bRefesh4Step = true;
                                }
                                else if (dataGridViewRow.Cells[21].Value.ToString() == "True") //step 1
                                {
                                    serviceTableAdapter.UpdateStep1DateProp(dlg.selecteddate, Convert.ToInt32(propID));
                                    bRefesh4Step = true;
                                }
                            }

                        }
                        //else
                        //    customerJobTableAdapter.UpdateJobDate(null, Convert.ToInt32(jobID));
                    }
                    crewNameTableAdapter.FillBy(this.mMSDataSet.CrewName, Convert.ToInt32(jobID));
                    if (bRefesh4Step)
                    {
                        MainForm pParent = (MainForm) this.ParentForm;
                        pParent.RefreshServiceFourStepView();
                    }
                    RefreshView();
                    MMSUtility.PlayAcceptSound();
                }
                catch (Exception exe)
                {
                    string message = "JobID =" + jobID + "- PropID" + propID;
                    MMSUtility.LogFile(exe.Message, message, ((Control)sender).Name, exe.LineNumber(), "ScheduleView");
                    //MMSUtility.LogFile(exe.Message, e.ToString(), ((Control)sender).Name, exe.LineNumber(), "ScheduleView");
                }
            }
        }