Beispiel #1
0
        internal void OKButton_Click(Object eventSender, System.EventArgs eventArgs)
        {
            using (var async1 = this.Async(true))
            {
                //Store filename & path in global variable gExcelPath
                UpgradeHelpers.Helpers.DialogResult Response = (UpgradeHelpers.Helpers.DialogResult) 0;

                string FilePath = modGlobal.Clean(ViewModel.txtFileName.Text);
                if (FilePath == "" || FilePath == "*.xls")
                {
                    ViewManager.ShowMessage("Please indicate FileName", "Error Message", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                    ViewManager.SetCurrent(ViewModel.txtFileName);
                    this.Return();
                    return;
                }

                //Load File Path
                if (ViewModel.Dir1.Path.Substring(Math.Max(ViewModel.Dir1.Path.Length - 1, 0)) == "\\")
                {
                    FilePath = ViewModel.Dir1.Path + FilePath;
                }
                else
                {
                    FilePath = ViewModel.Dir1.Path + "\\" + FilePath;
                }

                //Check for existing file with selected name
                Object FSO = new System.Object();
                if (File.Exists(FilePath))
                {
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(() => ViewManager.ShowMessage("File exists - Overwrite?", "TFD Stats - Excel Export", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                    async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized0 => tempNormalized0);
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized1 =>
                    {
                        Response = tempNormalized1;
                    });
                    async1.Append(() =>
                    {
                        if (Response == UpgradeHelpers.Helpers.DialogResult.No)
                        {
                            this.Return();
                            return;
                        }
                        else
                        {
                            File.Delete(FilePath);
                            FSO = null;
                        }
                    });
                }
                async1.Append(() =>
                {
                    modGlobal.Shared.gExcelPath = FilePath;
                    ViewManager.DisposeView(this);
                });
            }
        }
Beispiel #2
0
        internal void cmdRemove_Click(Object eventSender, System.EventArgs eventArgs)
        {
            using (var async1 = this.Async(true))
            {
                //Remove currently selected employee from
                //currently selected Promotion list

                DbCommand oCmd      = UpgradeHelpers.DB.AdoFactoryManager.GetFactory().CreateCommand();
                string    PromoCode = "";
                UpgradeHelpers.Helpers.DialogResult Response = (UpgradeHelpers.Helpers.DialogResult) 0;

                try
                {
                    {
                        async1.Append <UpgradeHelpers.Helpers.DialogResult>(() =>
                                                                            ViewManager.ShowMessage("This will permanently delete all record of this Promotion!" + "\r" + "Do you wish to continue?",
                                                                                                    "Delete Promotion Record", UpgradeHelpers.Helpers.BoxButtons.YesNo, UpgradeHelpers.Helpers.BoxIcons.Question));
                        async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized0 => tempNormalized0);
                        async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized1 =>
                        {
                            //Warn user on delete request
                            Response = tempNormalized1;
                        });
                        async1.Append(() =>
                        {
                            if (Response == UpgradeHelpers.Helpers.DialogResult.No)
                            {
                                this.Return();
                                return;
                            }

                            oCmd.Connection  = modGlobal.oConn;
                            oCmd.CommandType = CommandType.StoredProcedure;
                            oCmd.CommandText = "spDeletePromotion";
                            oCmd.ExecuteNonQuery(new object[] { ViewModel.CurrPromoID });

                            ClearForm();
                            ViewModel.lbAction.Visible = true;
                            ViewModel.lbAction.Text    = "Promotion Record Removed";

                            //Refresh Promotion List
                            PromoCode = Conversion.Str(ViewModel.cboPromotion.GetItemData(ViewModel.cboPromotion.SelectedIndex)).Trim();
                            LoadList(PromoCode);
                        });
                    }
                }
                catch
                {
                    if (modGlobal.ErrorControl() == modGlobal.eFATALERROR)
                    {
                        this.Return();
                        return;
                    }
                }
            }
        }
Beispiel #3
0
        internal void cmdClose_Click(Object eventSender, System.EventArgs eventArgs)
        {
            using (var async1 = this.Async(true))
            {
                UpgradeHelpers.Helpers.DialogResult Response = (UpgradeHelpers.Helpers.DialogResult) 0;

                if (ViewModel.UpdateFlag != 0)
                {
                    //Update Fields
                }

                if (UpgradeHelpers.Helpers.StringsHelper.ToDoubleSafe(Convert.ToString(ViewModel.cmdNotes.Tag)) == 1 && ViewModel.txtNote.Text != "")
                {
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(() => ViewManager
                                                                        .ShowMessage("The Schedule Notes have not been saved." + "\n" + "\n" + "Did you want to exit now?", "Add Employee Schedule Notes", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                    async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized0 => tempNormalized0);
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized1 =>
                    {
                        Response = tempNormalized1;
                    });
                    async1.Append(() =>
                    {
                        if (Response == UpgradeHelpers.Helpers.DialogResult.No)
                        {
                            ViewManager.SetCurrent(ViewModel.cmdNotes);
                            this.Return();
                            return;
                        }
                    });
                }
                async1.Append(() =>
                {
                    ViewManager.DisposeView(this);
                });
            }
        }
Beispiel #4
0
        internal void cmdInactivate_Click(Object eventSender, System.EventArgs eventArgs)
        {
            using (var async1 = this.Async(true))
            {
                PTSProject.clsScheduler             cTransfer = Container.Resolve <clsScheduler>();
                UpgradeHelpers.Helpers.DialogResult resp      = (UpgradeHelpers.Helpers.DialogResult) 0;
                ViewModel.cmdInactivate.Enabled = false;

                if (ViewModel.CurrPosition == 0)
                {
                    this.Return();
                    return;
                }
                if (cTransfer.GetTransferPositionByID(ViewModel.CurrPosition) != 0)
                {
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(()
                                                                        => ViewManager.ShowMessage("Are you sure you want to Inactivate this Posted Position?", "Inactivate Posted Position", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                    async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized0 => tempNormalized0);
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized1 =>
                    {
                        resp = tempNormalized1;
                    });
                    async1.Append(() =>
                    {
                        if (resp != UpgradeHelpers.Helpers.DialogResult.Yes)
                        {
                            //UPGRADE_ISSUE: (2064) FPSpreadADO.fpSpread method sprPositions.ClearSelection was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                            ViewModel.sprPositions.ClearSelection();
                            ViewModel.CurrPosition = 0;
                            this.Return();
                            return;
                        }
                    });
                }
                else
                {
                    ViewManager.ShowMessage("Ooooops!  There was a problem finding the record in the database.  Try Again", "Find Position Record", UpgradeHelpers.Helpers.BoxButtons.OK);
                    //UPGRADE_ISSUE: (2064) FPSpreadADO.fpSpread method sprPositions.ClearSelection was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                    ViewModel.sprPositions.ClearSelection();
                    ViewModel.CurrPosition = 0;
                    this.Return();
                    return;
                }
                async1.Append(() =>
                {
                    //If you're here... then procede in updating the record and refreshing the list...

                    cTransfer.TransferPositionActiveFlag    = "N";
                    cTransfer.TransferPositionStatusChanged = DateTime.Now.ToString("M/d/yyyy HH:mm:ss");
                    cTransfer.TransferPositionChangedBy     = modGlobal.Shared.gUser;

                    if (cTransfer.UpdateTransferPosition())
                    {
                        //success!!
                    }
                    else
                    {
                        ViewManager.ShowMessage("Ooooops!  Something went wrong updating the Position Record!", "Update Position Record", UpgradeHelpers.Helpers.BoxButtons.OK);
                    }
                    ViewModel.cboReqNameList.SelectedIndex = -1;
                    ViewModel.FilterEmployee = "";
                    ViewModel.cboReqPositionList.SelectedIndex = -1;
                    //UPGRADE_ISSUE: (2064) FPSpreadADO.fpSpread method sprPositions.ClearSelection was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                    ViewModel.sprPositions.ClearSelection();
                    ViewModel.CurrPosition = 0;
                    RefreshPositionLists();
                    FillGrids();
                });
            }
        }
