예제 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult dlgResult = CustomClientMessageBox.Show("Delete Device '" + pvtDataView[pvtintDataViewReaderIndex]["DEVICE_DESC"].ToString() + "'",
                                                                     this.Text,
                                                                     MessageBoxButtons.YesNo,
                                                                     MessageBoxIcon.Warning);

                if (dlgResult == DialogResult.Yes)
                {
                    object[] objParm = new object[1];
                    objParm[0] = Convert.ToInt32(pvtDataView[pvtintDataViewReaderIndex]["DEVICE_NO"]);

                    clsISClientUtilities.DynamicFunction("Delete_Record", objParm, true);

                    pvtDataView[pvtintDataViewReaderIndex].Delete();

                    this.pvtDataSet.AcceptChanges();

                    this.Load_CurrentForm_Records();
                }
            }
            catch (Exception eException)
            {
                clsISClientUtilities.ErrorHandler(eException);
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult myDialogResult = CustomClientMessageBox.Show("Are you sure you want to Backup the Database?",
                                                                          this.Text,
                                                                          MessageBoxButtons.YesNo,
                                                                          MessageBoxIcon.Question);

                if (myDialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    int intReturnCode = (int)clsISClientUtilities.DynamicFunction("Backup_DataBase", null, false);

                    if (intReturnCode == 0)
                    {
                        CustomClientMessageBox.Show("Backup Successful.",
                                                    this.Text,
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                    }
                    else
                    {
                        CustomClientMessageBox.Show("Backup Failed.",
                                                    this.Text,
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception eException)
            {
                clsISClientUtilities.ErrorHandler(eException);
            }
        }
        public void btnDelete_Click(object sender, System.EventArgs e)
        {
            try
            {
                DialogResult dlgResult = CustomClientMessageBox.Show("Delete All Employees / Cost Centres / Departments / Groups Linked to Device '" + this.dgvDeviceDataGridView[0, this.dgvDeviceDataGridView.CurrentRow.Index].Value.ToString() + "'",
                                                                     this.Text,
                                                                     MessageBoxButtons.YesNo,
                                                                     MessageBoxIcon.Warning);

                if (dlgResult == DialogResult.Yes)
                {
                    DataView EmployeeChosenDataView = new DataView(pvtDataSet.Tables["EmployeeChosen"], "DEVICE_NO = " + this.pvtintDeviceNo + " AND COMPANY_NO = " + pvtint64CompanyNo, "", DataViewRowState.CurrentRows);

                    for (int intRow = 0; intRow < EmployeeChosenDataView.Count; intRow++)
                    {
                        EmployeeChosenDataView[intRow].Delete();
                        intRow -= 1;
                    }

                    DataView PayCategoryChosenDataView = new DataView(pvtDataSet.Tables["PayCategoryChosen"], "DEVICE_NO = " + this.pvtintDeviceNo + " AND COMPANY_NO = " + pvtint64CompanyNo, "", DataViewRowState.CurrentRows);

                    for (int intRow = 0; intRow < PayCategoryChosenDataView.Count; intRow++)
                    {
                        PayCategoryChosenDataView[intRow].Delete();
                        intRow -= 1;
                    }

                    DataView DepartmentChosenDataView = new DataView(pvtDataSet.Tables["DepartmentChosen"], "DEVICE_NO = " + this.pvtintDeviceNo + " AND COMPANY_NO = " + pvtint64CompanyNo, "", DataViewRowState.CurrentRows);

                    for (int intRow = 0; intRow < DepartmentChosenDataView.Count; intRow++)
                    {
                        DepartmentChosenDataView[intRow].Delete();
                        intRow -= 1;
                    }

                    DataView GroupChosenDataView = new DataView(pvtDataSet.Tables["GroupChosen"], "DEVICE_NO = " + this.pvtintDeviceNo + " AND COMPANY_NO = " + pvtint64CompanyNo, "", DataViewRowState.CurrentRows);

                    for (int intRow = 0; intRow < GroupChosenDataView.Count; intRow++)
                    {
                        GroupChosenDataView[intRow].Delete();
                        intRow -= 1;
                    }

                    pvtDataSet.AcceptChanges();

                    object[] objParm = new object[2];
                    objParm[0] = pvtint64CompanyNo;
                    objParm[1] = pvtintDeviceNo;

                    clsISClientUtilities.DynamicFunction("Delete_Records", objParm, true);

                    this.Load_CurrentForm_Records();
                }
            }
            catch (Exception ex)
            {
                clsISClientUtilities.ErrorHandler(ex);
            }
        }
예제 #4
0
        private void frmClientConvertCostCentre_Load(object sender, EventArgs e)
        {
            try
            {
                miLinkedMenuItem = (ToolStripMenuItem)AppDomain.CurrentDomain.GetData("LinkedMenuItem");

                clsISClientUtilities = new clsISClientUtilities(this, "busClientConvertCostCentre");

                this.lblCompanySpreadsheetHeader.Paint += new System.Windows.Forms.PaintEventHandler(clsISClientUtilities.Label_Paint);
                this.lblPayrollTypeHeader.Paint        += new System.Windows.Forms.PaintEventHandler(clsISClientUtilities.Label_Paint);
                this.lblPayCategoryDesc.Paint          += new System.Windows.Forms.PaintEventHandler(clsISClientUtilities.Label_Paint);
                this.lblPayCategorySelectDesc.Paint    += new System.Windows.Forms.PaintEventHandler(clsISClientUtilities.Label_Paint);

                this.dgvConvertToPayrollTypeDataGridView.Rows.Add("Wages");
                this.dgvConvertToPayrollTypeDataGridView.Rows.Add("TimeSheets");
                this.dgvConvertToPayrollTypeDataGridView.Rows.Add("Salaries");

                pvtblnConvertToPayrollTypeDataGridViewLoaded = true;

                this.Set_DataGridView_SelectedRowIndex(this.dgvConvertToPayrollTypeDataGridView, 0);

                try
                {
                    clsISUtilities = new InteractPayroll.clsISUtilities(this, "busConvertCostCentre");
                }
                catch (Exception ex)
                {
                    CustomClientMessageBox.Show("Connection to Internet Database Could Not be Established", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                object[] objParm = new object[0];

                pvtbytCompress = (byte[])clsISClientUtilities.DynamicFunction("Get_Form_Records", objParm, false);

                pvtDataSet = clsISClientUtilities.DeCompress_Array_To_DataSet(pvtbytCompress);

                for (int intRow = 0; intRow < this.pvtDataSet.Tables["Company"].Rows.Count; intRow++)
                {
                    this.dgvCompanyDataGridView.Rows.Add(this.pvtDataSet.Tables["Company"].Rows[intRow]["COMPANY_DESC"].ToString(),
                                                         this.pvtDataSet.Tables["Company"].Rows[intRow]["COMPANY_NO"].ToString());
                }

                pvtblnCompanyDataGridViewLoaded = true;

                if (this.dgvCompanyDataGridView.Rows.Count > 0)
                {
                    this.Set_DataGridView_SelectedRowIndex(this.dgvCompanyDataGridView, 0);
                }
            }
            catch (Exception eException)
            {
                clsISClientUtilities.ErrorHandler(eException);
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult myDialogResult = CustomClientMessageBox.Show("Are you sure you want to Delete the Backup File?",
                                                                          this.Text,
                                                                          MessageBoxButtons.YesNo,
                                                                          MessageBoxIcon.Question);

                if (myDialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    string strFileName = this.dgvFilesDataGridView[1, this.Get_DataGridView_SelectedRowIndex(this.dgvFilesDataGridView)].Value.ToString();

                    object[] objParm = new object[1];
                    //#if(DEBUG)
                    //                    MessageBox.Show("Delete NOT Available in DEBUG Mode");
                    //#else
                    objParm[0] = strFileName;

                    clsISClientUtilities.DynamicFunction("Delete_Backup_File", objParm, false);

                    this.Refresh();

                    CustomClientMessageBox.Show("Delete of Backup File Successful.",
                                                this.Text,
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information);

                    //#endif
                    this.dgvFilesDataGridView.Rows.RemoveAt(this.Get_DataGridView_SelectedRowIndex(this.dgvFilesDataGridView));

                    if (this.dgvFilesDataGridView.Rows.Count == 0)
                    {
                        this.btnOK.Enabled     = false;
                        this.btnDelete.Visible = false;
                    }
                }
            }
            catch (Exception eException)
            {
                clsISClientUtilities.ErrorHandler(eException);
            }
        }
예제 #6
0
        public void btnDelete_Click(object sender, System.EventArgs e)
        {
            try
            {
                DialogResult dlgResult = CustomClientMessageBox.Show("Delete Group '" + pvtGroupDataView[this.pvtintGroupDataViewRow]["GROUP_DESC"].ToString() + "'",
                                                                     this.Text,
                                                                     MessageBoxButtons.YesNo,
                                                                     MessageBoxIcon.Question);

                if (dlgResult == DialogResult.Yes)
                {
                    object[] objParm = new object[2];
                    objParm[0] = pvtint64CompanyNo;
                    objParm[1] = pvtintGroupNo;

                    clsISClientUtilities.DynamicFunction("Delete_Group", objParm, true);

                    pvtGroupDataView[pvtintGroupDataViewRow].Delete();

                    DataView EmployeeLinkDataView = new DataView(pvtDataSet.Tables["EmployeeLink"], "GROUP_NO = " + pvtintGroupNo + " AND COMPANY_NO = " + pvtint64CompanyNo, "", DataViewRowState.CurrentRows);

                    for (int intRow = 0; intRow < EmployeeLinkDataView.Count; intRow++)
                    {
                        EmployeeLinkDataView[intRow].Delete();
                        intRow -= 1;
                    }

                    this.pvtDataSet.AcceptChanges();

                    pvtintGroupNo = -1;

                    this.Load_CurrentForm_Records();
                }
            }
            catch (Exception eException)
            {
                clsISClientUtilities.ErrorHandler(eException);
            }
        }
예제 #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string strTimeFrom = "";
                string strTimeTo   = "";

                if (this.cboCompany.SelectedIndex == -1)
                {
                    CustomClientMessageBox.Show("Select Company that owns Clock Reader.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.cboCompany.Focus();
                    return;
                }

                if (this.txtReader.Text.Trim() == "")
                {
                    CustomClientMessageBox.Show("Enter Clock Reader Description.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.txtReader.Focus();
                    return;
                }
                else
                {
                    pvtstrDeviceDesc = this.txtReader.Text.Trim();
                }

                pvtstrTimeAttendClockFirstLastInd = "";

                if (this.rbnTimeAttend.Checked == true)
                {
                    pvtstrDeviceUsage = "T";
                }
                else
                {
                    if (this.rbnAccess.Checked == true)
                    {
                        pvtstrDeviceUsage = "A";
                    }
                    else
                    {
                        if (this.rbnBoth.Checked == true)
                        {
                            pvtstrDeviceUsage = "B";

                            if (this.rbnClockNormal.Checked == true)
                            {
                                pvtstrTimeAttendClockFirstLastInd = "N";
                            }
                            else
                            {
                                if (this.rbnClockFirstLast.Checked == true)
                                {
                                    pvtstrTimeAttendClockFirstLastInd = "Y";
                                }
                                else
                                {
                                    CustomClientMessageBox.Show("Choose Access / Time & Attendance Option.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                            }
                        }
                        else
                        {
                            CustomClientMessageBox.Show("Choose Device Usage.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                }

                if (this.rbnInOnly.Checked == true)
                {
                    pvtstrClockInOutParm = "I";
                }
                else
                {
                    if (this.rbnOutOnly.Checked == true)
                    {
                        pvtstrClockInOutParm = "O";
                    }
                    else
                    {
                        if (this.rbnDynamic.Checked == true)
                        {
                            pvtstrClockInOutParm = "D";
                        }
                        else
                        {
                            if (this.rbnClockRange.Checked == true)
                            {
                                if (this.cboFromHour.SelectedIndex == -1)
                                {
                                    this.cboFromHour.Focus();
                                    CustomClientMessageBox.Show("Select From Hour.\n\n(Clock Range - In Range)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }

                                if (this.cboFromMinute.SelectedIndex == -1)
                                {
                                    this.cboFromMinute.Focus();
                                    CustomClientMessageBox.Show("Select From Minute.\n\n(Clock Range - In Range)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }

                                if (this.cboToHour.SelectedIndex == -1)
                                {
                                    this.cboToHour.Focus();
                                    CustomClientMessageBox.Show("Select To Hour.\n\n(Clock Range - In Range)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }

                                if (this.cboToMinute.SelectedIndex == -1)
                                {
                                    this.cboToMinute.Focus();
                                    CustomClientMessageBox.Show("Select To Minute.\n\n(Clock Range - In Range)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }

                                pvtstrClockInOutParm = "R";

                                strTimeFrom = this.cboFromHour.SelectedItem.ToString() + this.cboFromMinute.SelectedItem.ToString();
                                strTimeTo   = this.cboToHour.SelectedItem.ToString() + this.cboToMinute.SelectedItem.ToString();

                                pvtintClockInRangeFrom = Convert.ToInt32(strTimeFrom);
                                pvtintClockInRangeTo   = Convert.ToInt32(strTimeTo);
                            }
                            else
                            {
                                CustomClientMessageBox.Show("Select a " + this.grbClockOptions.Text + ".", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                    }
                }

                if (this.cboLockOut.SelectedIndex == -1)
                {
                    CustomClientMessageBox.Show("Select Lock Out Time.\n\n(Access Control - Employee Lock Out)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.cboLockOut.Focus();
                    return;
                }
                else
                {
                    pvtintLockOutMinutes = Convert.ToInt32(this.cboLockOut.SelectedItem.ToString());
                }

                if (this.cboCompany.Items.Count > 0)
                {
                    if (this.cboCompany.SelectedIndex == -1)
                    {
                        CustomClientMessageBox.Show("Select Company that owns Clock Reader.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.cboCompany.Focus();
                        return;
                    }
                    else
                    {
                        pvtintCompanyNo = Convert.ToInt32(pvtDataSet.Tables["Company"].Rows[this.cboCompany.SelectedIndex]["COMPANY_NO"]);
                    }
                }
                else
                {
                    pvtintCompanyNo = -1;
                }

                if (this.rbnWAN.Checked == true)
                {
                    pvtstrLanWanInd = "W";
                }
                else
                {
                    pvtstrLanWanInd = "L";
                }

                if (this.cboFAR.SelectedIndex == -1)
                {
                    CustomClientMessageBox.Show("Select False Acceptance Read Value.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.cboFAR.Focus();
                    return;
                }
                else
                {
                    pvtintFARRequested = intPossibleFARValuesArray[this.cboFAR.SelectedIndex];
                }


                DataSet TempDataSet = new DataSet();
                TempDataSet.Tables.Add(pvtDataSet.Tables["Clock"].Clone());

                if (this.Text.IndexOf(" - New") > 0)
                {
                    DataRowView drvDataRowView = this.pvtDataView.AddNew();
                    //Set Key for Find
                    drvDataRowView["DEVICE_NO"]    = 0;
                    drvDataRowView["DEVICE_DESC"]  = pvtstrDeviceDesc;
                    drvDataRowView["DEVICE_USAGE"] = pvtstrDeviceUsage;
                    drvDataRowView["TIME_ATTEND_CLOCK_FIRST_LAST_IND"] = pvtstrTimeAttendClockFirstLastInd;
                    drvDataRowView["CLOCK_IN_OUT_PARM"]   = pvtstrClockInOutParm;
                    drvDataRowView["CLOCK_IN_RANGE_FROM"] = pvtintClockInRangeFrom;
                    drvDataRowView["CLOCK_IN_RANGE_TO"]   = pvtintClockInRangeTo;
                    drvDataRowView["LOCK_OUT_MINUTES"]    = pvtintLockOutMinutes;
                    drvDataRowView["COMPANY_NO"]          = pvtintCompanyNo;
                    drvDataRowView["LAN_WAN_IND"]         = pvtstrLanWanInd;
                    drvDataRowView["FAR_REQUESTED"]       = pvtintFARRequested;

                    drvDataRowView.EndEdit();

                    TempDataSet.Tables["Clock"].ImportRow(drvDataRowView.Row);

                    //Compress DataSet
                    byte[] pvtbytCompress = clsISClientUtilities.Compress_DataSet(TempDataSet);

                    object[] objParm = new object[1];
                    objParm[0] = pvtbytCompress;

                    drvDataRowView["DEVICE_NO"] = clsISClientUtilities.DynamicFunction("Insert_Record", objParm, true);

                    this.pvtintDeviceNo = Convert.ToInt32(drvDataRowView["DEVICE_NO"]);
                }
                else
                {
                    pvtDataView[pvtintDataViewReaderIndex]["DEVICE_DESC"]  = pvtstrDeviceDesc;
                    pvtDataView[pvtintDataViewReaderIndex]["DEVICE_USAGE"] = pvtstrDeviceUsage;
                    pvtDataView[pvtintDataViewReaderIndex]["TIME_ATTEND_CLOCK_FIRST_LAST_IND"] = pvtstrTimeAttendClockFirstLastInd;
                    pvtDataView[pvtintDataViewReaderIndex]["CLOCK_IN_OUT_PARM"]   = pvtstrClockInOutParm;
                    pvtDataView[pvtintDataViewReaderIndex]["CLOCK_IN_RANGE_FROM"] = pvtintClockInRangeFrom;
                    pvtDataView[pvtintDataViewReaderIndex]["CLOCK_IN_RANGE_TO"]   = pvtintClockInRangeTo;
                    pvtDataView[pvtintDataViewReaderIndex]["LOCK_OUT_MINUTES"]    = pvtintLockOutMinutes;
                    pvtDataView[pvtintDataViewReaderIndex]["COMPANY_NO"]          = pvtintCompanyNo;
                    pvtDataView[pvtintDataViewReaderIndex]["LAN_WAN_IND"]         = pvtstrLanWanInd;
                    pvtDataView[pvtintDataViewReaderIndex]["FAR_REQUESTED"]       = pvtintFARRequested;

                    TempDataSet.Tables["Clock"].ImportRow(pvtDataView[pvtintDataViewReaderIndex].Row);

                    //Compress DataSet
                    byte[] pvtbytCompress = clsISClientUtilities.Compress_DataSet(TempDataSet);

                    object[] objParm = new object[1];
                    objParm[0] = pvtbytCompress;

                    clsISClientUtilities.DynamicFunction("Update_Record", objParm, true);

                    this.dgvClockDataGridView[pvtintClockDescCol, this.dgvClockDataGridView.CurrentRow.Index].Value = pvtstrDeviceDesc;
                }

                pvtDataSet.AcceptChanges();

                if (this.Text.IndexOf(" - New") > 0)
                {
                    Load_CurrentForm_Records();
                }

                btnCancel_Click(sender, e);
            }
            catch (Exception ex)
            {
                clsISClientUtilities.ErrorHandler(ex);
            }
        }
예제 #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool blnServerDatabaseConverted = false;

            try
            {
                if (this.dgvChosenPayCategoryDataGridView.Rows.Count == 0)
                {
                    CustomClientMessageBox.Show("There are NO Selected Cost Centres.\nFix to Continue.",
                                                this.Text,
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                    return;
                }

                DialogResult dlgResult = CustomClientMessageBox.Show("Are you absolutely sure you want to Convert the Selected Cost Centre/s to '" + dgvConvertToPayrollTypeDataGridView[0, pvtintConvertToPayrollTypeDataGridViewRowIndex].Value.ToString() + "'",
                                                                     this.Text,
                                                                     MessageBoxButtons.YesNo,
                                                                     MessageBoxIcon.Warning);

                if (dlgResult == DialogResult.Yes)
                {
                    DataSet DataSet = new DataSet();

                    DataTable myDataTable = this.pvtDataSet.Tables["PayCategory"].Clone();

                    for (int intRow = 0; intRow < this.dgvChosenPayCategoryDataGridView.Rows.Count; intRow++)
                    {
                        DataRow drDataRow = myDataTable.NewRow();

                        drDataRow["COMPANY_NO"]        = pvtInt64CompanyNo;
                        drDataRow["PAY_CATEGORY_NO"]   = Convert.ToInt32(this.dgvChosenPayCategoryDataGridView[2, intRow].Value);
                        drDataRow["PAY_CATEGORY_TYPE"] = this.dgvChosenPayCategoryDataGridView[1, intRow].Value.ToString();

                        myDataTable.Rows.Add(drDataRow);
                    }

                    DataSet.Tables.Add(myDataTable);

                    //Compress DataSet
                    pvtbytCompress = clsISClientUtilities.Compress_DataSet(DataSet);

                    object[] objParm = new object[3];
                    objParm[0] = pvtInt64CompanyNo;
                    objParm[1] = pvtstrToPayCategoryType;
                    objParm[2] = pvtbytCompress;

                    //Backup Internet Database
                    int intReturnCode = (int)clsISUtilities.DynamicFunction("Check_Run", objParm, false);

                    if (intReturnCode == 9)
                    {
                        CustomClientMessageBox.Show("You do NOT have permission to perform this operation.\nSpeak to System Administrator.",
                                                    this.Text,
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error);

                        goto btnSave_Click_Continue;
                    }
                    else
                    {
                        if (intReturnCode == 1)
                        {
                            this.tmrProcess.Enabled = false;
                            this.picDatabaseConvertInternet.Image = global::ConvertCostCentre.Properties.Resources.Error;

                            CustomClientMessageBox.Show("There is Currently a Payroll/Time Attendance Run Date Open.\nFix to Continue.",
                                                        this.Text,
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Error);

                            goto btnSave_Click_Continue;
                        }
                    }

                    pvtintProcessNo = 0;
                    pvtblnShowImage = false;

                    this.picDatabaseBackupInternet.Image  = null;
                    this.picDatabaseBackupLocal.Image     = null;
                    this.picDatabaseConvertInternet.Image = null;
                    this.picDatabaseConvertLocal.Image    = null;

                    this.grbConversionProcess.Visible = true;

                    this.Refresh();

                    this.tmrProcess.Enabled = true;
                    DateTime dtDateTimeNext = DateTime.Now.AddSeconds(pvtintTimeDelaySeconds);

                    clsISUtilities.Set_New_BusinessObjectName("busBackupRestoreDatabase");

                    objParm    = new object[2];
                    objParm[0] = pvtInt64CompanyNo;
                    objParm[1] = "_Backup_Before_CostCentre_Conversion";

                    //Backup Internet Database
                    intReturnCode = (int)clsISUtilities.DynamicFunction("Backup_DataBase_New", objParm, false);

                    if (intReturnCode != 0)
                    {
                        this.tmrProcess.Enabled = false;
                        this.picDatabaseBackupInternet.Image = global::ConvertCostCentre.Properties.Resources.Error;

                        CustomClientMessageBox.Show("Error Backing up Internet Database.\nFix to Continue.",
                                                    this.Text,
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error);

                        goto btnSave_Click_Continue;
                    }

                    while (DateTime.Now < dtDateTimeNext)
                    {
                        Application.DoEvents();
                    }

                    this.picDatabaseBackupInternet.Image = global::ConvertCostCentre.Properties.Resources.Ok;
                    this.pvtintProcessNo += 1;
                    dtDateTimeNext        = DateTime.Now.AddSeconds(pvtintTimeDelaySeconds);

                    //Reset Class
                    clsISUtilities.Set_New_BusinessObjectName("busConvertCostCentre");

                    this.pnlDatabaseLocalBackup.Visible = true;
                    this.Refresh();

                    clsISClientUtilities.Set_New_BusinessObjectName("busBackupRestoreClientDatabase");

                    objParm    = new object[1];
                    objParm[0] = "_Backup_Before_CostCentre_Conversion";

                    //Backup Client Database
                    intReturnCode = (int)clsISClientUtilities.DynamicFunction("Backup_DataBase_New", objParm, false);

                    if (intReturnCode != 0)
                    {
                        this.tmrProcess.Enabled           = false;
                        this.picDatabaseBackupLocal.Image = global::ConvertCostCentre.Properties.Resources.Error;

                        CustomClientMessageBox.Show("Error Backing up Client Database.\nFix to Continue.",
                                                    this.Text,
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error);

                        goto btnSave_Click_Continue;
                    }

                    while (DateTime.Now < dtDateTimeNext)
                    {
                        Application.DoEvents();
                    }

                    this.picDatabaseBackupLocal.Image = global::ConvertCostCentre.Properties.Resources.Ok;
                    this.pvtintProcessNo += 1;
                    dtDateTimeNext        = DateTime.Now.AddSeconds(pvtintTimeDelaySeconds);

                    //Reset Class
                    clsISClientUtilities.Set_New_BusinessObjectName("busClientConvertCostCentre");

                    objParm    = new object[3];
                    objParm[0] = pvtInt64CompanyNo;
                    objParm[1] = pvtstrToPayCategoryType;
                    objParm[2] = pvtbytCompress;

                    //Convert Server
                    intReturnCode = (int)clsISUtilities.DynamicFunction("Convert_Records", objParm, false);

                    if (intReturnCode == 0)
                    {
                        blnServerDatabaseConverted = true;

                        while (DateTime.Now < dtDateTimeNext)
                        {
                            Application.DoEvents();
                        }

                        this.picDatabaseConvertInternet.Image = global::ConvertCostCentre.Properties.Resources.Ok;
                        this.pvtintProcessNo += 1;
                        dtDateTimeNext        = DateTime.Now.AddSeconds(pvtintTimeDelaySeconds);

                        //Convert Client Databases
                        clsISClientUtilities.DynamicFunction("Convert_Client_Records", objParm, true);

                        while (DateTime.Now < dtDateTimeNext)
                        {
                            Application.DoEvents();
                        }

                        this.tmrProcess.Enabled            = false;
                        this.picDatabaseConvertLocal.Image = global::ConvertCostCentre.Properties.Resources.Ok;

                        CustomClientMessageBox.Show("Conversion Successful.",
                                                    this.Text,
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                    }

btnSave_Click_Continue:

                    btnCancel_Click(sender, e);
                }
            }
            catch (Exception eException)
            {
                this.tmrProcess.Enabled = false;

                if (pvtintProcessNo == 0)
                {
                    this.picDatabaseBackupInternet.Image = global::ConvertCostCentre.Properties.Resources.Error;
                }
                else
                {
                    if (pvtintProcessNo == 1)
                    {
                        this.picDatabaseBackupLocal.Image = global::ConvertCostCentre.Properties.Resources.Error;
                    }
                    else
                    {
                        if (pvtintProcessNo == 2)
                        {
                            this.picDatabaseConvertInternet.Image = global::ConvertCostCentre.Properties.Resources.Error;
                        }
                        else
                        {
                            if (pvtintProcessNo == 3)
                            {
                                this.picDatabaseConvertLocal.Image = global::ConvertCostCentre.Properties.Resources.Error;
                            }
                        }
                    }
                }

                if (blnServerDatabaseConverted == true)
                {
                    CustomClientMessageBox.Show("Server Database Converted. / Local Database CONVERT FAILURE.\nURGENT - Speak to System Administrator.",
                                                this.Text,
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                }

                clsISClientUtilities.ErrorHandler(eException);
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult myDialogResult = CustomClientMessageBox.Show("Are you sure you want to Restore this Database?",
                                                                          this.Text,
                                                                          MessageBoxButtons.YesNo,
                                                                          MessageBoxIcon.Question);

                if (myDialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    this.btnOK.Enabled = false;

                    pvtintProcess = 0;
                    grbActivationProcess.Visible    = true;
                    this.pnlRestoreDatabase.Visible = false;

                    this.picBackupBefore.Image    = (Image)global::InteractPayrollClient.Properties.Resources.Question;
                    this.picRestoreDatabase.Image = null;

                    DateTime dtWaitTime = DateTime.Now.AddSeconds(3);

                    this.tmrTimer.Enabled = true;

                    int intReturnCode = 0;

                    intReturnCode = (int)clsISClientUtilities.DynamicFunction("Backup_DataBase_Before_Restore", null, false);

                    this.tmrTimer.Enabled        = false;
                    this.picBackupBefore.Visible = true;

                    if (intReturnCode == 0)
                    {
                        while (dtWaitTime > DateTime.Now)
                        {
                            Application.DoEvents();
                        }

                        dtWaitTime = DateTime.Now.AddSeconds(3);

                        this.picBackupBefore.Image = (Image)global::InteractPayrollClient.Properties.Resources.Ok;

                        pvtintProcess += 1;
                        this.pnlRestoreDatabase.Visible = true;
                        this.picRestoreDatabase.Image   = (Image)global::InteractPayrollClient.Properties.Resources.Question;

                        this.tmrTimer.Enabled = true;

                        object[] objParm = new object[1];

                        objParm[0] = dgvFilesDataGridView[1, dgvFilesDataGridView.SelectedRows[0].Index].Value.ToString();

                        intReturnCode = (int)clsISClientUtilities.DynamicFunction("Restore_DataBase", objParm, false);

                        this.tmrTimer.Enabled           = false;
                        this.picRestoreDatabase.Visible = true;

                        while (dtWaitTime > DateTime.Now)
                        {
                            Application.DoEvents();
                        }

                        if (intReturnCode == 0)
                        {
                            this.picRestoreDatabase.Image = (Image)global::InteractPayrollClient.Properties.Resources.Ok;
                            this.Refresh();


                            CustomClientMessageBox.Show("Restore Successful.",
                                                        this.Text,
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Information);
                        }
                        else
                        {
                            this.picRestoreDatabase.Image = (Image)global::InteractPayrollClient.Properties.Resources.Error;
                            this.Refresh();

                            CustomClientMessageBox.Show("Restore Failed.",
                                                        this.Text,
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        this.picBackupBefore.Image = (Image)global::InteractPayrollClient.Properties.Resources.Error;

                        CustomClientMessageBox.Show("Backup of Database Before Restore Failed.",
                                                    this.Text,
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error);
                    }

                    Load_Restore_Files();

                    this.grbActivationProcess.Visible = false;
                }
            }
            catch (Exception eException)
            {
                clsISClientUtilities.ErrorHandler(eException);
            }
        }
예제 #10
0
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.txtGroup.Text.Trim() == "")
                {
                    CustomClientMessageBox.Show("Enter Group Description.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.txtGroup.Focus();
                    return;
                }

                if (this.dgvEmployeeLinkedDataGridView.Rows.Count == 0)
                {
                    CustomClientMessageBox.Show("Select Employees.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.btnAdd.Focus();
                    return;
                }

                if (this.Text.IndexOf(" - New") > 0)
                {
                    pvtintGroupNo = 0;
                }

                //NB - New Will Not Remove Any Records
                DataView EmployeeLinkDataView = new DataView(pvtDataSet.Tables["EmployeeLink"], "GROUP_NO = " + pvtintGroupNo + " AND COMPANY_NO = " + pvtint64CompanyNo, "", DataViewRowState.CurrentRows);

                for (int intRow = 0; intRow < EmployeeLinkDataView.Count; intRow++)
                {
                    EmployeeLinkDataView[intRow].Delete();
                    intRow -= 1;
                }

                pvtDataSet.AcceptChanges();

                for (int intRowCount = 0; intRowCount < this.dgvEmployeeLinkedDataGridView.Rows.Count; intRowCount++)
                {
                    DataRowView drvDataRowView = EmployeeLinkDataView.AddNew();

                    drvDataRowView["GROUP_NO"]          = pvtintGroupNo;
                    drvDataRowView["COMPANY_NO"]        = pvtint64CompanyNo;
                    drvDataRowView["EMPLOYEE_NO"]       = Convert.ToInt32(this.dgvEmployeeLinkedDataGridView[pvtintEmployeeNoCol, intRowCount].Value);
                    drvDataRowView["PAY_CATEGORY_NO"]   = Convert.ToInt32(this.dgvEmployeeLinkedDataGridView[pvtintPayCategoryNoCol, intRowCount].Value);
                    drvDataRowView["PAY_CATEGORY_TYPE"] = this.dgvEmployeeLinkedDataGridView[pvtintPayCategoryTypeCol, intRowCount].Value.ToString();

                    drvDataRowView.EndEdit();
                }



                DataSet TempDataSet = new DataSet();
                //Add EmployeePayCategory Table
                TempDataSet.Tables.Add(pvtDataSet.Tables["EmployeeLink"].Clone());

                for (int intRow = 0; intRow < EmployeeLinkDataView.Count; intRow++)
                {
                    TempDataSet.Tables["EmployeeLink"].ImportRow(EmployeeLinkDataView[intRow].Row);
                }

                //Compress DataSet
                byte[] pvtbytCompress = clsISClientUtilities.Compress_DataSet(TempDataSet);

                this.Cursor = Cursors.WaitCursor;

                if (this.Text.IndexOf(" - New") > 0)
                {
                    object[] objParm = new object[3];
                    objParm[0] = pvtint64CompanyNo;
                    objParm[1] = this.txtGroup.Text.Trim();
                    objParm[2] = pvtbytCompress;

                    pvtintGroupNo = (int)clsISClientUtilities.DynamicFunction("Insert_Group", objParm, true);

                    for (int intRowCount = 0; intRowCount < EmployeeLinkDataView.Count; intRowCount++)
                    {
                        EmployeeLinkDataView[intRowCount]["GROUP_NO"] = pvtintGroupNo;

                        intRowCount -= 1;
                    }

                    DataRowView drvDataRowView = this.pvtGroupDataView.AddNew();
                    //Set Key for Find
                    drvDataRowView["COMPANY_NO"] = pvtDataSet.Tables["Company"].Rows[pvtintCompanyDataTableRow]["COMPANY_NO"].ToString();
                    drvDataRowView["GROUP_DESC"] = this.txtGroup.Text.Trim();
                    drvDataRowView["GROUP_NO"]   = pvtintGroupNo;

                    drvDataRowView.EndEdit();
                }
                else
                {
                    object[] objParm = new object[4];
                    objParm[0] = Convert.ToInt64(pvtDataSet.Tables["Company"].Rows[pvtintCompanyDataTableRow]["COMPANY_NO"]);
                    objParm[1] = pvtintGroupNo;
                    objParm[2] = this.txtGroup.Text.Trim();
                    objParm[3] = pvtbytCompress;

                    clsISClientUtilities.DynamicFunction("Update_Group", objParm, true);

                    this.dgvGroupDataGridView[0, this.dgvGroupDataGridView.CurrentRow.Index].Value = this.txtGroup.Text.Trim();
                    pvtGroupDataView[pvtintGroupDataViewRow]["GROUP_DESC"] = this.txtGroup.Text.Trim();
                }

                pvtDataSet.AcceptChanges();

                if (this.Text.IndexOf(" - New") > 0)
                {
                    Load_CurrentForm_Records();
                }

                btnCancel_Click(sender, e);

                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                clsISClientUtilities.ErrorHandler(ex);
            }
        }