Ejemplo n.º 1
0
        private void CreateJobs(bool IsScheduleDate, DateTime date, bool bIsFourStep)
        {
            string strPropID = "";
            int nTotalJob = nJobCount;

            //SelectDateDialog datedlg = new SelectDateDialog("Schedule Job");
            //if (datedlg.ShowDialog() == DialogResult.Cancel)
            //{
            //    return;
            //}

            //has to be in all mode
            if (!AllFilterCheckBox.Checked)
            {
                AllFilterCheckBox.Checked = true;
                FilterComboBox_SelectedIndexChanged(null, null);
            }
            if (filterTextBox.Text.Length > 0)
            {
                filterTextBox.Text = "";
                filterTextBox_TextChanged(null, null);
            }

            DateTime strDate = date;
            string strCost = "0";
            string strCostB = "0";
            string strCostC = "0";
            string strCostD = "0";
            string strRevenue = "0";
            string strMaterialCost = "0";
            string strContractCost = "0";
            string strFourStepCost = "0";
            string strInstruct = "";
            string strNotes = "";
            string strStatus = "Pending";
            MainForm pParent = (MainForm)this.ParentForm;
            pParent.enableMainButtons(false);
            bool bFourStepJob = false;
            string strFourStepMat = "0";

            int nCount = 0;
            int rowCount = serviceDataGridView.RowCount;
            //int rowCount = nUpperBound-nLowerBound;

            Cursor.Current = Cursors.WaitCursor;

            pParent.ProgressBarInit(0, rowCount, 1);
            for (int row = 0; row < rowCount; row++)
            //for (int row = nLowerBound; row <= nUpperBound; row++)
            {
                //for (int j = 9; j <= 15; j++)
                for (int j = nLeftBound; j <= nRightBound; j++)
                {
                    if (this.serviceDataGridView.Rows[row].Cells[j].Value.ToString() == "True")
                    {
                        try
                        {
                            string serviceId = this.serviceDataGridView.Rows[row].Cells[18].Value.ToString();
                            System.Windows.Forms.MMS.Data.MMSDataSet.PropServiceDataTable myDataTable =
                                new System.Windows.Forms.MMS.Data.MMSDataSet.PropServiceDataTable();
                            propServiceTableAdapter.FillBy(myDataTable, Convert.ToInt32(serviceId));
                            DataRow dRow = myDataTable.Rows[0];
                            strFourStepMat = "0";

                            strPropID = this.serviceDataGridView.Rows[row].Cells[17].Value.ToString();
                            strPropID = dRow["PropertyID"].ToString();

                            string strType = "";

                            switch (j)
                            {
                                case 9:
                                    strType = "Mow";
                                    strCost = dRow["Cost"].ToString();
                                    strContractCost = dRow["ContractorCost"].ToString();
                                    strInstruct = dRow["specInstruct"].ToString(); //used for MOW
                                    //strInstruct = this.specInstructTextBox.Text;
                                    strNotes = dRow["Notes"].ToString();
                                    break;
                                case 10:
                                    strType = "Leaf";
                                    strCost = dRow["CostB"].ToString();
                                    strContractCost = dRow["CCostB"].ToString();
                                    strInstruct = dRow["leafInstruct"].ToString();
                                    //strInstruct = this.leafInstructTextBox.Text;
                                    strNotes = dRow["Notes"].ToString();
                                    break;
                                case 11:
                                    strType = "Gutter";
                                    strCost = dRow["CostC"].ToString();
                                    strContractCost = dRow["CCostC"].ToString();
                                    strInstruct = dRow["gutterInstruct"].ToString();
                                    //strInstruct = this.gutterInstructTextBox.Text;
                                    strNotes = dRow["Notes"].ToString();
                                    break;
                                case 12:
                                    strType = "App";
                                    strCost = dRow["CostApp"].ToString();
                                    strContractCost = dRow["CCostApp"].ToString();
                                    strInstruct = dRow["appInstruct"].ToString();
                                    //strInstruct = this.appInstructTextBox.Text;
                                    strNotes = dRow["Notes"].ToString();
                                    break;
                                case 13:
                                    strType = "Prune";
                                    strCost = dRow["CostPruning"].ToString();
                                    strContractCost = dRow["CCostPruning"].ToString();
                                    strInstruct = dRow["pruneInstruct"].ToString();
                                    //strInstruct = this.pruneInstructTextBox1.Text;
                                    break;
                                case 14:
                                    strType = "Mulch";
                                    strCost = dRow["CostMulching"].ToString();
                                    strContractCost = dRow["CCostMulching"].ToString();
                                    strInstruct = dRow["mulchInstruct"].ToString();
                                    //strInstruct = this.mulchInstructTextBox.Text;
                                    strNotes = dRow["Notes"].ToString();
                                    break;
                                case 15:
                                    strType = "Other";
                                    strCost = dRow["CostOther"].ToString();
                                    strContractCost = dRow["CCostOther"].ToString();
                                    strInstruct = dRow["otherInstruct"].ToString();
                                    //strInstruct = this.otherInstructTextBox.Text;
                                    strNotes = dRow["Notes"].ToString();
                                    break;
                            }
                            if (bIsFourStep)
                            {
                                strCost = dRow["FourStepCost"].ToString();
                                strContractCost = "0.00";
                                strFourStepCost = dRow["FourStepCost"].ToString();
                                //strInstruct = this.fourStepInstructTextBox.Text;
                                strInstruct = dRow["fourStepInstruct"].ToString();
                                bFourStepJob = true;
                                strMaterialCost = dRow["FourStepCost"].ToString();
                                strFourStepMat = dRow["FourStepMat"].ToString();
                                strNotes = dRow["Notes"].ToString();
                            }

                            if (strCost == "") strCost = "0.00";
                            if (strContractCost == "") strContractCost = "0.00";
                            if (strFourStepMat == "") strFourStepMat = "0";
                            if (strFourStepCost == "") strFourStepCost = "0.00";
                            if (strMaterialCost == "") strMaterialCost = "0.00";

                            int id = 0;
                            if (IsScheduleDate)
                            {
                                id = Convert.ToInt32(customerJobTableAdapter.InsertQuery(strDate, strType,
                                    Convert.ToDecimal(strCost), Convert.ToDecimal(strContractCost),
                                    Convert.ToDecimal(strFourStepCost), strInstruct, Convert.ToInt32(strPropID),
                                    strStatus,
                                    Convert.ToDecimal(strCostB), Convert.ToDecimal(strCostC), Convert.ToDecimal(strCostD),
                                    Convert.ToDecimal(strRevenue), bFourStepJob, Convert.ToDecimal(strMaterialCost),
                                    (float) Convert.ToDouble(strFourStepMat), strNotes, false, false, false, false));
                            }
                            else
                            {
                                id = Convert.ToInt32(customerJobTableAdapter.InsertQuery(null, strType,
                                    Convert.ToDecimal(strCost), Convert.ToDecimal(strContractCost),
                                    Convert.ToDecimal(strFourStepCost), strInstruct, Convert.ToInt32(strPropID),
                                    strStatus,
                                    Convert.ToDecimal(strCostB), Convert.ToDecimal(strCostC), Convert.ToDecimal(strCostD),
                                    Convert.ToDecimal(strRevenue), bFourStepJob, Convert.ToDecimal(strMaterialCost),
                                    (float) Convert.ToDouble(strFourStepMat), strNotes, false, false, false, false));

                            }
                            nCount++;

                            //clear it
                            this.serviceDataGridView.Rows[row].Cells[j].Value = "False";
                        }
                        catch (Exception exe)
                        {
                            MMSUtility.LogFile(exe.Message, "CreateJobs", "CreateJobs Function", exe.LineNumber(), "ServiceView");
                        }
                    }
                }
                pParent.ProgressBarUpdate();

                //peformance once all the job is found, leave
                if (nCount >= nTotalJob)
                {
                    pParent.ProgressBarEnd();
                    break;
                }
            }

            if (nCount > 0)
            {
                string strMessage = nCount.ToString() + " Jobs have been created!";
                MessageBox.Show(strMessage, "Job Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MMSUtility.PlayAcceptSound();
            }

            this.Validate();
            this.propServiceBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.mMSDataSet);

            pParent.enableMainButtons(true);
            pParent.RefreshScheduleView();
            bSelected = false;
            bDirty = false;

            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 2
0
        private void CreateJobs(bool IsScheduleDate, DateTime date)
        {
            string strPropID = "";
            int nTotalJob = nJobCount;

            //has to be in all mode
            if (!AllFilterCheckBox.Checked)
            {
                AllFilterCheckBox.Checked = true;
                FilterComboBox_SelectedIndexChanged(null, null);
            }
            if (filterTextBox.Text.Length > 0)
            {
                filterTextBox.Text = "";
                filterTextBox_TextChanged(null, null);
            }

            DateTime strDate = date;
            string strCost = "0";
            string strCostB = "0";
            string strCostC = "0";
            string strCostD = "0";
            string strRevenue = "0";
            string strMaterialCost = "0";
            string strContractCost = "0";
            string strFourStepCost = "0";
            string strInstruct = "";
            string strNotes = "";
            string strStatus = "Pending";
            MainForm pParent = (MainForm)this.ParentForm;
            pParent.enableMainButtons(false);
            string strFourStepMat = "0";

            int nCount = 0;
            int rowCount = serviceDataGridView.RowCount;
            //int rowCount = nUpperBound-nLowerBound;

            Cursor.Current = Cursors.WaitCursor;

            pParent.ProgressBarInit(0, rowCount, 1);
            for (int row = 0; row < rowCount; row++)
            {
                for (int j = nLeftBound; j <= nRightBound; j++)
                {

                    if ((this.serviceDataGridView.Rows[row].Cells[j].Value.ToString() == "True") &&
                        (this.serviceDataGridView.Rows[row].Cells[j].ReadOnly == false))
                    {
                        try
                        {
                            string serviceId = this.serviceDataGridView.Rows[row].Cells[10].Value.ToString();
                            System.Windows.Forms.MMS.Data.MMSDataSet.PropServiceDataTable myDataTable =
                                new System.Windows.Forms.MMS.Data.MMSDataSet.PropServiceDataTable();
                            propServiceTableAdapter.FillBy(myDataTable, Convert.ToInt32(serviceId));
                            DataRow dRow = myDataTable.Rows[0];
                            strFourStepMat = "0";

                            strPropID = this.serviceDataGridView.Rows[row].Cells[11].Value.ToString();
                            strPropID = dRow["PropertyID"].ToString();

                            string strType = "";

                            strType = "App";
                            strCost = dRow["FourStepCost"].ToString();
                            strContractCost = "0.00";
                            strFourStepCost = dRow["FourStepCost"].ToString();
                            //strInstruct = this.fourStepInstructTextBox.Text;
                            strInstruct = dRow["fourStepInstruct"].ToString();
                            strMaterialCost = dRow["FourStepCost"].ToString();
                            strFourStepMat = dRow["FourStepMat"].ToString();
                            strNotes = dRow["Notes"].ToString();

                            if (strCost == "") strCost = "0.00";
                            if (strContractCost == "") strContractCost = "0.00";
                            if (strFourStepMat == "") strFourStepMat = "0";
                            if (strFourStepCost == "") strFourStepCost = "0.00";
                            if (strMaterialCost == "") strMaterialCost = "0.00";

                            bool Step1Job = false;
                            bool Step2Job = false;
                            bool Step3Job = false;
                            bool Step4Job = false;

                            switch (j)
                            {
                                case 5: //Step 1
                                    Step1Job = true;
                                    break;
                                case 6: //Step 2
                                    Step2Job = true;
                                    break;
                                case 7: //Step 3
                                    Step3Job = true;
                                    break;
                                case 8: //Step 4
                                    Step4Job = true;
                                    break;
                            }

                            int id = 0;
                            if (IsScheduleDate)
                            {
                                id = Convert.ToInt32(customerJobTableAdapter.InsertQuery(strDate, strType,
                                    Convert.ToDecimal(strCost), Convert.ToDecimal(strContractCost),
                                    Convert.ToDecimal(strFourStepCost), strInstruct, Convert.ToInt32(strPropID),
                                    strStatus,
                                    Convert.ToDecimal(strCostB), Convert.ToDecimal(strCostC), Convert.ToDecimal(strCostD),
                                    Convert.ToDecimal(strRevenue), true, Convert.ToDecimal(strMaterialCost),
                                    (float) Convert.ToDouble(strFourStepMat), strNotes, Step1Job, Step2Job, Step3Job,
                                    Step4Job));

                                switch (j)
                                {
                                    case 5: //Step 1
                                        serviceTableAdapter.UpdateStep1Date(strDate, Convert.ToInt32(serviceId));
                                        break;
                                    case 6: //Step 2
                                        serviceTableAdapter.UpdateStep2Date(strDate, Convert.ToInt32(serviceId));
                                        break;
                                    case 7: //Step 3
                                        serviceTableAdapter.UpdateStep3Date(strDate, Convert.ToInt32(serviceId));
                                        break;
                                    case 8: //Step 4
                                        serviceTableAdapter.UpdateStep4Date(strDate, Convert.ToInt32(serviceId));
                                        break;
                                }
                            }
                            else
                            {
                                id = Convert.ToInt32(customerJobTableAdapter.InsertQuery(null, strType,
                                    Convert.ToDecimal(strCost), Convert.ToDecimal(strContractCost),
                                    Convert.ToDecimal(strFourStepCost), strInstruct, Convert.ToInt32(strPropID),
                                    strStatus,
                                    Convert.ToDecimal(strCostB), Convert.ToDecimal(strCostC), Convert.ToDecimal(strCostD),
                                    Convert.ToDecimal(strRevenue), true, Convert.ToDecimal(strMaterialCost),
                                    (float) Convert.ToDouble(strFourStepMat), strNotes, Step1Job, Step2Job, Step3Job,
                                    Step4Job));
                            }
                            nCount++;

                            //protected it
                            this.serviceDataGridView.Rows[row].Cells[j].ReadOnly = true;
                            this.serviceDataGridView.Rows[row].Cells[j].Style.ForeColor = Color.Green;
                            this.serviceDataGridView.Rows[row].Cells[j].Style.BackColor = Color.Yellow;
                        }
                        catch (Exception exe)
                        {
                            MMSUtility.LogFile(exe.Message, "Create4StepJobs", "Create4StepJobs Function", exe.LineNumber(), "ServiceFourStepView");
                        }
                    }
                }

                pParent.CheckServiceView();
                pParent.ProgressBarUpdate();
                FourStepJobList.Clear();

                //peformance once all the job is found, leave
                if (nCount >= nTotalJob)
                {
                    pParent.ProgressBarEnd();
                    RefreshView();
                    break;
                }
            }
            this.Validate();
            this.propServiceBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.mMSDataSet);

            if (nCount > 0)
            {
                string strMessage = nCount.ToString() + " Jobs have been created!";
                MessageBox.Show(strMessage, "Job Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MMSUtility.PlayAcceptSound();
            }
            pParent.enableMainButtons(true);
            pParent.RefreshScheduleView();
            bSelected = false;
            bDirty = false;

            Cursor.Current = Cursors.Default;
        }