Beispiel #5
0
        internal void cmdAdd_Click(Object eventSender, System.EventArgs eventArgs)
        {
            using (var async1 = this.Async(true))
            {
                dynamic txtExceptDay = null;

                //Add New Employee Record
                //Form data is checked for required fields and field lengths
                //SQLServer spInsertPersonnel stored procedure is called to insert record

                DbCommand          oCmd = UpgradeHelpers.DB.AdoFactoryManager.GetFactory().CreateCommand();
                ADORecordSetHelper oRec = null;
                string             strSQL = "";
                string             NameWork = "";
                byte            Status = 0;
                int             ArcID = 0;
                string          LeaveStatus = "";
                System.DateTime TestDate = DateTime.FromOADate(0);
                string          str1 = "", str2 = "";
                int             i = 0;
                UpgradeHelpers.Helpers.DialogResult Response = (UpgradeHelpers.Helpers.DialogResult) 0;
                string TYear   = "";
                int    iPersID = 0;

                try
                {
                    {
                        oCmd.Connection  = modGlobal.oConn;
                        oCmd.CommandType = CommandType.Text;

                        //Edits
                        //SAP Employee ID number
                        double dbNumericTemp = 0;
                        if (!Double.TryParse(ViewModel.txtSAPEmpID.Text, NumberStyles.Float, CultureInfo.CurrentCulture.NumberFormat, out dbNumericTemp))
                        {
                            ViewManager.ShowMessage("Invalid Employee Id", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            ViewManager.SetCurrent(ViewModel.txtSAPEmpID);
                            ViewModel.txtSAPEmpID.SelectionStart  = 0;
                            ViewModel.txtSAPEmpID.SelectionLength = Strings.Len(ViewModel.txtSAPEmpID.Text);
                            this.Return();
                            return;
                        }
                        else
                        {
                            //check for existing employee_id
                            if (Convert.ToString(ViewModel.cmdSwitch.Tag) == "1")
                            {
                                strSQL           = "spSelect_SAPConversionBySapID " + ViewModel.txtSAPEmpID.Text + " ";
                                oCmd.CommandText = strSQL;
                                oRec             = ADORecordSetHelper.Open(oCmd, "");
                                if (!oRec.EOF)
                                {
                                    ViewManager.ShowMessage("Duplicate Employee Id", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                                    ViewManager.SetCurrent(ViewModel.txtSAPEmpID);
                                    ViewModel.txtSAPEmpID.SelectionStart  = 0;
                                    ViewModel.txtSAPEmpID.SelectionLength = Strings.Len(ViewModel.txtSAPEmpID.Text);
                                    this.Return();
                                    return;
                                }
                            }
                            else
                            {
                                ArcID = GetNewID(ViewModel.txtSAPEmpID.Text);
                            }
                        }

                        //TFD Employee ID number
                        //    If Not IsNumeric(txtEmpID) Then
                        //        MsgBox "Invalid Employee Id", vbOKOnly, "Add New Employee Error"
                        //        txtEmpID.SetFocus
                        //        txtEmpID.SelStart = 0
                        //        txtEmpID.SelLength = Len(txtEmpID.Text)
                        //        Exit Sub
                        //    Else
                        if (Strings.Len(ViewModel.txtEmpID.Text) != 5)
                        {
                            ViewManager.ShowMessage("Invalid Employee Id", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            ViewManager.SetCurrent(ViewModel.txtEmpID);
                            ViewModel.txtEmpID.SelectionStart  = 0;
                            ViewModel.txtEmpID.SelectionLength = Strings.Len(ViewModel.txtEmpID.Text);
                            this.Return();
                            return;
                        }
                        else
                        {
                            //check for existing employee_id
                            if (Convert.ToString(ViewModel.cmdSwitch.Tag) == "1")
                            {
                                strSQL           = "spSelect_PersonnelByEmpID '" + ViewModel.txtEmpID.Text + "'";
                                oCmd.CommandText = strSQL;
                                oRec             = ADORecordSetHelper.Open(oCmd, "");
                                if (!oRec.EOF)
                                {
                                    ViewManager.ShowMessage("Duplicate Employee Id", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                                    ViewManager.SetCurrent(ViewModel.txtEmpID);
                                    ViewModel.txtEmpID.SelectionStart  = 0;
                                    ViewModel.txtEmpID.SelectionLength = Strings.Len(ViewModel.txtEmpID.Text);
                                    this.Return();
                                    return;
                                }
                            }
                            else
                            {
                                ArcID = GetNewID(ViewModel.txtEmpID.Text);
                            }
                        }

                        //Name Fields
                        if (modGlobal.Clean(ViewModel.txtFName.Text) == "")
                        {
                            ViewManager.ShowMessage("First Name must be entered", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            ViewManager.SetCurrent(ViewModel.txtFName);
                            ViewModel.txtFName.SelectionStart  = 0;
                            ViewModel.txtFName.SelectionLength = Strings.Len(ViewModel.txtFName.Text);
                            this.Return();
                            return;
                        }

                        if (modGlobal.Clean(ViewModel.txtLName.Text) == "")
                        {
                            ViewManager.ShowMessage("Last Name must be entered", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            ViewManager.SetCurrent(ViewModel.txtLName);
                            ViewModel.txtLName.SelectionStart  = 0;
                            ViewModel.txtLName.SelectionLength = Strings.Len(ViewModel.txtLName.Text);
                            this.Return();
                            return;
                        }

                        //job code
                        if (ViewModel.cboJobCode.SelectedIndex < 0)
                        {
                            ViewManager.ShowMessage("Please select a Job Title/Code from the list.", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            ViewManager.SetCurrent(ViewModel.cboJobCode);
                            this.Return();
                            return;
                        }

                        //Sex
                        if (ViewModel.txtSex.Text == "M" || ViewModel.txtSex.Text == "F")
                        {
                            //sex entered correctly
                        }
                        else
                        {
                            ViewManager.ShowMessage("Sex must be M or F", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            ViewManager.SetCurrent(ViewModel.txtSex);
                            ViewModel.txtSex.SelectionStart  = 0;
                            ViewModel.txtSex.SelectionLength = Strings.Len(ViewModel.txtSex.Text);
                            this.Return();
                            return;
                        }
                        ViewModel.txtNameKnownBy.Text = modGlobal.Clean(ViewModel.txtNameKnownBy.Text);

                        //Exception Days
                        double dbNumericTemp2 = 0;
                        if (!Double.TryParse(ViewModel.txtException.Text, NumberStyles.Float, CultureInfo.CurrentCulture.NumberFormat, out dbNumericTemp2))
                        {
                            //UPGRADE_WARNING: (1049) Use of Null/IsNull() detected. More Information: http://www.vbtonet.com/ewis/ewi1049.aspx
                            if (Convert.IsDBNull(ViewModel.txtException.Text) || ViewModel.txtException.Text == "")
                            {
                                ViewModel.txtException.Text = "0";
                            }
                            else
                            {
                                ViewManager.ShowMessage("Exception Days must be numeric", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                                ViewManager.SetCurrent(ViewModel.txtException);
                                ViewModel.txtException.SelectionStart = 0;
                                //UPGRADE_TODO: (1067) Member Text is not defined in type Variant. More Information: http://www.vbtonet.com/ewis/ewi1067.aspx
                                ViewModel.txtException.SelectionLength = Strings.Len(Convert.ToString(txtExceptDay.Text));
                                this.Return();
                                return;
                            }
                        }

                        //Date Fields
                        if (Information.IsDate(ViewModel.txtBDay.Text))
                        {
                            TestDate = DateTime.Parse(DateTime.Parse(ViewModel.txtBDay.Text).ToString("M/d/yyyy"));
                            if (TestDate > DateTime.Now)
                            {
                                async1.Append <UpgradeHelpers.Helpers.DialogResult>(() =>
                                                                                    ViewManager.ShowMessage("The Birthdate is in the future. Is this correct?", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                                async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized0 => tempNormalized0);
                                async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized1 =>
                                {
                                    Response = tempNormalized1;
                                });
                                async1.Append(() =>
                                {
                                    if (Response == UpgradeHelpers.Helpers.DialogResult.No)
                                    {
                                        ViewManager.ShowMessage("Please Correct the Birthdate using 4 digit Year", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.OK);
                                        ViewManager.SetCurrent(ViewModel.txtCOT);
                                        ViewModel.txtCOT.SelectionStart  = 0;
                                        ViewModel.txtCOT.SelectionLength = Strings.Len(ViewModel.txtBDay.Text);
                                        this.Return();
                                        return;
                                    }
                                });
                            }
                            else
                            {
                                //Birthdate OK
                                ViewModel.txtBDay.Text = DateTime.Parse(ViewModel.txtBDay.Text).ToString("M/d/yyyy");
                            }
                        }
                        else
                        {
                            ViewManager.ShowMessage("Birthday is invalid", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            ViewManager.SetCurrent(ViewModel.txtBDay);
                            ViewModel.txtBDay.SelectionStart  = 0;
                            ViewModel.txtBDay.SelectionLength = Strings.Len(ViewModel.txtBDay.Text);
                            this.Return();
                            return;
                        }

                        if (Information.IsDate(ViewModel.txtCOT.Text))
                        {
                            TestDate = DateTime.Parse(DateTime.Parse(ViewModel.txtCOT.Text).ToString("M/d/yyyy"));
                            if (TestDate > DateTime.Now)
                            {
                                async1.Append <UpgradeHelpers.Helpers.DialogResult>(() =>
                                                                                    ViewManager.ShowMessage("COT Service Date is in the future. Is this correct?", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                                async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized2 => tempNormalized2);
                                async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized3 =>
                                {
                                    Response = tempNormalized3;
                                });
                                async1.Append(() =>
                                {
                                    using (var async2 = this.Async())
                                    {
                                        if (Response == UpgradeHelpers.Helpers.DialogResult.No)
                                        {
                                            ViewManager.ShowMessage("Please Correct COT Service Date using 4 digit Year", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.OK);
                                            ViewManager.SetCurrent(ViewModel.txtCOT);
                                            ViewModel.txtCOT.SelectionStart  = 0;
                                            ViewModel.txtCOT.SelectionLength = Strings.Len(ViewModel.txtCOT.Text);
                                            this.Return();
                                            return;
                                        }
                                        TYear = DateTime.Parse(ViewModel.txtCOT.Text).ToString("yyyy");
                                        if (Strings.Len(TYear) == 2)
                                        {
                                            TYear = "20" + TYear;
                                            TYear = DateTime.Parse(ViewModel.txtCOT.Text).ToString("M/d/") + TYear;
                                            ViewModel.txtCOT.Text = TYear;
                                            async2.Append <UpgradeHelpers.Helpers.DialogResult>((
                                                                                                    ) => ViewManager.ShowMessage("COT Service Date Corrected for 4 digit Year, Keep Correction?", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                                            async2.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized4 => tempNormalized4);
                                            async2.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized5 =>
                                            {
                                                Response = tempNormalized5;
                                            });
                                            async2.Append(() =>
                                            {
                                                if (Response == UpgradeHelpers.Helpers.DialogResult.No)
                                                {
                                                    ViewManager.ShowMessage("Please Correct COT Service Date using 4 digit Year", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.OK);
                                                    ViewManager.SetCurrent(ViewModel.txtCOT);
                                                    ViewModel.txtCOT.SelectionStart  = 0;
                                                    ViewModel.txtCOT.SelectionLength = Strings.Len(ViewModel.txtCOT.Text);
                                                    this.Return();
                                                    return;
                                                }
                                            });
                                        }
                                    }
                                });
                            }
                            else
                            {
                                //COT Service date OK
                                ViewModel.txtCOT.Text = DateTime.Parse(ViewModel.txtCOT.Text).ToString("M/d/yyyy");
                            }
                        }
                        else
                        {
                            ViewManager.ShowMessage("COT Service Date is invalid", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            ViewManager.SetCurrent(ViewModel.txtCOT);
                            ViewModel.txtCOT.SelectionStart  = 0;
                            ViewModel.txtCOT.SelectionLength = Strings.Len(ViewModel.txtCOT.Text);
                            this.Return();
                            return;
                        }

                        if (Information.IsDate(ViewModel.txtTFD.Text))
                        {
                            TestDate = DateTime.Parse(DateTime.Parse(ViewModel.txtTFD.Text).ToString("M/d/yyyy"));
                            if (TestDate > DateTime.Now)
                            {
                                async1.Append <UpgradeHelpers.Helpers.DialogResult>(() =>
                                                                                    ViewManager.ShowMessage("TFD Hire Date is in the future. Is this correct?", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                                async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized6 => tempNormalized6);
                                async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized7 =>
                                {
                                    Response = tempNormalized7;
                                });
                                async1.Append(() =>
                                {
                                    if (Response == UpgradeHelpers.Helpers.DialogResult.No)
                                    {
                                        ViewManager.ShowMessage("Please Correct TFD Hire Date using 4 digit Year", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.OK);
                                        ViewManager.SetCurrent(ViewModel.txtCOT);
                                        ViewModel.txtCOT.SelectionStart  = 0;
                                        ViewModel.txtCOT.SelectionLength = Strings.Len(ViewModel.txtTFD.Text);
                                        this.Return();
                                        return;
                                    }
                                });
                            }
                            else
                            {
                                //TFD hire date OK
                                ViewModel.txtTFD.Text = DateTime.Parse(ViewModel.txtTFD.Text).ToString("M/d/yyyy");
                            }
                        }
                        else
                        {
                            ViewManager.ShowMessage("TFD Hire Date is invalid", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            ViewManager.SetCurrent(ViewModel.txtTFD);
                            ViewModel.txtTFD.SelectionStart  = 0;
                            ViewModel.txtTFD.SelectionLength = Strings.Len(ViewModel.txtTFD.Text);
                            this.Return();
                            return;
                        }

                        if (Convert.ToString(ViewModel.cmdSwitch.Tag) == "2")
                        {
                            //Adding New Archived Employee
                            if (Information.IsDate(ViewModel.txtExit.Text))
                            {
                                TestDate = DateTime.Parse(DateTime.Parse(ViewModel.txtExit.Text).ToString("M/d/yyyy"));
                                if (TestDate > DateTime.Now)
                                {
                                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(() =>
                                                                                        ViewManager.ShowMessage("Exit Date is in the future. Is this correct?", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                                    async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized8 => tempNormalized8);
                                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized9 =>
                                    {
                                        Response = tempNormalized9;
                                    });
                                    async1.Append(() =>
                                    {
                                        if (Response == UpgradeHelpers.Helpers.DialogResult.No)
                                        {
                                            ViewManager.ShowMessage("Please Correct Exit Date using 4 digit Year", "Add New Personnel", UpgradeHelpers.Helpers.BoxButtons.OK);
                                            ViewManager.SetCurrent(ViewModel.txtCOT);
                                            ViewModel.txtCOT.SelectionStart  = 0;
                                            ViewModel.txtCOT.SelectionLength = Strings.Len(ViewModel.txtExit.Text);
                                            this.Return();
                                            return;
                                        }
                                    });
                                }
                                else
                                {
                                    //TFD hire date OK
                                    ViewModel.txtExit.Text = DateTime.Parse(ViewModel.txtExit.Text).ToString("M/d/yyyy");
                                }
                            }
                            else
                            {
                                ViewManager.ShowMessage("TFD Exit Date is invalid", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                                ViewManager.SetCurrent(ViewModel.txtTFD);
                                ViewModel.txtTFD.SelectionStart  = 0;
                                ViewModel.txtTFD.SelectionLength = Strings.Len(ViewModel.txtExit.Text);
                                this.Return();
                                return;
                            }
                            async1.Append(() =>
                            {
                                switch (ViewModel.cboExitType.Text)
                                {
                                case "Retirement":
                                    LeaveStatus = "RT";
                                    break;

                                case "Transfer":
                                    LeaveStatus = "TR";
                                    break;

                                case "Resignation":
                                    LeaveStatus = "QT";
                                    break;

                                case "Termination":
                                    LeaveStatus = "TM";
                                    break;

                                default:
                                    LeaveStatus = "";
                                    break;
                                }

                                while ((ViewModel.txtExitComments.Text.IndexOf('\'') + 1) != 0)
                                {
                                    i    = (ViewModel.txtExitComments.Text.IndexOf('\'') + 1);
                                    str1 = ViewModel.txtExitComments.Text.Substring(0, Math.Min(i - 1, ViewModel.txtExitComments.Text.Length));
                                    str2 = ViewModel.txtExitComments.Text.Substring(Math.Max(ViewModel.txtExitComments.Text.Length - (Strings.Len(ViewModel.txtExitComments.Text) - i), 0));
                                    ViewModel.txtExitComments.Text = str1 + "-" + str2;
                                }
                                ;
                                ViewModel.txtExitComments.Text = ViewModel.txtExitComments.Text.Substring(0, Math.Min(255, ViewModel.txtExitComments.Text.Length));
                            });
                        }
                        else
                        {
                            //Adding New Regular Employee
                            double dbNumericTemp3 = 0;
                            if (!Double.TryParse(ViewModel.txtStep.Text, NumberStyles.Float, CultureInfo.CurrentCulture.NumberFormat, out dbNumericTemp3))
                            {
                                ViewManager.ShowMessage("Invalid Step", "Add New Employee Error", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                                ViewManager.SetCurrent(ViewModel.txtStep);
                                ViewModel.txtStep.SelectionStart  = 0;
                                ViewModel.txtStep.SelectionLength = Strings.Len(ViewModel.txtStep.Text);
                                this.Return();
                                return;
                            }
                            if (((int)ViewModel.chkStatus.CheckState) == ((int)UpgradeHelpers.Helpers.CheckState.Checked))
                            {
                                Status = 1;
                            }
                            else
                            {
                                Status = 0;
                            }
                        }
                        async1.Append(() =>
                        {
                            //Format name_full field
                            NameWork = modGlobal.Clean(modGlobal.ProofSQLString(ViewModel.txtLName.Text));
                            if (modGlobal.Clean(ViewModel.txtSName.Text) != "")
                            {
                                NameWork = NameWork + " " + modGlobal.Clean(ViewModel.txtSName.Text);
                            }
                            NameWork = NameWork + ", " + modGlobal.Clean(modGlobal.ProofSQLString(ViewModel.txtFName.Text));
                            if (modGlobal.Clean(ViewModel.txtMName.Text) != "")
                            {
                                NameWork = NameWork + " " + modGlobal.Clean(ViewModel.txtMName.Text) + ".";
                            }

                            //Edits ok, insert record
                            if (Convert.ToString(ViewModel.cmdSwitch.Tag) == "1")
                            {
                                strSQL = "spInsertPersonnel '" + modGlobal.Clean(ViewModel.txtEmpID.Text) + "',0,'" + modGlobal.Clean(ViewModel.lbJobCode.Text) + "'," + Conversion.Val(ViewModel.txtStep.Text).ToString() + ",'";
                                strSQL = strSQL + modGlobal.Clean(NameWork) + "','" + modGlobal.Clean(modGlobal.ProofSQLString(ViewModel
                                                                                                                               .txtLName.Text)) + "','" + modGlobal.Clean(modGlobal.ProofSQLString(ViewModel.txtFName.Text)) + "','";
                                strSQL = strSQL + modGlobal.Clean(ViewModel.txtMName.Text) + "','" + modGlobal.Clean(ViewModel.txtSName.Text) + "','" + ViewModel.txtSex.Text + "','";
                                strSQL = strSQL + ViewModel.txtSSN.Text + "','" + ViewModel.txtUnion.Text + "','" + ViewModel.cboBenefit.Text + "','";
                                strSQL = strSQL + ViewModel.txtAddress.Text + "','" + ViewModel.txtCity.Text + "','" + ViewModel.txtState.Text + "','" + ViewModel.txtZip.Text + "','";
                                strSQL = strSQL + ViewModel.txtPhone.Text + "','" + ViewModel.txtBDay.Text + "','" + ViewModel.txtCOT.Text + "','";
                                strSQL = strSQL + ViewModel.txtTFD.Text + "'," + Conversion.Val(ViewModel.txtException.Text).ToString() + ",'" + DateTime.Now.ToString("M/d/yyyy");
                                strSQL = strSQL + "'," + Status.ToString() + ",'" + ViewModel.txtNameKnownBy.Text + "'";
                            }
                            else
                            {
                                strSQL = "spInsertArcPersonnel " + ArcID.ToString() + ",'" + modGlobal.Clean(ViewModel.txtEmpID.Text) + "','" + modGlobal.Clean(ViewModel.lbJobCode.Text) + "','";
                                strSQL = strSQL + modGlobal.Clean(NameWork) + "','" + modGlobal.Clean(modGlobal.ProofSQLString(ViewModel
                                                                                                                               .txtLName.Text)) + "','" + modGlobal.Clean(modGlobal.ProofSQLString(ViewModel.txtFName.Text)) + "','";
                                strSQL = strSQL + modGlobal.Clean(ViewModel.txtMName.Text) + "','" + modGlobal.Clean(ViewModel.txtSName.Text) + "','" + ViewModel.txtSex.Text + "','";
                                strSQL = strSQL + ViewModel.txtSSN.Text + "','" + ViewModel.cboBenefit.Text + "','";
                                strSQL = strSQL + ViewModel.txtAddress.Text + "','" + ViewModel.txtCity.Text + "','" + ViewModel.txtState.Text + "','" + ViewModel.txtZip.Text + "','";
                                strSQL = strSQL + ViewModel.txtPhone.Text + "','" + ViewModel.txtBDay.Text + "','" + ViewModel.txtCOT.Text + "','";
                                strSQL = strSQL + ViewModel.txtTFD.Text + "','" + ViewModel.txtExit.Text + "','" + LeaveStatus + "'," + Conversion.Val(ViewModel.txtException.Text).ToString();
                                strSQL = strSQL + ",'" + ViewModel.txtExitComments.Text + "'";
                            }

                            oCmd.CommandType = CommandType.Text;
                            oCmd.CommandText = strSQL;
                            oCmd.ExecuteNonQuery();

                            //Vacation Balance record for new employee
                            oCmd.CommandText = "spInsertVacationBalance '" + ViewModel.txtEmpID.Text + "',0,'" + UpgradeHelpers.Helpers.DateTimeHelper.ToString(DateTime.Now) + "'";
                            oCmd.ExecuteNonQuery();

                            if (Convert.ToString(ViewModel.cmdSwitch.Tag) == "1")
                            {
                                modGlobal.Shared.gAssignID  = ViewModel.txtEmpID.Text;
                                ViewModel.cmdAssign.Enabled = true;
                                NameWork = modGlobal.Clean(ViewModel.txtLName.Text) + ", " + modGlobal.Clean(ViewModel.txtFName.Text);
                                ViewManager.ShowMessage(NameWork + " successfully Added", "Add New Employee", UpgradeHelpers.Helpers.BoxButtons.OK);
                                ViewManager.SetCurrent(ViewModel.cmdAssign);
                            }
                            else
                            {
                                NameWork = modGlobal.Clean(ViewModel.txtLName.Text) + ", " + modGlobal.Clean(ViewModel.txtFName.Text);
                                ViewManager.ShowMessage(NameWork + " successfully Added to Archived Personnel", "Add New Archived Employee", UpgradeHelpers.Helpers.BoxButtons.OK);
                                ClearForm();
                            }

                            //Add SAPConversion Record
                            if (Convert.ToString(ViewModel.cmdSwitch.Tag) == "1")
                            {
                                strSQL           = "spSelect_PersonnelSystemIDByEmpID '" + ViewModel.txtEmpID.Text + "' ";
                                oCmd.CommandType = CommandType.Text;
                                oCmd.CommandText = strSQL;
                                oRec             = ADORecordSetHelper.Open(oCmd, "");
                                if (!oRec.EOF)
                                {
                                    //UPGRADE_WARNING: (1068) GetVal() of type Variant is being forced to int. More Information: http://www.vbtonet.com/ewis/ewi1068.aspx
                                    iPersID = Convert.ToInt32(modGlobal.GetVal(oRec["per_sys_id"]));


                                    //UPGRADE_WARNING: (1068) GetVal() of type Variant is being forced to string. More Information: http://www.vbtonet.com/ewis/ewi1068.aspx
                                    strSQL           = "spInsertSAPConversion " + iPersID.ToString() + ", " + Convert.ToString(modGlobal.GetVal(ViewModel.txtSAPEmpID.Text)) + " ";
                                    oCmd.CommandType = CommandType.Text;
                                    oCmd.CommandText = strSQL;
                                    oCmd.ExecuteNonQuery();
                                }
                            }
                        });
                    }
                }
                catch
                {
                    if (modGlobal.ErrorControl() == modGlobal.eFATALERROR)
                    {
                        this.Return();
                        return;
                    }
                }
            }
        }
Beispiel #6
0
        internal void OKButton_Click(Object eventSender, System.EventArgs eventArgs)
        {
            using (var async1 = this.Async(true))
            {
                UpgradeHelpers.Helpers.DialogResult resp = (UpgradeHelpers.Helpers.DialogResult) 0;

                string sName = "";
                //Do some editing and check for delete...
                //UPGRADE_WARNING: (1068) GetVal(lbRecordID.Caption) of type Variant is being forced to double. More Information: http://www.vbtonet.com/ewis/ewi1068.aspx
                if (Convert.ToDouble(modGlobal.GetVal(ViewModel.lbRecordID.Text)) != 0 && modGlobal.Clean(ViewModel.
                                                                                                          cboShift.Text) == "" && modGlobal.Clean(ViewModel.cboNumber.Text) == "" && modGlobal.Clean(ViewModel.cboDebitGroup.Text) == "")
                {
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(() =>
                                                                        ViewManager.ShowMessage("Do you want to Delete the Callback # for this Employee?", "Delete Callback Number", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                    async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized0 => tempNormalized0);
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized1 =>
                    {
                        resp = tempNormalized1;
                    });
                    async1.Append(() =>
                    {
                        if (resp == UpgradeHelpers.Helpers.DialogResult.No)
                        {
                            this.Return();
                            return;
                        }
                        else
                        {
                            //UPGRADE_WARNING: (1068) GetVal() of type Variant is being forced to int. More Information: http://www.vbtonet.com/ewis/ewi1068.aspx
                            if (cScheduler.DeletePersonnelCallBackNumber(Convert.ToInt32(modGlobal.GetVal(ViewModel.lbRecordID.Text))) != 0)
                            {
                                //success
                                ViewManager.DisposeView(this);
                                this.Return();
                                return;
                            }
                            else
                            {
                                ViewManager.ShowMessage("Oooops! There was a problem deleting CallBackNumber.", "Delete Callback Number Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                                this.Return();
                                return;
                            }
                        }
                    });
                }
                async1.Append(() =>
                {
                    using (var async2 = this.Async())
                    {
                        if (modGlobal.Clean(ViewModel.cboShift.Text) == "")
                        {
                            ViewManager.ShowMessage("Please select a Shift... or Click Cancel to Exit.", "Edit Callback Number Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            this.Return();
                            return;
                        }

                        if (modGlobal.Clean(ViewModel.cboNumber.Text) == "")
                        {
                            ViewManager.ShowMessage("Please select a Number... or Click Cancel to Exit.", "Edit Callback Number Error", UpgradeHelpers.Helpers.BoxButtons.OK);
                            this.Return();
                            return;
                        }

                        //UPGRADE_WARNING: (1068) GetVal(cboNumber.Text) of type Variant is being forced to int. More Information: http://www.vbtonet.com/ewis/ewi1068.aspx
                        if (cScheduler.CheckCallBackNumberInUse(modGlobal.Clean(ViewModel.cboShift.Text), Convert.ToInt32(modGlobal.GetVal(ViewModel.cboNumber.Text)), modGlobal.Clean(ViewModel.sEmpID)) != 0)
                        {
                            if (!cScheduler.PersonnelCallBackNumber.EOF)
                            {
                                sName = modGlobal.Clean(cScheduler.PersonnelCallBackNumber["name_full"]);
                                async2.Append <UpgradeHelpers.Helpers.DialogResult>(() => ViewManager.ShowMessage("This Callback # currently belongs to " + sName + "." + "\r" +
                                                                                                                  "Do you want to continue anyway?", "Check Callback Number In Use", UpgradeHelpers.Helpers.BoxButtons.YesNo));
                                async2.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized2 => tempNormalized2);
                                async2.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized3 =>
                                {
                                    resp = tempNormalized3;
                                });
                                async2.Append(() =>
                                {
                                    if (resp == UpgradeHelpers.Helpers.DialogResult.Yes)
                                    {
                                        //continue...
                                    }
                                    else
                                    {
                                        this.Return();
                                        return;
                                    }
                                });
                            }
                        }
                        async2.Append(() =>
                        {
                            ChangeCallbackNumber();
                            ViewManager.DisposeView(this);
                        });
                    }
                });
            }
        }
        internal void cmdUpdate_Click(Object eventSender, System.EventArgs eventArgs)
        {
            using (var async1 = this.Async(true))
            {
                int       str1 = 0;
                DbCommand oCmd = UpgradeHelpers.DB.AdoFactoryManager.GetFactory().CreateCommand();
                UpgradeHelpers.Helpers.DialogResult Response = (UpgradeHelpers.Helpers.DialogResult) 0;
                //DbCommand oRec = null;
                //string strl = "";
                string str2 = "";
                int    i    = 0;

                //Edit Fields
                ViewModel.txtAddress.Text = ViewModel.txtAddress.Text.Trim();
                if (ViewModel.txtAddress.Text == "")
                {
                    ViewManager.ShowMessage("You must enter a Address !!", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                    ViewManager.SetCurrent(ViewModel.txtAddress);
                    this.Return();
                    return;
                }
                ViewModel.cboType.Text = ViewModel.cboType.Text.Trim();
                if (ViewModel.cboType.Text == "")
                {
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(() => ViewManager
                                                                        .ShowMessage("No Address Type was selected. Default to 'Unknown' " + "?? ", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OKCancel));
                    async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized0 => tempNormalized0);
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized1 =>
                    {
                        Response = tempNormalized1;
                    });
                    async1.Append(() =>
                    {
                        if (Response == UpgradeHelpers.Helpers.DialogResult.Cancel)
                        {
                            ViewManager.SetCurrent(ViewModel.cboType);
                            this.Return();
                            return;
                        }
                        else
                        {
                            ViewModel.cboType.Text = "Unknown";
                        }
                    });
                }
                async1.Append(() =>
                {
                    ViewModel.txtCity.Text = ViewModel.txtCity.Text.Trim();
                    if (ViewModel.txtCity.Text == "")
                    {
                        ViewManager.ShowMessage("You must enter a City !!", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                        ViewManager.SetCurrent(ViewModel.txtCity);
                        this.Return();
                        return;
                    }
                    ViewModel.txtState.Text = ViewModel.txtState.Text.Trim();
                    if (ViewModel.txtState.Text == "")
                    {
                        ViewManager.ShowMessage("You must enter a State !!", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                        ViewManager.SetCurrent(ViewModel.txtState);
                        this.Return();
                        return;
                    }
                    ViewModel.txtZip.Text = ViewModel.txtZip.Text.Trim();
                    if (ViewModel.txtCity.Text == "")
                    {
                        ViewManager.ShowMessage("You must enter a Zip Code !!", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                        ViewManager.SetCurrent(ViewModel.txtZip);
                        this.Return();
                        return;
                    }

                    string CommStr = ViewModel.txtComment.Text.Trim();

                    while ((CommStr.IndexOf('\'') + 1) != 0)
                    {
                        i       = (CommStr.IndexOf('\'') + 1);
                        str1    = Convert.ToInt32(Double.Parse(CommStr.Substring(0, Math.Min(i - 1, CommStr.Length))));
                        str2    = CommStr.Substring(Math.Max(CommStr.Length - (Strings.Len(CommStr) - i), 0));
                        CommStr = str1.ToString() + "-" + str2;
                    }
                    ;
                    ViewModel.txtComment.Text = CommStr.Substring(0, Math.Min(255, CommStr.Length));

                    //Execute spUpdatePersonnelAddress
                    oCmd.Connection  = modGlobal.oConn;
                    oCmd.CommandType = CommandType.Text;

                    oCmd.CommandText = "spUpdatePersonnelAddress '" + ViewModel.lbAddressID.Text + "','" + ViewModel.lbEmpID.Text + "','" + Strings.Replace
                                           (ViewModel.txtAddress.Text, "'", "''", 1, -1, CompareMethod.Binary) + "','" +
                                       ViewModel.txtCity.Text + "','" + ViewModel.txtZip.Text + "','" + ViewModel.txtComment.Text + "','" + ViewModel.cboType.Text + "','" + ViewModel.txtState.Text + "'";
                    oCmd.ExecuteNonQuery();

                    //Refresh Screen
                    LoadAddressList();
                });
            }
        }
        internal void cmdAdd_Click(Object eventSender, System.EventArgs eventArgs)
        {
            using (var async1 = this.Async(true))
            {
                int       str1 = 0;
                DbCommand oCmd = UpgradeHelpers.DB.AdoFactoryManager.GetFactory().CreateCommand();
                UpgradeHelpers.Helpers.DialogResult Response = (UpgradeHelpers.Helpers.DialogResult) 0;
                //DbCommand oRec = null;
                //string strl = "";
                string str2 = "";
                int    i    = 0;

                //Check cmdAdd.Tag to see if fields need cleared...
                if (UpgradeHelpers.Helpers.StringsHelper.ToDoubleSafe(Convert.ToString(ViewModel.cmdAdd.Tag)) == 1)
                {
                    //Unselect row in the Address List Box
                    for (i = 0; i <= ViewModel.lstAddress.Items.Count - 1; i++)
                    {
                        UpgradeHelpers.Helpers.ListBoxHelper.SetSelected(ViewModel.lstAddress, i, false);
                    }

                    // Clear fields
                    ViewModel.txtAddress.Text = "";
                    ViewModel.txtCity.Text    = "";
                    ViewModel.txtState.Text   = "";
                    ViewModel.txtZip.Text     = "";
                    ViewModel.txtComment.Text = "";
                    ViewModel.cboType.Text    = "";

                    // Reset buttons...
                    ViewModel.cmdAdd.Tag        = "2";
                    ViewModel.cmdAdd.Text       = "&Add New Address";
                    ViewModel.cmdDelete.Visible = false;
                    ViewModel.cmdUpdate.Visible = false;

                    //Set Focus
                    ViewManager.SetCurrent(

//Set Focus
                        ViewModel.txtAddress);
                    this.Return();
                    return;
                }

                //Edit Fields
                ViewModel.txtAddress.Text = ViewModel.txtAddress.Text.Trim();
                if (ViewModel.txtAddress.Text == "")
                {
                    ViewManager.ShowMessage("You must enter a Address !!", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                    ViewManager.SetCurrent(ViewModel.txtAddress);
                    this.Return();
                    return;
                }
                ViewModel.cboType.Text = ViewModel.cboType.Text.Trim();
                if (ViewModel.cboType.Text == "")
                {
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(() => ViewManager
                                                                        .ShowMessage("No Address Type was selected. Default to 'Unknown' " + "?? ", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OKCancel));
                    async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized0 => tempNormalized0);
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized1 =>
                    {
                        Response = tempNormalized1;
                    });
                    async1.Append(() =>
                    {
                        if (Response == UpgradeHelpers.Helpers.DialogResult.Cancel)
                        {
                            ViewManager.SetCurrent(ViewModel.cboType);
                            this.Return();
                            return;
                        }
                        else
                        {
                            ViewModel.cboType.Text = "Unknown";
                        }
                    });
                }
                async1.Append(() =>
                {
                    ViewModel.txtCity.Text = ViewModel.txtCity.Text.Trim();
                    if (ViewModel.txtCity.Text == "")
                    {
                        ViewManager.ShowMessage("You must enter a City !!", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                        ViewManager.SetCurrent(ViewModel.txtCity);
                        this.Return();
                        return;
                    }
                    ViewModel.txtState.Text = ViewModel.txtState.Text.Trim();
                    if (ViewModel.txtState.Text == "")
                    {
                        ViewManager.ShowMessage("You must enter a State !!", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                        ViewManager.SetCurrent(ViewModel.txtState);
                        this.Return();
                        return;
                    }
                    ViewModel.txtZip.Text = ViewModel.txtZip.Text.Trim();
                    if (ViewModel.txtCity.Text == "")
                    {
                        ViewManager.ShowMessage("You must enter a Zip Code !!", "Insert New Address", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                        ViewManager.SetCurrent(ViewModel.txtZip);
                        this.Return();
                        return;
                    }

                    string CommStr = ViewModel.txtComment.Text.Trim();

                    while ((CommStr.IndexOf('\'') + 1) != 0)
                    {
                        i       = (CommStr.IndexOf('\'') + 1);
                        str1    = Convert.ToInt32(Double.Parse(CommStr.Substring(0, Math.Min(i - 1, CommStr.Length))));
                        str2    = CommStr.Substring(Math.Max(CommStr.Length - (Strings.Len(CommStr) - i), 0));
                        CommStr = str1.ToString() + "-" + str2;
                    }
                    ;
                    ViewModel.txtComment.Text = CommStr.Substring(0, Math.Min(255, CommStr.Length));

                    //Execute spInsertPersonnelAddress
                    oCmd.Connection  = modGlobal.oConn;
                    oCmd.CommandType = CommandType.Text;

                    oCmd.CommandText = "spInsertPersonnelAddress '" + ViewModel.lbEmpID.Text + "','" + ViewModel.txtAddress.Text +
                                       "','" + ViewModel.txtCity.Text + "','" + ViewModel.txtZip.Text + "','" + ViewModel.txtComment.Text + "','" + ViewModel.cboType.Text + "','" + ViewModel.txtState.Text + "'";
                    oCmd.ExecuteNonQuery();

                    //Refresh Screen
                    LoadAddressList();
                });
            }
        }
        public void CreateNewSchedule()
        {
            using (var async1 = this.Async(true))
            {
                //Create REG, DDF and ROV
                //Schedule records for selected date range
                UpgradeHelpers.Helpers.DialogResult Response = (UpgradeHelpers.Helpers.DialogResult) 0;
                DbConnection oConUtil = UpgradeHelpers.DB.AdoFactoryManager.GetFactory().CreateConnection();
                string       strCon   = "";
                DbCommand    oCmd     = UpgradeHelpers.DB.AdoFactoryManager.GetFactory().CreateCommand();
                ViewModel.cmdExit.Visible = false;

                string          sStartDate  = DateTime.Parse(ViewModel.calStart.Text).ToString("M/d/yyyy");
                System.DateTime dtStartDate = DateTime.Parse(DateTime.Parse(ViewModel.calStart.Text).ToString("M/d/yyyy"));
                string          sEndDate    = DateTime.Parse(ViewModel.calEnd.Text).ToString("M/d/yyyy");
                System.DateTime dtEndDate   = DateTime.Parse(DateTime.Parse(ViewModel.calEnd.Text).ToString("M/d/yyyy"));

                if (modGlobal.Shared.gTestMode != 0)
                {
                    strCon = "Provider=SQLOLEDB; Data Source=TFDSQL1; Initial Catalog=PTSTestBackup; Integrated Security=SSPI";
                }
                else
                {
                    strCon = "Provider=SQLOLEDB; Data Source=TFDSQL1; Initial Catalog=PTSData; Integrated Security=SSPI";
                }
                //    strCon = "Provider=SQLOLEDB; Data Source=TFDSQL2; Initial Catalog=PTSData; Integrated Security=SSPI"
                //UPGRADE_TODO: (7010) The connection string must be verified to fullfill the .NET data provider connection string requirements. More Information: http://www.vbtonet.com/ewis/ewi7010.aspx
                oConUtil.ConnectionString = strCon;
                oConUtil.Open();
                while ((oConUtil.State == ConnectionState.Connecting))
                {
                    //Debug.Print "Connecting to SQL Server....."
                }

                oCmd.Connection  = oConUtil;
                oCmd.CommandType = CommandType.Text;
                oCmd.CommandText = "sp_LastSchedDate";
                ADORecordSetHelper oRec     = ADORecordSetHelper.Open(oCmd, "");
                System.DateTime    LastDate = Convert.ToDateTime(oRec["last_date"]);

                if (dtStartDate >= dtEndDate)
                {
                    ViewManager.ShowMessage("End Date must be greater than Start Date", "Create New Schedule", UpgradeHelpers.Helpers.BoxButtons.OK, UpgradeHelpers.Helpers.BoxIcons.Error);
                    this.Return();
                    return;
                }

                if (LastDate > dtStartDate)
                {
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(()
                                                                        => ViewManager.ShowMessage("Delete Current Schedule Records occuring after selected Start Date?", "Create New Schedule", UpgradeHelpers.Helpers.BoxButtons.YesNoCancel));
                    async1.Append <UpgradeHelpers.Helpers.DialogResult, UpgradeHelpers.Helpers.DialogResult>(tempNormalized0 => tempNormalized0);
                    async1.Append <UpgradeHelpers.Helpers.DialogResult>(tempNormalized1 =>
                    {
                        Response = tempNormalized1;
                    });
                    async1.Append(() =>
                    {
                        if (Response == UpgradeHelpers.Helpers.DialogResult.No)
                        {
                            dtStartDate = LastDate.AddDays(1);
                            sStartDate  = dtStartDate.ToString("M/d/yyyy");
                        }
                        else if (Response == UpgradeHelpers.Helpers.DialogResult.Cancel)
                        {
                            this.Return();
                            return;
                        }
                        else
                        {
                            //Delete Overlapping Schedule Records
                            oCmd.CommandText = "spClearSchedule '" + sStartDate + "','" + LastDate.AddDays(1).ToString("M/d/yyyy") + "'";
                            oCmd.ExecuteNonQuery();
                        }
                    });
                }
                async1.Append(() =>
                {
                    ViewModel.lbStatus.Visible = true;
                    ViewModel.pb1.Visible      = true;

                    //Create REG Schedule Records
                    ViewModel.lbStatus.Text = "Creating New REG Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    int RecFactor           = ((int)DateAndTime.DateDiff("d", dtStartDate, dtEndDate, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1)) * 164;
                    int i            = 0;
                    oCmd.CommandText = "spCreateSchedREG '" + sStartDate + "','" + sEndDate + "'";
                    //    oCmd.CommandText = "spCreateSchedREG_OneTime '" & sStartDate & "','" & sEndDate & "'"
                    oRec = ADORecordSetHelper.Open(oCmd, "");


                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "'," + Convert.ToString(oRec["ass_id"]) + ",'REG',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating New REG Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creation of New REG Schedule Records Complete";

                    //UPGRADE_WARNING: (6021) Casting 'int' to Enum may cause different behaviour. More Information: http://www.vbtonet.com/ewis/ewi6021.aspx
                    for (Response = UpgradeHelpers.Helpers.DialogResult.OK; ((int)Response) <= 10000; Response = (UpgradeHelpers.Helpers.DialogResult)(((int)Response) + 1))
                    {
                    }

                    //Create ROV Schedule Records (position ROV181 & ROV182 & ROV183)
                    ViewModel.lbStatus.Text = "Creating New Batt 1 ROV Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    RecFactor        = ((int)DateAndTime.DateDiff("d", dtStartDate, dtEndDate, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1)) * 11;
                    i                = 0;
                    oCmd.CommandText = "spCreateSchedROV '" + sStartDate + "','" + sEndDate + "','1'";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");

                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "',559,'REG',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating New Batt 1 ROV Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creating New Batt 2 ROV Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    RecFactor        = ((int)DateAndTime.DateDiff("d", dtStartDate, dtEndDate, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1)) * 12;
                    i                = 0;
                    oCmd.CommandText = "spCreateSchedROV '" + sStartDate + "','" + sEndDate + "','2'";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");

                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "',560,'REG',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating New Batt 2 ROV Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creating New Batt 3 ROV Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    RecFactor        = ((int)DateAndTime.DateDiff("d", dtStartDate, dtEndDate, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1)) * 12;
                    i                = 0;
                    oCmd.CommandText = "spCreateSchedROV '" + sStartDate + "','" + sEndDate + "','3'";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");

                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "',1283,'REG',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating New Batt 3 ROV Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creation of ROV Schedule Records Complete";
                    //UPGRADE_WARNING: (6021) Casting 'int' to Enum may cause different behaviour. More Information: http://www.vbtonet.com/ewis/ewi6021.aspx
                    for (Response = UpgradeHelpers.Helpers.DialogResult.OK; ((int)Response) <= 10000; Response = (UpgradeHelpers.Helpers.DialogResult)(((int)Response) + 1))
                    {
                    }

                    //Create DDF Schedule Records (position DBT181 & DBT182 & DBT183)
                    ViewModel.lbStatus.Text = "Creating New Batt 1 DDF Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    RecFactor        = ((int)DateAndTime.DateDiff("d", dtStartDate, dtEndDate, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1)) * 6;
                    i                = 0;
                    oCmd.CommandText = "spCreateSchedDDF '" + sStartDate + "','" + sEndDate + "','1'";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");

                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "',561,'DDF',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating New Batt 1 DDF Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creating New Batt 2 DDF Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    i = 0;
                    oCmd.CommandText = "spCreateSchedDDF '" + sStartDate + "','" + sEndDate + "','2'";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");

                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "',562,'DDF',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating New Batt 2 DDF Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creating New Batt 3 DDF Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    i = 0;
                    oCmd.CommandText = "spCreateSchedDDF '" + sStartDate + "','" + sEndDate + "','3'";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");

                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "',1284,'DDF',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating New Batt 3 DDF Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creation of DDF Schedule Records Complete";
                    //UPGRADE_WARNING: (6021) Casting 'int' to Enum may cause different behaviour. More Information: http://www.vbtonet.com/ewis/ewi6021.aspx
                    for (Response = UpgradeHelpers.Helpers.DialogResult.OK; ((int)Response) <= 10000; Response = (UpgradeHelpers.Helpers.DialogResult)(((int)Response) + 1))
                    {
                    }

                    //Create DDF Schedule Records (position DBT181 & DBT182 & DBT183) for
                    //Special Non-Paramedic Personnel in Paramedic positions
                    ViewModel.lbStatus.Text = "Creating Special Batt 1 DDF Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    RecFactor        = ((int)DateAndTime.DateDiff("d", dtStartDate, dtEndDate, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1)) * 6;
                    i                = 0;
                    oCmd.CommandText = "spCreateSchedDDF_2 '" + sStartDate + "','" + sEndDate + "','1'";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");

                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "',561,'DDF',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating Special Batt 1 DDF Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creating Special Batt 2 DDF Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    i = 0;
                    oCmd.CommandText = "spCreateSchedDDF_2 '" + sStartDate + "','" + sEndDate + "','2'";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");

                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "',562,'DDF',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating Special Batt 2 DDF Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creating Special Batt 3 DDF Schedule Records";
                    ViewModel.pb1.Value     = 0;
                    i = 0;
                    oCmd.CommandText = "spCreateSchedDDF_2 '" + sStartDate + "','" + sEndDate + "','3'";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");

                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spInsertSchedule '" + Convert.ToString(oRec["shift_start"]) + "','" + Convert.ToString(oRec["employee_id"]) + "',1284,'DDF',0,'" + Convert.ToString(oRec["job_code"]) + "'," + Convert.ToString(oRec["step"]) + ",'" +
                                           DateTime.Now.ToString("M/d/yyyy") + "','" + modGlobal.Shared.gUser + "'";
                        oCmd.ExecuteNonQuery();
                        //UPGRADE_ISSUE: (2064) ADODB.Command property oCmd.State was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
                        while ((oCmd.getState() == ((int)ConnectionState.Executing)))
                        {
                            //Debug.Print "Executing Insert... " & I
                        }
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating Special Batt 3 DDF Schedule Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creation of Special DDF Schedule Records Complete";
                    //UPGRADE_WARNING: (6021) Casting 'int' to Enum may cause different behaviour. More Information: http://www.vbtonet.com/ewis/ewi6021.aspx
                    for (Response = UpgradeHelpers.Helpers.DialogResult.OK; ((int)Response) <= 10000; Response = (UpgradeHelpers.Helpers.DialogResult)(((int)Response) + 1))
                    {
                    }

                    //Create Payroll Signoff records for new scheduling Period
                    //Check for existing SignOff Records for requested date span
                    oCmd.CommandText = "sp_LastSignOffDate";
                    oRec             = ADORecordSetHelper.Open(oCmd, "");
                    LastDate         = Convert.ToDateTime(oRec["last_date"]);

                    if (LastDate > dtStartDate)
                    {
                        //Delete Overlapping Schedule Records
                        oCmd.CommandText = "spClearSignOff '" + sStartDate + "','" + LastDate.AddDays(1).ToString("M/d/yyyy") + "'";
                        oCmd.ExecuteNonQuery();
                    }
                    else
                    {
                        dtStartDate = LastDate;
                        sStartDate  = dtStartDate.ToString("M/d/yyyy");
                    }

                    //Create SignOff Records
                    ViewModel.lbStatus.Text = "Creating New PayRoll SignOff Records";
                    oCmd.CommandText        = "sp_GetSignOffYear '" + sStartDate + "','" + sEndDate + "'";
                    oRec = ADORecordSetHelper.Open(oCmd, "");
                    ViewModel.pb1.Value = 0;
                    RecFactor           = (int)DateAndTime.DateDiff("d", DateTime.Parse(sStartDate), DateTime.Parse(sEndDate), FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1);
                    i = 0;


                    while (!oRec.EOF)
                    {
                        oCmd.CommandText = "spCreateSignOff " + Convert.ToString(oRec["calendar_year"]) + ",'" + sStartDate + "','" + sEndDate + "','" + modGlobal.Shared.gUser + "','1'";
                        oCmd.ExecuteNonQuery();
                        oCmd.CommandText = "spCreateSignOff " + Convert.ToString(oRec["calendar_year"]) + ",'" + sStartDate + "','" + sEndDate + "','" + modGlobal.Shared.gUser + "','2'";
                        oCmd.ExecuteNonQuery();
                        oCmd.CommandText = "spCreateSignOff " + Convert.ToString(oRec["calendar_year"]) + ",'" + sStartDate + "','" + sEndDate + "','" + modGlobal.Shared.gUser + "','3'";
                        oCmd.ExecuteNonQuery();
                        oRec.MoveNext();
                        i++;
                        if ((i / RecFactor) * 100 > 100)
                        {
                            ViewModel.pb1.Value = 100;
                        }
                        else
                        {
                            ViewModel.pb1.Value = (i / RecFactor) * 100;
                        }
                        ViewModel.lbStatus.Text = "Creating New PayRoll SignOff Records  -  " + ViewModel.pb1.Value.ToString() + "% Complete";
                    }
                    ;
                    ViewModel.lbStatus.Text = "Creation of PayRoll SignOff Records Complete";
                    //UPGRADE_WARNING: (6021) Casting 'int' to Enum may cause different behaviour. More Information: http://www.vbtonet.com/ewis/ewi6021.aspx
                    for (Response = UpgradeHelpers.Helpers.DialogResult.OK; ((int)Response) <= 30000; Response = (UpgradeHelpers.Helpers.DialogResult)(((int)Response) + 1))
                    {
                    }
                    ViewModel.lbStatus.Visible = false;
                    ViewModel.pb1.Value        = 0;
                    ViewModel.pb1.Visible      = false;

                    oRec.Close();
                    oRec = null;
                    oCmd = null;
                    UpgradeHelpers.DB.TransactionManager.DeEnlist(oConUtil);
                    oConUtil.Close();
                    oConUtil = null;
                    ViewModel.cmdExit.Visible = true;
                });
            }
        }