Esempio n. 1
0
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                int intDataViewRow = 0;

                for (int intRow = 0; intRow < pvtEmployeeDataView.Count; intRow++)
                {
                    intDataViewRow = Convert.ToInt32(this.dgvEmployeesDataGridView[7, intRow].Value);

                    if (Convert.ToDouble(this.dgvEmployeesDataGridView[4, intRow].Value) == Convert.ToDouble(pvtEmployeeDataView[intDataViewRow]["PREV_NORMAL_LEAVE_DAYS"])
                        & Convert.ToDouble(this.dgvEmployeesDataGridView[5, intRow].Value) == Convert.ToDouble(pvtEmployeeDataView[intDataViewRow]["NORMAL_LEAVE_DAYS"])
                        & Convert.ToDouble(this.dgvEmployeesDataGridView[6, intRow].Value) == Convert.ToDouble(pvtEmployeeDataView[intDataViewRow]["SICK_LEAVE_DAYS"]))
                    {
                        continue;
                    }

                    pvtEmployeeDataView[intDataViewRow]["PREV_NORMAL_LEAVE_DAYS"] = Math.Round(Convert.ToDouble(this.dgvEmployeesDataGridView[4, intRow].Value), 2);
                    pvtEmployeeDataView[intDataViewRow]["NORMAL_LEAVE_DAYS"]      = Math.Round(Convert.ToDouble(this.dgvEmployeesDataGridView[5, intRow].Value), 2);
                    pvtEmployeeDataView[intDataViewRow]["SICK_LEAVE_DAYS"]        = Math.Round(Convert.ToDouble(this.dgvEmployeesDataGridView[6, intRow].Value), 2);
                }

                pvtTempDataSet = null;
                pvtTempDataSet = new DataSet();

                DataTable myDataTable = this.pvtDataSet.Tables["Employee"].Clone();
                pvtTempDataSet.Tables.Add(myDataTable);

                if (pvtEmployeeDataView != null)
                {
                    for (int intRow = 0; intRow < pvtEmployeeDataView.Count; intRow++)
                    {
                        if (pvtEmployeeDataView[intRow].Row.RowState == DataRowState.Modified)
                        {
                            pvtTempDataSet.Tables["Employee"].ImportRow(pvtEmployeeDataView[intRow].Row);
                        }
                    }
                }

                if (pvtTempDataSet.Tables["Employee"].Rows.Count > 0)
                {
                    //Compress DataSet
                    pvtbytCompress = clsISUtilities.Compress_DataSet(pvtTempDataSet);

                    object[] objParm = new object[2];
                    objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                    objParm[1] = pvtbytCompress;

                    clsISUtilities.DynamicFunction("Update_Record", objParm);
                }

                this.pvtDataSet.AcceptChanges();

                btnCancel_Click(sender, e);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet tempDataSet = new DataSet();

                tempDataSet.Tables.Add(pvtDataSet.Tables["Earning"].Clone());

                pvtEarningDataView = null;
                pvtEarningDataView = new DataView(this.pvtDataSet.Tables["Earning"],
                                                  "PAY_CATEGORY_NO = " + pvtintPayCategoryNo + " AND EMPLOYEE_NO = " + this.pvtintEmployeeNo,
                                                  "",
                                                  DataViewRowState.Added | DataViewRowState.ModifiedCurrent);

                for (int intRow = 0; intRow < pvtEarningDataView.Count; intRow++)
                {
                    tempDataSet.Tables["Earning"].ImportRow(pvtEarningDataView[intRow].Row);
                }

                tempDataSet.Tables.Add(pvtDataSet.Tables["Deduction"].Clone());

                pvtEarningDataView = null;
                pvtEarningDataView = new DataView(this.pvtDataSet.Tables["Deduction"],
                                                  "EMPLOYEE_NO = " + this.pvtintEmployeeNo,
                                                  "",
                                                  DataViewRowState.Added | DataViewRowState.ModifiedCurrent);

                for (int intRow = 0; intRow < pvtEarningDataView.Count; intRow++)
                {
                    tempDataSet.Tables["Deduction"].ImportRow(pvtEarningDataView[intRow].Row);
                }

                byte[] bytCompress = clsISUtilities.Compress_DataSet(tempDataSet);

                object[] objParm = new object[5];
                objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                objParm[1] = pvtintPayCategoryNo;
                objParm[2] = pvtstrNormPaidPerPeriod;
                objParm[3] = pvtstrSickPaidPerPeriod;
                objParm[4] = bytCompress;

                clsISUtilities.DynamicFunction("Update_Employee_Earnings_Deductions", objParm);

                this.pvtDataSet.AcceptChanges();

                btnCancel_Click(null, e);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet TempDataSet = new DataSet();

                TempDataSet.Tables.Add(this.pvtDataSet.Tables["EtiEmployeeSave"].Clone());

                for (int intRow = 0; intRow < this.dgvEmployeeDataGridView.Rows.Count; intRow++)
                {
                    DataRow DataRow = TempDataSet.Tables["EtiEmployeeSave"].NewRow();

                    DataRow["EMPLOYEE_NO"]    = Convert.ToInt32(this.dgvEmployeeDataGridView[EmployeeNoCol, intRow].Value);
                    DataRow["ETI_MONTH"]      = Convert.ToInt32(this.dgvEmployeeDataGridView[EmployeeEtiMonthCol, intRow].Value);
                    DataRow["TOTAL_HOURS"]    = Convert.ToDecimal(this.dgvEmployeeDataGridView[EmployeeTotalHoursCol, intRow].Value);
                    DataRow["FACTOR"]         = Convert.ToDecimal(this.dgvEmployeeDataGridView[EmployeeFactorCol, intRow].Value);
                    DataRow["TOTAL_EARNINGS"] = Convert.ToDecimal(this.dgvEmployeeDataGridView[EmployeeTotalAmountCol, intRow].Value);
                    DataRow["ETI_EARNINGS"]   = Convert.ToDecimal(this.dgvEmployeeDataGridView[EmployeeEtiAmountCol, intRow].Value);
                    DataRow["ETI_VALUE"]      = Convert.ToDecimal(this.dgvEmployeeDataGridView[EmployeeEtiCalculatedCol, intRow].Value);

                    TempDataSet.Tables["EtiEmployeeSave"].Rows.Add(DataRow);
                }

                byte[] pvtbytCompress = clsISUtilities.Compress_DataSet(TempDataSet);

                object[] objParm = new object[5];
                objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                objParm[1] = AppDomain.CurrentDomain.GetData("AccessInd").ToString();
                objParm[2] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                objParm[3] = Convert.ToDateTime(this.pvtDataSet.Tables["EtiRunDate"].Rows[intSelectedRowIndex]["ETI_RUN_DATE"]).ToString("yyyy-MM-dd");
                objParm[4] = pvtbytCompress;

                byte[] bytCompress = (byte[])clsISUtilities.DynamicFunction("Insert_Eti_Records", objParm, true);

                pvtDataSet = clsISUtilities.DeCompress_Array_To_DataSet(bytCompress);

                cboEtiRunDate.Items.Clear();
                this.dgvEmployeeDataGridView.Rows.Clear();
                this.dgvEmployeeExcludedDataGridView.Rows.Clear();

                for (int intRow = 0; intRow < this.pvtDataSet.Tables["EtiRunDate"].Rows.Count; intRow++)
                {
                    cboEtiRunDate.Items.Add(Convert.ToDateTime(this.pvtDataSet.Tables["EtiRunDate"].Rows[intRow]["ETI_RUN_DATE"]).ToString("MMMM yyyy"));
                }

                this.btnSave.Enabled = false;
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
Esempio n. 4
0
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                pvtTempDataSet = null;
                pvtTempDataSet = new DataSet();
                DataTable myDataTable;

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

                pvtTempDataSet.Tables.Add(myDataTable);

                for (int intRow = 0; intRow < pvtEmployeeEarningDataView.Count; intRow++)
                {
                    if (pvtEmployeeEarningDataView[intRow].Row.RowState == DataRowState.Modified)
                    {
                        pvtTempDataSet.Tables["EmployeeEarning"].ImportRow(pvtEmployeeEarningDataView[intRow].Row);
                    }
                }

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

                pvtTempDataSet.Tables.Add(myDataTable);

                for (int intRow = 0; intRow < pvtEmployeeDeductionDataView.Count; intRow++)
                {
                    if (pvtEmployeeDeductionDataView[intRow].Row.RowState == DataRowState.Modified)
                    {
                        pvtTempDataSet.Tables["EmployeeDeduction"].ImportRow(pvtEmployeeDeductionDataView[intRow].Row);
                    }
                }

                //Compress DataSet
                pvtbytCompress = clsISUtilities.Compress_DataSet(pvtTempDataSet);

                object[] objParm = new object[3];
                objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                objParm[1] = pvtbytCompress;
                objParm[2] = this.dgvPayrollTypeDataGridView[0, this.Get_DataGridView_SelectedRowIndex(dgvPayrollTypeDataGridView)].Value.ToString().Substring(0, 1);

                clsISUtilities.DynamicFunction("Update_Records", objParm, true);

                this.pvtDataSet.AcceptChanges();

                btnCancel_Click(null, null);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
Esempio n. 5
0
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                pvtTempDataSet = null;
                pvtTempDataSet = new DataSet();
                DataTable DataTable = this.pvtDataSet.Tables["Employee"].Clone();

                pvtTempDataSet.Tables.Add(DataTable);

                pvtEmployeeDataView = null;

                pvtEmployeeDataView = new DataView(pvtDataSet.Tables["Employee"],
                                                   "PAY_CATEGORY_TYPE = '" + this.dgvPayrollTypeDataGridView[0, this.Get_DataGridView_SelectedRowIndex(dgvPayrollTypeDataGridView)].Value.ToString().Substring(0, 1) + "'",
                                                   "EMPLOYEE_CODE",
                                                   DataViewRowState.ModifiedCurrent);

                for (int intRow = 0; intRow < pvtEmployeeDataView.Count; intRow++)
                {
                    pvtTempDataSet.Tables["Employee"].ImportRow(pvtEmployeeDataView[intRow].Row);
                }

                //Compress DataSet
                pvtbytCompress = clsISUtilities.Compress_DataSet(pvtTempDataSet);

                object[] objParm = new object[4];
                objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                objParm[2] = pvtstrMenuId;
                objParm[3] = pvtbytCompress;

                clsISUtilities.DynamicFunction("Update_Employee_Link", objParm, true);

                this.pvtDataSet.AcceptChanges();

                btnCancel_Click(sender, e);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                int intReturnCode = clsISUtilities.DataBind_Save_Check();

                if (intReturnCode != 0)
                {
                    return;
                }

                pvtTempDataSet = null;
                pvtTempDataSet = new DataSet();

                pvtTempDataSet.Tables.Add(this.pvtDataSet.Tables["Leave"].Clone());
                pvtTempDataSet.Tables[0].ImportRow(pvtLeaveDataView[clsISUtilities.DataViewIndex].Row);

                //Compress DataSet
                pvtbytCompress = clsISUtilities.Compress_DataSet(pvtTempDataSet);

                if (this.Text.IndexOf(" - New", 0) > 0)
                {
                    object[] objParm = new object[3];
                    objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                    objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                    objParm[2] = pvtbytCompress;

                    pvtintLeaveNo = (int)clsISUtilities.DynamicFunction("Insert_New_Record", objParm, true);

                    pvtLeaveDataView[clsISUtilities.DataViewIndex]["LEAVE_SHIFT_NO"] = pvtintLeaveNo;

                    //Reset From 0 To Null
                    pvtLeaveDataView[clsISUtilities.DataViewIndex]["PAYROLL_LINK"] = System.DBNull.Value;
                }
                else
                {
                    object[] objParm = new object[3];
                    objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                    objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                    objParm[2] = pvtbytCompress;

                    pvtintReturnCode = (int)clsISUtilities.DynamicFunction("Update_Record", objParm, true);

                    if (pvtintReturnCode == 9999)
                    {
                        this.pvtDataSet.RejectChanges();

                        this.dgvNormalSickLeaveCategoryDataGridView[0, this.Get_DataGridView_SelectedRowIndex(dgvNormalSickLeaveCategoryDataGridView)].Style = this.PayrollLinkDataGridViewCellStyle;

                        pvtLeaveDataView[clsISUtilities.DataViewIndex]["PAYROLL_LINK"] = 0;

                        DialogResult dlgResult = CustomMessageBox.Show("This Normal Leave and Sick Leave Category is currently being used in a Payroll Run.\r\n\r\nUpdate Cancelled.",
                                                                       this.Text,
                                                                       MessageBoxButtons.OK,
                                                                       MessageBoxIcon.Warning);
                    }
                    else
                    {
                        this.dgvNormalSickLeaveCategoryDataGridView[1, this.Get_DataGridView_SelectedRowIndex(dgvNormalSickLeaveCategoryDataGridView)].Value = this.txtLeave.Text.Trim();
                    }
                }

                this.pvtDataSet.Tables["Leave"].AcceptChanges();

                if (this.clsISUtilities.pubintReloadSpreadsheet == true)
                {
                    Load_CurrentForm_Records();
                }
                else
                {
                    btnCancel_Click(sender, e);
                }
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
Esempio n. 7
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                int intReturnCode = Save_Check();

                if (intReturnCode != 0)
                {
                    return;
                }

                DataSet TempDataSet = new DataSet();

                DataTable myDataTable = this.pvtDataSet.Tables["PaidHoliday"].Clone();
                TempDataSet.Tables.Add(myDataTable);

                pvtDataView = null;
                pvtDataView = new DataView(this.pvtDataSet.Tables["PaidHoliday"],
                                           "",
                                           "",
                                           DataViewRowState.Added | DataViewRowState.Deleted | DataViewRowState.ModifiedCurrent);

                for (int intRow = 0; intRow < pvtDataView.Count; intRow++)
                {
                    if (pvtDataView[intRow]["PUBLIC_HOLIDAY_DESC"].ToString().Trim() == ""
                        & pvtDataView[intRow]["PUBLIC_HOLIDAY_DATE"] == System.DBNull.Value)
                    {
                        continue;
                    }

                    TempDataSet.Tables[0].ImportRow(pvtDataView[intRow].Row);
                }

                if (TempDataSet.Tables[0].Rows.Count > 0)
                {
                    Int64 Int64CompanyNo = 999999;

                    if (this.btnAll.Text == "All")
                    {
                        Int64CompanyNo = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                    }

                    byte[] bytCompress = clsISUtilities.Compress_DataSet(TempDataSet);

                    object[] objParm = new object[3];
                    objParm[0] = Int64CompanyNo;
                    objParm[1] = bytCompress;
                    objParm[2] = AppDomain.CurrentDomain.GetData("FromProgramInd").ToString();

                    bytCompress = (byte[])clsISUtilities.DynamicFunction("Update_Records", objParm, true);

                    pvtDataSet = null;
                    pvtDataSet = clsISUtilities.DeCompress_Array_To_DataSet(bytCompress);
                }

                btnCancel_Click(sender, e);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
Esempio n. 8
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            try
            {
                string strPayCategoryFilterWages          = " AND PAY_CATEGORY_NO IN (";
                string strPayCategoryFilterSalaries       = " AND PAY_CATEGORY_NO IN (";
                string strPayCategoryFilterTimeAttendance = " AND PAY_CATEGORY_NO IN (";

                string   strCostCentresWages          = "";
                string   strCostCentresSalaries       = "";
                string   strCostCentresTimeAttendance = "";
                object[] objFind = new object[3];

                object[] objParm;

                if (this.dgvCostCentreChosenDataGridView.Rows.Count == 0)
                {
                    //Test
                    DialogResult myDialogResult = InteractPayroll.CustomMessageBox.Show("Would you like to DELETE this Company From the Local Database?",
                                                                                        this.Text,
                                                                                        MessageBoxButtons.YesNo,
                                                                                        MessageBoxIcon.Question);

                    if (myDialogResult == DialogResult.Yes)
                    {
                        objParm    = new object[2];
                        objParm[0] = pvtint64CompanyNo;
                        objParm[1] = "B";

                        pvtblnLocalWebService = true;
                        clsISClientUtilities.DynamicFunction("Delete_All_PayCategory_Records_New", objParm, false);

                        //Test
                        InteractPayroll.CustomMessageBox.Show("Delete from Local Database Successful.",
                                                              this.Text,
                                                              MessageBoxButtons.OK,
                                                              MessageBoxIcon.Information);

                        this.Set_DataGridView_SelectedRowIndex(this.dgvCompanyDataGridView, Get_DataGridView_SelectedRowIndex(this.dgvCompanyDataGridView));
                    }

                    return;
                }
                else
                {
                    for (int intRow = 0; intRow < this.dgvCostCentreChosenDataGridView.Rows.Count; intRow++)
                    {
                        if (dgvCostCentreChosenDataGridView[2, intRow].Value.ToString().Substring(0, 1) == "W")
                        {
                            if (strCostCentresWages == "")
                            {
                                strCostCentresWages        = this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                strPayCategoryFilterWages += this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                            }
                            else
                            {
                                strCostCentresWages       += "|" + this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                strPayCategoryFilterWages += "," + this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                            }
                        }
                        else
                        {
                            if (dgvCostCentreChosenDataGridView[2, intRow].Value.ToString().Substring(0, 1) == "S")
                            {
                                if (strCostCentresSalaries == "")
                                {
                                    strCostCentresSalaries        = this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                    strPayCategoryFilterSalaries += this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                }
                                else
                                {
                                    strCostCentresSalaries       += "|" + this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                    strPayCategoryFilterSalaries += "," + this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                }
                            }
                            else
                            {
                                if (strCostCentresTimeAttendance == "")
                                {
                                    strCostCentresTimeAttendance        = this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                    strPayCategoryFilterTimeAttendance += this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                }
                                else
                                {
                                    strCostCentresTimeAttendance       += "|" + this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                    strPayCategoryFilterTimeAttendance += "," + this.dgvCostCentreChosenDataGridView[3, intRow].Value.ToString();
                                }
                            }
                        }
                    }
                }

                if (strPayCategoryFilterWages != " AND PAY_CATEGORY_NO IN (")
                {
                    strPayCategoryFilterWages += ")";
                }
                else
                {
                    strPayCategoryFilterWages += "-1)";
                }

                if (strPayCategoryFilterSalaries != " AND PAY_CATEGORY_NO IN (")
                {
                    strPayCategoryFilterSalaries += ")";
                }
                else
                {
                    strPayCategoryFilterSalaries += "-1)";
                }

                if (strPayCategoryFilterTimeAttendance != " AND PAY_CATEGORY_NO IN (")
                {
                    strPayCategoryFilterTimeAttendance += ")";
                }
                else
                {
                    strPayCategoryFilterTimeAttendance += "-1)";
                }

                objParm    = new object[4];
                objParm[0] = pvtint64CompanyNo;
                objParm[1] = strPayCategoryFilterWages;
                objParm[2] = strPayCategoryFilterSalaries;
                objParm[3] = strPayCategoryFilterTimeAttendance;

                pvtblnLocalWebService = true;
                byte[] bytClientDataSetCompress = (byte[])clsISClientUtilities.DynamicFunction("Check_PayCategory_Records_New", objParm, false);

                DataSet DataSetClient = clsISUtilities.DeCompress_Array_To_DataSet(bytClientDataSetCompress);

                if (DataSetClient.Tables["Temp"].Rows.Count > 0)
                {
                    string strPayCategoryDesc             = "Cost Centre\n\n";
                    string strPayCategoryNoWages          = "(";
                    string strPayCategoryNoSalaries       = "(";
                    string strPayCategoryNoTimeAttendance = "(";

                    for (int intRow = 0; intRow < DataSetClient.Tables["Temp"].Rows.Count; intRow++)
                    {
                        if (DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_TYPE"].ToString() == "W")
                        {
                            strPayCategoryDesc += DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_DESC"].ToString() + " (Wages)\n";

                            if (strPayCategoryNoWages == "(")
                            {
                                strPayCategoryNoWages += DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_NO"].ToString();
                            }
                            else
                            {
                                strPayCategoryNoWages += "," + DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_NO"].ToString();
                            }
                        }
                        else
                        {
                            if (DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_TYPE"].ToString() == "S")
                            {
                                strPayCategoryDesc += DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_DESC"].ToString() + " (Salaries)\n";

                                if (strPayCategoryNoSalaries == "(")
                                {
                                    strPayCategoryNoSalaries += DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_NO"].ToString();
                                }
                                else
                                {
                                    strPayCategoryNoSalaries += "," + DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_NO"].ToString();
                                }
                            }
                            else
                            {
                                strPayCategoryDesc += DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_DESC"].ToString() + " (Time Attendance)\n";

                                if (strPayCategoryNoTimeAttendance == "(")
                                {
                                    strPayCategoryNoTimeAttendance += DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_NO"].ToString();
                                }
                                else
                                {
                                    strPayCategoryNoTimeAttendance += "," + DataSetClient.Tables["Temp"].Rows[intRow]["PAY_CATEGORY_NO"].ToString();
                                }
                            }
                        }
                    }

                    if (strPayCategoryNoWages != "(")
                    {
                        strPayCategoryNoWages += ")";
                    }
                    else
                    {
                        strPayCategoryNoWages += "-1)";
                    }

                    if (strPayCategoryNoSalaries != "(")
                    {
                        strPayCategoryNoSalaries += ")";
                    }
                    else
                    {
                        strPayCategoryNoSalaries += "-1)";
                    }

                    if (strPayCategoryNoTimeAttendance != "(")
                    {
                        strPayCategoryNoTimeAttendance += ")";
                    }
                    else
                    {
                        strPayCategoryNoTimeAttendance += "-1)";
                    }

                    strPayCategoryDesc += "\nExist on Local Database.\n\nClick Yes to Delete this Cost Centre and also Synchronize Selected Cost Centre.\n\nClick No to Synchronize Selected Cost Centre Only.";

                    if (DataSetClient.Tables["Temp"].Rows.Count > 1)
                    {
                        strPayCategoryDesc = strPayCategoryDesc.Replace("Centre", "Centres");
                        strPayCategoryDesc = strPayCategoryDesc.Replace("this", "these");
                    }
                    else
                    {
                        strPayCategoryDesc = strPayCategoryDesc.Replace("Exist", "Exists");
                    }

                    //Leave As Is
                    DialogResult myDialogResult = MessageBox.Show(strPayCategoryDesc,
                                                                  this.Text,
                                                                  MessageBoxButtons.YesNoCancel,
                                                                  MessageBoxIcon.Warning);

                    if (myDialogResult == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }
                    else
                    {
                        if (myDialogResult == System.Windows.Forms.DialogResult.Yes)
                        {
                            objParm    = new object[5];
                            objParm[0] = pvtint64CompanyNo;
                            objParm[1] = strPayCategoryNoWages;
                            objParm[2] = strPayCategoryNoSalaries;
                            objParm[3] = strPayCategoryNoTimeAttendance;
                            objParm[4] = bytClientDataSetCompress;

                            pvtblnLocalWebService = true;
                            this.clsISClientUtilities.DynamicFunction("Delete_Certain_PayCategory_Records_New", objParm, false);
                        }
                    }
                }
                else
                {
                    //Test
                    DialogResult myDialogResult = InteractPayroll.CustomMessageBox.Show("Would you like to Synchronize the Selected Cost Centre/s?",
                                                                                        this.Text,
                                                                                        MessageBoxButtons.YesNo,
                                                                                        MessageBoxIcon.Question);

                    if (myDialogResult == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }
                }

                //get Records from Internet Database
                objParm    = new object[5];
                objParm[0] = pvtint64CompanyNo;
                objParm[1] = strCostCentresWages;
                objParm[2] = strCostCentresSalaries;
                objParm[3] = strCostCentresTimeAttendance;
                //2017-09-28 (Upload Employee Parameters)
                objParm[4] = bytClientDataSetCompress;

                pvtblnLocalWebService = false;
                pvtbytCompress        = (byte[])clsISUtilities.DynamicFunction("Download_Records_Fix_Parameters", objParm);

                pvtTempDataSet = clsISUtilities.DeCompress_Array_To_DataSet(pvtbytCompress);
                pvtDataSet.Merge(pvtTempDataSet);

                pvtbytCompress = clsISUtilities.Compress_DataSet(pvtDataSet);

                //Insert Records Into Client Database
                objParm    = new object[8];
                objParm[0] = pvtint64CompanyNo;
                objParm[1] = strPayCategoryFilterWages;
                objParm[2] = strPayCategoryFilterSalaries;
                objParm[3] = strPayCategoryFilterTimeAttendance;
                objParm[4] = strCostCentresWages;
                objParm[5] = strCostCentresSalaries;
                objParm[6] = strCostCentresTimeAttendance;
                objParm[7] = pvtbytCompress;

                pvtblnLocalWebService = true;
                pvtbytCompress        = (byte[])this.clsISClientUtilities.DynamicFunction("Download_Records_New", objParm, false);

                pvtTempDataSet = clsISUtilities.DeCompress_Array_To_DataSet(pvtbytCompress);

                if (pvtTempDataSet.Tables["EmployeeFingerPrintTemplateUpload"].Rows.Count > 0 ||
                    pvtTempDataSet.Tables["EmployeeFingerPrintTemplateDelete"].Rows.Count > 0 ||
                    pvtTempDataSet.Tables["UserFingerPrintTemplateUpload"].Rows.Count > 0 ||
                    pvtTempDataSet.Tables["UserFingerPrintTemplateDelete"].Rows.Count > 0 ||
                    pvtTempDataSet.Tables["PayCategoryInteractInd"].Rows.Count > 0)
                {
                    objParm    = new object[2];
                    objParm[0] = pvtint64CompanyNo;
                    objParm[1] = pvtbytCompress;

                    pvtbytCompress = (byte[])clsISUtilities.DynamicFunction("Maintain_Templates", objParm);

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

                    //Update CREATION_DATETIME which comes from Server
                    clsISClientUtilities.DynamicFunction("Maintain_Templates", objParm, false);
                }

                //Test
                InteractPayroll.CustomMessageBox.Show("Synchronization of Databases Successful.",
                                                      this.Text,
                                                      MessageBoxButtons.OK,
                                                      MessageBoxIcon.Information);

                this.Set_DataGridView_SelectedRowIndex(this.dgvCompanyDataGridView, Get_DataGridView_SelectedRowIndex(this.dgvCompanyDataGridView));
            }
            catch (Exception eException)
            {
                if (pvtblnLocalWebService == true)
                {
                    clsISClientUtilities.ErrorHandler(eException);
                }
                else
                {
                    clsISUtilities.ErrorHandler(eException);
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //Tables to Be Moved to Business Layer
                DataSet TempDataSet = new DataSet();

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

                //Check Roster
                for (int intRow = 0; intRow < dgvShiftScheduleDataGridView.Rows.Count; intRow++)
                {
                    if (this.dgvShiftScheduleDataGridView.Rows[intRow].HeaderCell.Style == ErrorDataGridViewCellStyle)
                    {
                        //Set Cell
                        if (dgvShiftScheduleDataGridView[pvtintNamesCol, intRow].Style.BackColor.ToArgb() == Color.White.ToArgb())
                        {
                            MessageBox.Show("Background Color is White.",
                                            this.Text,
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);

                            return;
                        }

                        MessageBox.Show("Error Exists in Roster.",
                                        this.Text,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);

                        return;
                    }
                    else
                    {
                        if (dgvShiftScheduleDataGridView[this.pvtintFromHHMMCol, intRow].Value.ToString().Trim() != "")
                        {
                            DataRow myDataRow = myDataTable.NewRow();

                            myDataRow["COMPANY_NO"]        = Convert.ToInt32(AppDomain.CurrentDomain.GetData("CompanyNo"));
                            myDataRow["EMPLOYEE_NO"]       = dgvShiftScheduleDataGridView[this.pvtintEmployeeNoCol, intRow].Value.ToString();
                            myDataRow["PAY_CATEGORY_NO"]   = pvtintPayCategoryNo;
                            myDataRow["PAY_CATEGORY_TYPE"] = pvtstrPayrollType;
                            myDataRow["PAY_CATEGORY_SHIFT_SCHEDULE_NO"] = pvtintPayCategoryShiftScheduleNo;
                            myDataRow["SHIFT_SCHEDULE_DATETIME"]        = dgvShiftScheduleDataGridView[this.pvtintDateYYYYMMDDCol, intRow].Value.ToString();
                            myDataRow["FROM_HHMM"] = dgvShiftScheduleDataGridView[this.pvtintFromHHMMCol, intRow].Value.ToString();
                            myDataRow["TO_HHMM"]   = dgvShiftScheduleDataGridView[this.pvtintToHHMMCol, intRow].Value.ToString();

                            myDataTable.Rows.Add(myDataRow);
                        }
                    }
                }

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

                TempDataSet.Tables.Add(myDataTable);

                //Compress DataSet
                pvtbytCompress = clsISUtilities.Compress_DataSet(TempDataSet);

                object[] objParm = new object[4];
                objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                objParm[2] = pvtbytCompress;
                objParm[3] = this.dgvPayrollTypeDataGridView[0, this.Get_DataGridView_SelectedRowIndex(dgvPayrollTypeDataGridView)].Value.ToString().Substring(0, 1);

                pvtbytCompress = (byte[])clsISUtilities.DynamicFunction("Update_Record", objParm, true);

                TempDataSet = clsISUtilities.DeCompress_Array_To_DataSet(pvtbytCompress);
                pvtDataSet.Merge(TempDataSet);

                this.pvtDataSet.AcceptChanges();

                Load_PayCategory_SpreadSheet();
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                foreach (TreeNode ndeLevel1 in this.tvwCompany.Nodes)
                {
                    if (ndeLevel1.GetNodeCount(true) > 0)
                    {
                        foreach (TreeNode ndeLevel2 in ndeLevel1.Nodes)
                        {
                            if (ndeLevel2.GetNodeCount(true) == 0)
                            {
                                pvtintFindRow = pvtUserMenuDataView.Find(ndeLevel2.Tag.ToString());

                                if (ndeLevel2.ImageIndex == 1)
                                {
                                    if (pvtintFindRow == -1)
                                    {
                                        pvtDataRowView = pvtUserMenuDataView.AddNew();

                                        pvtDataRowView.BeginEdit();

                                        pvtDataRowView["COMPANY_NO"]   = pvtint64CompanyNo;
                                        pvtDataRowView["USER_NO"]      = pvtint64UserNo;
                                        pvtDataRowView["MENU_ITEM_ID"] = ndeLevel2.Tag.ToString();

                                        pvtDataRowView["ACCESS_IND"] = "A";

                                        pvtDataRowView.EndEdit();
                                    }
                                }
                                else
                                {
                                    if (pvtintFindRow > -1)
                                    {
                                        pvtUserMenuDataView[pvtintFindRow].Delete();
                                    }
                                }
                            }
                            else
                            {
                                foreach (TreeNode ndeLevel3 in ndeLevel2.Nodes)
                                {
                                    if (ndeLevel3.GetNodeCount(true) == 0)
                                    {
                                        pvtintFindRow = pvtUserMenuDataView.Find(ndeLevel3.Tag.ToString());

                                        if (ndeLevel3.ImageIndex == 1)
                                        {
                                            if (pvtintFindRow == -1)
                                            {
                                                pvtDataRowView = pvtUserMenuDataView.AddNew();

                                                pvtDataRowView.BeginEdit();

                                                pvtDataRowView["COMPANY_NO"]   = pvtint64CompanyNo;
                                                pvtDataRowView["USER_NO"]      = pvtint64UserNo;
                                                pvtDataRowView["MENU_ITEM_ID"] = ndeLevel3.Tag.ToString();

                                                pvtDataRowView["ACCESS_IND"] = "A";

                                                pvtDataRowView.EndEdit();
                                            }
                                        }
                                        else
                                        {
                                            if (pvtintFindRow > -1)
                                            {
                                                pvtUserMenuDataView[pvtintFindRow].Delete();
                                            }
                                        }
                                    }
                                    else
                                    {
                                        foreach (TreeNode ndeLevel4 in ndeLevel3.Nodes)
                                        {
                                            if (ndeLevel4.GetNodeCount(true) == 0)
                                            {
                                                if (ndeLevel4.ImageIndex == 1)
                                                {
                                                    pvtintFindRow = pvtUserMenuDataView.Find(ndeLevel4.Tag.ToString());

                                                    if (pvtintFindRow == -1)
                                                    {
                                                        pvtDataRowView = pvtUserMenuDataView.AddNew();

                                                        pvtDataRowView.BeginEdit();

                                                        pvtDataRowView["COMPANY_NO"]   = pvtint64CompanyNo;
                                                        pvtDataRowView["USER_NO"]      = pvtint64UserNo;
                                                        pvtDataRowView["MENU_ITEM_ID"] = ndeLevel4.Tag.ToString();

                                                        pvtDataRowView["ACCESS_IND"] = "A";

                                                        pvtDataRowView.EndEdit();
                                                    }
                                                }
                                                else
                                                {
                                                    if (pvtintFindRow > -1)
                                                    {
                                                        pvtUserMenuDataView[pvtintFindRow].Delete();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                pvtTempDataSet = null;
                pvtTempDataSet = new DataSet();

                DataTable myDataTable = this.pvtDataSet.Tables["UserMenu"].Clone();
                pvtTempDataSet.Tables.Add(myDataTable);

                for (int intRow = 0; intRow < this.pvtUserMenuDataView.Count; intRow++)
                {
                    if (this.pvtUserMenuDataView[intRow].Row.RowState == DataRowState.Added
                        | this.pvtUserMenuDataView[intRow].Row.RowState == DataRowState.Deleted
                        | this.pvtUserMenuDataView[intRow].Row.RowState == DataRowState.Modified)
                    {
                        pvtTempDataSet.Tables["UserMenu"].ImportRow(this.pvtUserMenuDataView[intRow].Row);
                    }
                }

                //Compress DataSet
                pvtbytCompress = clsISUtilities.Compress_DataSet(pvtTempDataSet);

                if (pvtTempDataSet.Tables["UserMenu"].Rows.Count > 0)
                {
                    object[] objParm = new object[3];

                    objParm[0] = AppDomain.CurrentDomain.GetData("FromProgramInd").ToString();
                    objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                    objParm[2] = pvtbytCompress;

                    pvtbytCompress = (byte[])clsISUtilities.DynamicFunction("Update_User_Menus", objParm, true);

                    pvtUserMenuDataView = null;
                    pvtUserMenuDataView = new DataView(pvtDataSet.Tables["UserMenu"],
                                                       "USER_NO = " + pvtint64UserNo,
                                                       "MENU_ITEM_ID",
                                                       DataViewRowState.CurrentRows | DataViewRowState.Deleted);

                    for (int intRow = 0; intRow < this.pvtUserMenuDataView.Count; intRow++)
                    {
                        this.pvtUserMenuDataView[intRow].Delete();
                    }

                    pvtTempDataSet = clsISUtilities.DeCompress_Array_To_DataSet(pvtbytCompress);
                    pvtDataSet.Merge(pvtTempDataSet);

                    pvtDataSet.AcceptChanges();
                }

                btnCancel_Click(sender, e);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                int intReturnCode = clsISUtilities.DataBind_Save_Check();

                if (intReturnCode != 0)
                {
                    return;
                }

                if (Convert.ToDouble(this.txtRate1.Text) > Convert.ToDouble(this.txtRate2.Text)
                    & Convert.ToDouble(this.txtRate2.Text) != 0)
                {
                    CustomMessageBox.Show("Overtime Rate 1 cannot be Greater than Overtime Rate 2",
                                          this.Text,
                                          MessageBoxButtons.OK,
                                          MessageBoxIcon.Exclamation);

                    this.txtRate1.Focus();
                    return;
                }

                if (Convert.ToDouble(this.txtRate2.Text) > Convert.ToDouble(this.txtRate3.Text)
                    & Convert.ToDouble(this.txtRate3.Text) != 0)
                {
                    CustomMessageBox.Show("Overtime Rate 2 cannot be Greater than Overtime Rate 3",
                                          this.Text,
                                          MessageBoxButtons.OK,
                                          MessageBoxIcon.Exclamation);

                    this.txtRate2.Focus();
                    return;
                }

                if (Convert.ToDouble(this.txtSalaryRate1.Text) > Convert.ToDouble(this.txtSalaryRate2.Text)
                    & Convert.ToDouble(this.txtSalaryRate2.Text) != 0)
                {
                    CustomMessageBox.Show("Overtime Rate 1 cannot be Greater than Overtime Rate 2",
                                          this.Text,
                                          MessageBoxButtons.OK,
                                          MessageBoxIcon.Exclamation);

                    this.txtSalaryRate1.Focus();
                    return;
                }

                if (Convert.ToDouble(this.txtSalaryRate2.Text) > Convert.ToDouble(this.txtSalaryRate3.Text)
                    & Convert.ToDouble(this.txtSalaryRate3.Text) != 0)
                {
                    CustomMessageBox.Show("Overtime Rate 2 cannot be Greater than Overtime Rate 3",
                                          this.Text,
                                          MessageBoxButtons.OK,
                                          MessageBoxIcon.Exclamation);

                    this.txtSalaryRate2.Focus();
                    return;
                }

                pvtTempDataSet = null;
                pvtTempDataSet = new DataSet();

                pvtTempDataSet.Tables.Add(this.pvtDataSet.Tables["Company"].Clone());
                pvtTempDataSet.Tables["Company"].ImportRow(this.pvtCompanyDataView[clsISUtilities.DataViewIndex].Row);

                pvtTempDataSet.Tables.Add(this.pvtDataSet.Tables["EfilingPeriod"].Clone());

                //Compress DataSet
                pvtbytCompress = clsISUtilities.Compress_DataSet(pvtTempDataSet);

                if (this.Text.EndsWith(" - New") == true)
                {
                    object[] objParm = new object[3];
                    objParm[0] = AppDomain.CurrentDomain.GetData("AccessInd").ToString();
                    objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                    objParm[2] = this.pvtbytCompress;

                    pvtint64CompanyNo = (Int64)clsISUtilities.DynamicFunction("Insert_New_Record", objParm, true);

                    AppDomain.CurrentDomain.SetData("LastCompanyNo", pvtint64CompanyNo);

                    //Get Main DataSet
                    DataSet TempDataSet = (DataSet)AppDomain.CurrentDomain.GetData("DataSet");

                    DataRow dtDataRow = TempDataSet.Tables["Company"].NewRow();

                    dtDataRow["COMPANY_NO"]   = pvtint64CompanyNo;
                    dtDataRow["COMPANY_DESC"] = this.txtCompany.Text;

                    if (rbnYYYY.Checked == true)
                    {
                        dtDataRow["DATE_FORMAT"] = "yyyy-MM-dd";
                    }
                    else
                    {
                        dtDataRow["DATE_FORMAT"] = "dd-MM-yyyy";
                    }

                    dtDataRow["COMPANY_ACCESS_IND"] = "A";

                    TempDataSet.Tables["Company"].Rows.Add(dtDataRow);

                    TempDataSet.AcceptChanges();

                    //Fire Off Load Of Companies ComboBox on PayrollMain Form
                    Timer tmrTimerReloadCompanies = (Timer)AppDomain.CurrentDomain.GetData("TimerReloadCompanies");
                    tmrTimerReloadCompanies.Enabled = true;

                    pvtCompanyDataView[clsISUtilities.DataViewIndex]["COMPANY_NO"] = pvtint64CompanyNo;
                }
                else
                {
                    object[] objParm = new object[3];
                    objParm[0] = pvtint64CompanyNo;
                    objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                    objParm[2] = this.pvtbytCompress;

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

                    //Get Main DataSet
                    DataSet TempDataSet = (DataSet)AppDomain.CurrentDomain.GetData("DataSet");

                    for (int intRow = 0; intRow < TempDataSet.Tables["Company"].Rows.Count; intRow++)
                    {
                        if (Convert.ToInt64(TempDataSet.Tables["Company"].Rows[intRow]["COMPANY_NO"]) == pvtint64CompanyNo)
                        {
                            if (rbnYYYY.Checked == true)
                            {
                                TempDataSet.Tables["Company"].Rows[intRow]["DATE_FORMAT"] = "yyyy-MM-dd";
                            }
                            else
                            {
                                TempDataSet.Tables["Company"].Rows[intRow]["DATE_FORMAT"] = "dd-MM-yyyy";
                            }

                            break;
                        }
                    }
                }

                //Current Company Selected Globally
                if (Convert.ToInt32(AppDomain.CurrentDomain.GetData("CompanyNo")) == pvtint64CompanyNo)
                {
                    if (rbnYYYY.Checked == true)
                    {
                        AppDomain.CurrentDomain.SetData("DateFormat", "yyyy-MM-dd");
                    }
                    else
                    {
                        AppDomain.CurrentDomain.SetData("DateFormat", "dd-MM-yyyy");
                    }
                }

                this.pvtDataSet.AcceptChanges();

                btnCancel_Click(sender, e);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int     intIndex       = 0;
                string  strType        = "P";
                string  strEmployeeNos = "";
                DataSet DataSet        = new System.Data.DataSet();
                DataSet.Tables.Add(pvtDataSet.Tables["Employee"].Clone());

                if (rbnPercent.Checked == true)
                {
                    if (this.txtIncrease.Text.Trim().Replace(".", "") == "")
                    {
                        this.txtIncrease.Text = "";

                        CustomMessageBox.Show("Enter Percent Increase / Decrease Value.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.txtIncrease.Focus();
                        return;
                    }
                    else
                    {
                        if (Convert.ToDouble(this.txtIncrease.Text.Trim()) == 0)
                        {
                            CustomMessageBox.Show("Percent Increase / Decrease Value Cannot be Zero.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.txtIncrease.Focus();
                            return;
                        }
                    }

                    if (dgvEmployeeSelectedDataGridView.Rows.Count == 0)
                    {
                        CustomMessageBox.Show("You need to Select at least 1 Employee.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.btnAdd.Focus();
                        return;
                    }

                    for (int intRow = 0; intRow < this.dgvEmployeeSelectedDataGridView.Rows.Count; intRow++)
                    {
                        intIndex = Convert.ToInt32(this.dgvEmployeeSelectedDataGridView[6, intRow].Value);

                        DataSet.Tables["Employee"].ImportRow(pvtEmployeeDataView[intIndex].Row);

                        if (intRow == 0)
                        {
                            strEmployeeNos = pvtEmployeeDataView[intIndex]["EMPLOYEE_NO"].ToString();
                        }
                        else
                        {
                            strEmployeeNos += "," + pvtEmployeeDataView[intIndex]["EMPLOYEE_NO"].ToString();
                        }
                    }
                }
                else
                {
                    strType = "A";

                    for (int intRow = 0; intRow < this.dgvEmployeeDataGridView.Rows.Count; intRow++)
                    {
                        if (this.dgvEmployeeDataGridView[3, intRow].Value != null)
                        {
                            if (this.dgvEmployeeDataGridView[3, intRow].Value.ToString() != "")
                            {
                                intIndex = Convert.ToInt32(this.dgvEmployeeDataGridView[6, intRow].Value);

                                pvtEmployeeDataView[intIndex]["HOURLY_RATE"]          = Convert.ToDouble(this.dgvEmployeeDataGridView[3, intRow].Value);
                                pvtEmployeeDataView[intIndex]["SALARY_WAGE_INCREASE"] = Convert.ToDouble(this.dgvEmployeeDataGridView[4, intRow].Value);

                                DataSet.Tables["Employee"].ImportRow(pvtEmployeeDataView[intIndex].Row);

                                if (intRow == 0)
                                {
                                    strEmployeeNos = pvtEmployeeDataView[intIndex]["EMPLOYEE_NO"].ToString();
                                }
                                else
                                {
                                    strEmployeeNos += "," + pvtEmployeeDataView[intIndex]["EMPLOYEE_NO"].ToString();
                                }
                            }
                        }
                    }

                    if (strEmployeeNos == "")
                    {
                        CustomMessageBox.Show("Enter at least 1 Value into the 'New' Column in the 'List of Employees' Spreadsheet.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.dgvEmployeeDataGridView.Focus();
                        return;
                    }

                    this.txtIncrease.Text = "0";
                }

                pvtEmployeeDataView.RowFilter = pvtEmployeeDataView.RowFilter + " AND EMPLOYEE_NO IN (" + strEmployeeNos + ")";

                //Compress DataSet
                byte[] bytCompress = clsISUtilities.Compress_DataSet(DataSet);

                object[] objParm = new object[8];

                objParm[0] = parInt64CompanyNo;
                objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                objParm[2] = AppDomain.CurrentDomain.GetData("AccessInd").ToString();
                objParm[3] = pvtintPayCategoryNo;
                objParm[4] = this.pvtstrPayrollType;
                objParm[5] = strType;
                objParm[6] = Convert.ToDouble(this.txtIncrease.Text);
                objParm[7] = bytCompress;

                bytCompress = (byte[])clsISUtilities.DynamicFunction("Update_Records", objParm, true);

                DataSet = clsISUtilities.DeCompress_Array_To_DataSet(bytCompress);

                //Remove Rows from DataTable
                for (int intRow = 0; intRow < pvtEmployeeDataView.Count; intRow++)
                {
                    pvtEmployeeDataView[intRow].Delete();

                    intRow -= 1;
                }

                pvtDataSet.AcceptChanges();

                pvtDataSet.Merge(DataSet);

                btnCancel_Click(sender, e);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            try
            {
                DialogResult dlgResult = InteractPayroll.CustomMessageBox.Show("Are you sure you want to Upload this Data?",
                                                                               this.Text,
                                                                               MessageBoxButtons.YesNo,
                                                                               MessageBoxIcon.Question);

                if (dlgResult == DialogResult.Yes)
                {
                    string strPayCategoryWhere = "";

                    int pvtPayCategoryDataViewIndex = -1;

                    for (int intRow = 0; intRow < this.dgvPayCategoryDataGridView.Rows.Count; intRow++)
                    {
                        if (intRow == 0)
                        {
                            strPayCategoryWhere = " AND EPC.PAY_CATEGORY_NO IN (" + this.dgvPayCategoryDataGridView[4, intRow].Value.ToString();

                            pvtPayCategoryDataViewIndex = Convert.ToInt32(this.dgvPayCategoryDataGridView[8, intRow].Value);
                        }
                        else
                        {
                            strPayCategoryWhere += "," + this.dgvPayCategoryDataGridView[4, intRow].Value.ToString();
                        }
                    }

                    strPayCategoryWhere += ")";

                    pvtTempDataSet = null;
                    pvtTempDataSet = new DataSet();

                    DataTable myEmployeeDataTable;
                    myEmployeeDataTable = pvtDataSet.Tables["Employee"].Copy();
                    pvtTempDataSet.Tables.Add(myEmployeeDataTable);

                    DataTable myEmployeePayCategoryDataTable;
                    myEmployeePayCategoryDataTable = pvtDataSet.Tables["EmployeePayCategory"].Copy();
                    pvtTempDataSet.Tables.Add(myEmployeePayCategoryDataTable);

                    //Compress DataSet
                    pvtbytCompress = clsISUtilities.Compress_DataSet(pvtTempDataSet);

                    object[] objParm = new object[5];
                    objParm[0] = pvtint64CompanyNo;
                    objParm[1] = pvtstrPayrollType;
                    objParm[2] = strPayCategoryWhere;
                    objParm[3] = Convert.ToDateTime(this.pvtPayCategoryDataView[pvtPayCategoryDataViewIndex]["TIMESHEET_UPLOAD_DATETIME"]).ToString("yyyy-MM-dd");
                    objParm[4] = pvtbytCompress;

                    pvtblnLocalWebService = true;
                    pvtbytCompress        = (byte[])this.clsISClientUtilities.DynamicFunction("Get_Upload_Data", objParm, false);

                    DataSet DataSetClient = clsISClientUtilities.DeCompress_Array_To_DataSet(pvtbytCompress);

                    if (DataSetClient.Tables["ErrorCount"].Rows.Count > 0)
                    {
                        if (DataSetClient.Tables["ErrorCount"].Rows[0]["INDICATOR"].ToString() == "X")
                        {
                            //Test
                            InteractPayroll.CustomMessageBox.Show("There are Time Sheets with Errors on the Client Database.\n\nYou Need to Fix these TimeSheets on (Validite Client Program) to Proceed.\n\nProcess Cancelled.",
                                                                  this.Text,
                                                                  MessageBoxButtons.OK,
                                                                  MessageBoxIcon.Error);

                            return;
                        }
                    }

                    if (DataSetClient.Tables["Dates"].Rows.Count > 0)
                    {
                        this.grbUploadProgress.Visible = true;
                        this.pgbProgressBar.Maximum    = DataSetClient.Tables["Dates"].Rows.Count + 1;

                        for (int intRow = 0; intRow < DataSetClient.Tables["Dates"].Rows.Count; intRow++)
                        {
                            //From Clint Database
                            objParm    = new object[4];
                            objParm[0] = pvtint64CompanyNo;
                            objParm[1] = pvtstrPayrollType;
                            objParm[2] = strPayCategoryWhere;
                            objParm[3] = Convert.ToDateTime(DataSetClient.Tables["Dates"].Rows[intRow]["TIMESHEET_DATE"]).ToString("yyyy-MM-dd");

                            pvtblnLocalWebService = true;
                            pvtbytCompress        = (byte[])this.clsISClientUtilities.DynamicFunction("Get_Upload_Data_For_Day", objParm, false);

                            //Internet Database Insert
                            objParm    = new object[6];
                            objParm[0] = pvtint64CompanyNo;
                            objParm[1] = Convert.ToDateTime(DataSetClient.Tables["Dates"].Rows[intRow]["TIMESHEET_DATE"]);
                            objParm[2] = pvtbytCompress;
                            objParm[3] = pvtstrPayrollType;
                            objParm[4] = Convert.ToDateTime(this.pvtPayCategoryDataView[pvtPayCategoryDataViewIndex]["PAY_PERIOD_DATE"]).ToString("yyyy-MM-dd");
                            objParm[5] = Convert.ToDateTime(this.pvtPayCategoryDataView[pvtPayCategoryDataViewIndex]["TIMESHEET_UPLOAD_DATETIME"]).ToString("yyyy-MM-dd");

                            pvtblnLocalWebService = false;
                            string strUploadDateTime = (string)clsISUtilities.DynamicFunction("Insert_TimeSheet_Records", objParm);

                            //Update Client PAYCATEGORY Records with Date TimeStamp
                            objParm    = new object[3];
                            objParm[0] = pvtint64CompanyNo;
                            objParm[1] = strUploadDateTime;
                            objParm[2] = pvtbytCompress;

                            pvtblnLocalWebService = true;
                            this.clsISClientUtilities.DynamicFunction("Update_PayCategory_Last_Upload_DateTime", objParm, false);

                            this.pgbProgressBar.Value += 1;
                        }

                        this.Refresh();

                        objParm    = new object[3];
                        objParm[0] = pvtint64CompanyNo;
                        objParm[1] = pvtstrPayrollType;
                        objParm[2] = strPayCategoryWhere;

                        this.clsISClientUtilities.DynamicFunction("Move_Data_To_History_And_Cleanup", objParm, false);

                        this.pgbProgressBar.Value += 1;
                        this.Refresh();

                        InteractPayroll.CustomMessageBox.Show("Upload Successful.",
                                                              this.Text,
                                                              MessageBoxButtons.OK,
                                                              MessageBoxIcon.Information);
                    }
                    else
                    {
                        InteractPayroll.CustomMessageBox.Show("There is NO Data to Upload",
                                                              this.Text,
                                                              MessageBoxButtons.OK,
                                                              MessageBoxIcon.Information);
                    }

                    this.Close();
                }
            }
            catch (Exception eException)
            {
                if (pvtblnLocalWebService == true)
                {
                    clsISClientUtilities.ErrorHandler(eException);
                }
                else
                {
                    clsISUtilities.ErrorHandler(eException);
                }
            }
        }
Esempio n. 14
0
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                int intReturnCode = clsISUtilities.DataBind_Save_Check();

                if (intReturnCode != 0)
                {
                    return;
                }

                DataSet TempDataSet = new DataSet();

                TempDataSet.Tables.Add(this.pvtDataSet.Tables["LeaveType"].Clone());
                TempDataSet.Tables["LeaveType"].ImportRow(this.pvtLeaveTypeDataView[clsISUtilities.DataViewIndex].Row);

                //Compress DataSet
                byte[] bytCompress = clsISUtilities.Compress_DataSet(TempDataSet);

                if (this.Text.EndsWith(" - New") == true)
                {
                    object[] objParm = new object[3];
                    objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                    objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                    objParm[2] = bytCompress;

                    pvtintLeaveTypeNo = (int)clsISUtilities.DynamicFunction("Insert_New_Record", objParm, true);

                    pvtLeaveTypeDataView[clsISUtilities.DataViewIndex]["EARNING_NO"] = pvtintLeaveTypeNo;
                }
                else
                {
                    object[] objParm = new object[3];
                    objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                    objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                    objParm[2] = bytCompress;

                    intReturnCode = (int)clsISUtilities.DynamicFunction("Update_Record", objParm, true);

                    if (intReturnCode == 9999)
                    {
                        this.pvtDataSet.RejectChanges();

                        pvtLeaveTypeDataView[this.clsISUtilities.DataViewIndex]["PAYROLL_LINK"] = 0;

                        this.dgvLeaveTypeDataGridView[0, this.Get_DataGridView_SelectedRowIndex(dgvLeaveTypeDataGridView)].Style = this.PayrollLinkDataGridViewCellStyle;

                        CustomMessageBox.Show("This Leave Type is currently being used in a Payroll Run.\r\n\r\nUpdate Cancelled.",
                                              this.Text,
                                              MessageBoxButtons.OK,
                                              MessageBoxIcon.Warning);
                    }
                    else
                    {
                        this.dgvLeaveTypeDataGridView[1, this.Get_DataGridView_SelectedRowIndex(dgvLeaveTypeDataGridView)].Value = this.txtLeaveType.Text.Trim();
                    }
                }

                this.pvtDataSet.AcceptChanges();

                if (this.clsISUtilities.pubintReloadSpreadsheet == true)
                {
                    Load_CurrentForm_Records();
                }
                else
                {
                    btnCancel_Click(sender, e);
                }
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
Esempio n. 15
0
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                pvtintReturnCode = clsISUtilities.DataBind_Save_Check();

                if (pvtintReturnCode != 0)
                {
                    return;
                }

                pvtintReturnCode = Save_Check();

                if (pvtintReturnCode != 0)
                {
                    return;
                }

                pvtTempDataSet = null;
                pvtTempDataSet = new DataSet();

                pvtTempDataSet.Tables.Add(this.pvtDataSet.Tables["Deduction"].Clone());

                pvtTempDataSet.Tables["Deduction"].ImportRow(pvtDeductionDataView[clsISUtilities.DataViewIndex].Row);

                pvtTempDataSet.Tables.Add(this.pvtDataSet.Tables["EarningPercentage"].Clone());

                pvtEarningPercentageDataView = null;
                pvtEarningPercentageDataView = new DataView(pvtDataSet.Tables["EarningPercentage"],
                                                            "COMPANY_NO = " + AppDomain.CurrentDomain.GetData("CompanyNo").ToString() + " AND PAY_CATEGORY_TYPE = '" + pvtstrPayrollType + "' AND DEDUCTION_NO = " + pvtintDeductionNo,
                                                            "",
                                                            DataViewRowState.Added | DataViewRowState.Deleted | DataViewRowState.ModifiedCurrent);

                for (int intRow = 0; intRow < pvtEarningPercentageDataView.Count; intRow++)
                {
                    pvtTempDataSet.Tables["EarningPercentage"].ImportRow(pvtEarningPercentageDataView[intRow].Row);
                }

                //Compress DataSet
                pvtbytCompress = clsISUtilities.Compress_DataSet(pvtTempDataSet);

                if (this.Text.IndexOf(" - New", 0) > 0)
                {
                    object[] objParm = new object[2];
                    objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                    objParm[1] = pvtbytCompress;

                    pvtintDeductionNo = (int)clsISUtilities.DynamicFunction("Insert_New_Record", objParm, true);

                    pvtDeductionDataView[clsISUtilities.DataViewIndex]["DEDUCTION_NO"] = pvtintDeductionNo;
                    pvtDeductionDataView[clsISUtilities.DataViewIndex]["PAYROLL_LINK"] = System.DBNull.Value;

                    //2017-02-24 Create opposite PAY_CATEGORY_TYPE
                    DataRowView DataRowView = pvtDeductionDataView.AddNew();

                    DataRowView.BeginEdit();

                    DataRowView["COMPANY_NO"] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));

                    if (pvtDeductionDataView[clsISUtilities.DataViewIndex]["PAY_CATEGORY_TYPE"].ToString() == "W")
                    {
                        DataRowView["PAY_CATEGORY_TYPE"] = "S";
                    }
                    else
                    {
                        DataRowView["PAY_CATEGORY_TYPE"] = "W";
                    }

                    DataRowView["EMPLOYEE_NO"]              = 0;
                    DataRowView["DEDUCTION_NO"]             = Convert.ToInt16(pvtDeductionDataView[clsISUtilities.DataViewIndex]["DEDUCTION_NO"]);
                    DataRowView["DEDUCTION_SUB_ACCOUNT_NO"] = Convert.ToInt16(pvtDeductionDataView[clsISUtilities.DataViewIndex]["DEDUCTION_SUB_ACCOUNT_NO"]);

                    DataRowView["DEDUCTION_DESC"] = pvtDeductionDataView[clsISUtilities.DataViewIndex]["DEDUCTION_DESC"].ToString();

                    DataRowView["DEDUCTION_SUB_ACCOUNT_COUNT"] = Convert.ToInt16(pvtDeductionDataView[clsISUtilities.DataViewIndex]["DEDUCTION_SUB_ACCOUNT_COUNT"]);

                    if (pvtDeductionDataView[clsISUtilities.DataViewIndex]["IRP5_CODE"] != System.DBNull.Value)
                    {
                        DataRowView["IRP5_CODE"] = Convert.ToInt16(pvtDeductionDataView[clsISUtilities.DataViewIndex]["IRP5_CODE"]);
                    }

                    DataRowView["DEDUCTION_REPORT_HEADER1"] = pvtDeductionDataView[clsISUtilities.DataViewIndex]["DEDUCTION_REPORT_HEADER1"].ToString();
                    DataRowView["DEDUCTION_REPORT_HEADER2"] = pvtDeductionDataView[clsISUtilities.DataViewIndex]["DEDUCTION_REPORT_HEADER2"].ToString();
                    DataRowView["DEDUCTION_LOAN_TYPE_IND"]  = pvtDeductionDataView[clsISUtilities.DataViewIndex]["DEDUCTION_LOAN_TYPE_IND"].ToString();

                    DataRowView["DEDUCTION_DEL_IND"] = "Y";

                    DataRowView["DEDUCTION_TYPE_IND"]  = "U";
                    DataRowView["DEDUCTION_VALUE"]     = 0;
                    DataRowView["DEDUCTION_MIN_VALUE"] = 0;
                    DataRowView["DEDUCTION_MAX_VALUE"] = 0;

                    DataRowView["DEDUCTION_PERIOD_IND"] = "E";
                    DataRowView["DEDUCTION_DAY_VALUE"]  = 0;
                    DataRowView["TIE_BREAKER"]          = 1;

                    DataRowView.EndEdit();

                    pvtEarningPercentageDataView = null;
                    pvtEarningPercentageDataView = new DataView(pvtDataSet.Tables["EarningPercentage"],
                                                                "COMPANY_NO = " + AppDomain.CurrentDomain.GetData("CompanyNo").ToString() + " AND PAY_CATEGORY_TYPE = '" + pvtstrPayrollType + "' AND DEDUCTION_NO = 0 ",
                                                                "",
                                                                DataViewRowState.CurrentRows);

                    for (int intRow = 0; intRow < pvtEarningPercentageDataView.Count; intRow++)
                    {
                        pvtEarningPercentageDataView[intRow]["DEDUCTION_NO"] = pvtintDeductionNo;

                        intRow -= 1;
                    }
                }
                else
                {
                    object[] objParm = new object[3];
                    objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                    objParm[1] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                    objParm[2] = pvtbytCompress;

                    pvtintReturnCode = (int)clsISUtilities.DynamicFunction("Update_Record", objParm, true);

                    if (pvtintReturnCode == 9999)
                    {
                        this.pvtDataSet.Tables["Deduction"].RejectChanges();

                        pvtDeductionDataView[clsISUtilities.DataViewIndex]["PAYROLL_LINK"] = 0;

                        this.dgvDeductionDataGridView.Rows[this.Get_DataGridView_SelectedRowIndex(this.dgvDeductionDataGridView)].HeaderCell.Style = LockedPayrollRunDataGridViewCellStyle;

                        CustomMessageBox.Show("This Deduction is currently being used in a Payroll Run.\r\n\r\nUpdate Cancelled.",
                                              this.Text,
                                              MessageBoxButtons.OK,
                                              MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        if (pvtintReturnCode != 0)
                        {
                            CustomMessageBox.Show("Number of Sub-Accounts used = " + pvtintReturnCode.ToString() + "\r\n\r\nYou cannot set a Value of " + this.cboNumberSubAccount.SelectedItem.ToString(),
                                                  this.Text,
                                                  MessageBoxButtons.OK,
                                                  MessageBoxIcon.Exclamation);

                            return;
                        }
                        else
                        {
                            dgvDeductionDataGridView[2, pvtintDeductionDataGridViewRowIndex].Value = this.txtDeduction.Text.Trim();
                        }
                    }
                }


                this.pvtDataSet.AcceptChanges();

                if (this.Text.EndsWith(" - New") == true)
                {
                    Load_CurrentForm_Records();
                }
                else
                {
                    btnCancel_Click(sender, e);
                }
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
Esempio n. 16
0
        private void btnDateClose_Click(object sender, System.EventArgs e)
        {
            try
            {
                DateTime dtWageRunDateTime   = DateTime.Now;
                DateTime dtSalaryRunDateTime = DateTime.Now;

                string strRunDesc = "Payroll";

                if (AppDomain.CurrentDomain.GetData("FromProgramInd").ToString() == "X")
                {
                    strRunDesc = "Time Attendance";
                }

                DialogResult dlgResult = CustomMessageBox.Show("Are you sure you want to Close the " + strRunDesc + " Run?",
                                                               this.Text,
                                                               MessageBoxButtons.YesNo,
                                                               MessageBoxIcon.Question);

                if (dlgResult == DialogResult.Yes)
                {
                    int      intReturnCode                = 0;
                    object[] objParm                      = null;
                    string   strPayrollType               = "";
                    string   strWagesPayCategoryNumber    = "";
                    string   strSalariesPayCategoryNumber = "";

                    this.btnCancel.Enabled    = false;
                    this.btnDateClose.Enabled = false;
                    this.btnAddAll.Enabled    = false;
                    this.btnRemoveAll.Enabled = false;

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

                    for (int intChosenRow = 0; intChosenRow < this.dgvChosenPayCategoryDataGridView.Rows.Count; intChosenRow++)
                    {
                        if (this.dgvChosenPayCategoryDataGridView[1, intChosenRow].Value.ToString() == "S")
                        {
                            dtSalaryRunDateTime = DateTime.ParseExact(this.dgvChosenPayCategoryDataGridView[2, intChosenRow].Value.ToString(), AppDomain.CurrentDomain.GetData("DateFormat").ToString(), null);

                            if (strSalariesPayCategoryNumber == "")
                            {
                                strSalariesPayCategoryNumber = this.dgvChosenPayCategoryDataGridView[4, intChosenRow].Value.ToString();
                            }
                            else
                            {
                                strSalariesPayCategoryNumber += "," + this.dgvChosenPayCategoryDataGridView[4, intChosenRow].Value.ToString();
                            }
                        }
                        else
                        {
                            dtWageRunDateTime = DateTime.ParseExact(this.dgvChosenPayCategoryDataGridView[2, intChosenRow].Value.ToString(), AppDomain.CurrentDomain.GetData("DateFormat").ToString(), null);

                            if (strWagesPayCategoryNumber == "")
                            {
                                strWagesPayCategoryNumber = this.dgvChosenPayCategoryDataGridView[4, intChosenRow].Value.ToString();
                            }
                            else
                            {
                                strWagesPayCategoryNumber += "," + this.dgvChosenPayCategoryDataGridView[4, intChosenRow].Value.ToString();
                            }
                        }
                    }

                    if (strWagesPayCategoryNumber != "" &&
                        strSalariesPayCategoryNumber != "")
                    {
                        strPayrollType = "B";
                    }
                    else
                    {
                        if (strWagesPayCategoryNumber != "")
                        {
                            if (AppDomain.CurrentDomain.GetData("FromProgramInd").ToString() == "X")
                            {
                                strPayrollType = "T";
                            }
                            else
                            {
                                strPayrollType = "W";
                            }
                        }
                        else
                        {
                            strPayrollType = "S";
                        }
                    }

                    pvtintProcess         = 1;
                    this.tmrTimer.Enabled = true;

#if (DEBUG)
                    DateTime waitDateTime = DateTime.Now.AddSeconds(1);
#else
                    DateTime waitDateTime = DateTime.Now.AddSeconds(5);
#endif

                    objParm    = null;
                    objParm    = new object[2];
                    objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                    objParm[1] = strPayrollType;

                    intReturnCode = (int)clsISUtilities.DynamicFunction("Backup_DataBase", objParm);

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

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

                    if (intReturnCode == 0)
                    {
                        this.picBackupBefore.Image = (Image)global::ClosePayrollRun.Properties.Resources.tick48;

                        lblDatabaseBackupBeforeClose.Text = "Backup of Database Successful";

                        this.Refresh();

                        //Compress DataSet
                        pvtbytCompress = clsISUtilities.Compress_DataSet(pvtTempDataSet);

                        objParm = null;
#if (DEBUG)
                        if (strPayrollType == "B")
                        {
                            objParm = new object[6];
                        }
                        else
                        {
                            objParm = new object[4];
                        }

                        objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));

                        if (strPayrollType == "B")
                        {
                            objParm[1] = dtWageRunDateTime;
                            objParm[2] = dtSalaryRunDateTime;
                            objParm[3] = strWagesPayCategoryNumber;
                            objParm[4] = strSalariesPayCategoryNumber;
                            objParm[5] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                        }
                        else
                        {
                            if (strPayrollType == "S")
                            {
                                objParm[1] = dtSalaryRunDateTime;
                                objParm[2] = strSalariesPayCategoryNumber;
                                objParm[3] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                            }
                            else
                            {
                                objParm[1] = dtWageRunDateTime;
                                objParm[2] = strWagesPayCategoryNumber;
                                objParm[3] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                            }
                        }

                        if (strPayrollType == "B")
                        {
                            intReturnCode = (int)clsISUtilities.DynamicFunction("Close_Both_Run", objParm);
                        }
                        else
                        {
                            if (strPayrollType == "W")
                            {
                                intReturnCode = (int)clsISUtilities.DynamicFunction("Close_Wage_Run", objParm);
                            }
                            else
                            {
                                if (strPayrollType == "S")
                                {
                                    intReturnCode = (int)clsISUtilities.DynamicFunction("Close_Salary_Run", objParm);
                                }
                                else
                                {
                                    intReturnCode = (int)clsISUtilities.DynamicFunction("Close_TimeAttendance_Run", objParm);
                                }
                            }
                        }

                        if (intReturnCode == 0)
                        {
                            CustomMessageBox.Show("Close " + strRunDesc + " Run Successful.",
                                                  this.Text,
                                                  MessageBoxButtons.OK,
                                                  MessageBoxIcon.Information);
                        }
                        else
                        {
                            CustomMessageBox.Show("CLOSE " + strRunDesc + " Run UNSUCCESSFUL.\n\nSpeak to your System Administrator.",
                                                  this.Text,
                                                  MessageBoxButtons.OK,
                                                  MessageBoxIcon.Error);
                        }
#else
                        objParm = new object[7];

                        objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                        objParm[1] = dtWageRunDateTime;
                        objParm[2] = dtSalaryRunDateTime;
                        objParm[3] = strPayrollType;
                        objParm[4] = strWagesPayCategoryNumber;
                        objParm[5] = strSalariesPayCategoryNumber;
                        objParm[6] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));

                        intReturnCode = (int)clsISUtilities.DynamicFunction("Insert_Close_Into_Queue", objParm);

                        if (intReturnCode == 0)
                        {
                            pvtstrRunType = strPayrollType;
                            Busy_With_Run();
                        }
                        else
                        {
                            CustomMessageBox.Show("Insert Close Job into Queue FAILED.\n\nSpeak To your System Administrator.",
                                                  this.Text,
                                                  MessageBoxButtons.OK,
                                                  MessageBoxIcon.Error);
                        }
#endif
                    }
                    else
                    {
                        this.picBackupBefore.Image = (Image)global::ClosePayrollRun.Properties.Resources.Cross48;
                        this.Refresh();

                        this.lblDatabaseBackupBeforeClose.Text = "Backup of Database UNSUCCESSFUL";

                        CustomMessageBox.Show("Backup of Database Failed.\n\nSpeak To your System Administrator.",
                                              this.Text,
                                              MessageBoxButtons.OK,
                                              MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet tempDataSet = new DataSet();

                int intLeaveShiftNo = -1;

                //Employee Earnings
                //Employee Earnings
                tempDataSet.Tables.Add(pvtDataSet.Tables["PayCategory"].Clone());

                if (this.dgvChosenPayCategoryDataGridView.Rows.Count == 0)
                {
                    CustomMessageBox.Show("Select at least 1 Cost Centre",
                                          this.Text,
                                          MessageBoxButtons.OK,
                                          MessageBoxIcon.Error);

                    return;
                }
                else
                {
                    bool blnDefault = false;

                    for (int intRow = 0; intRow < dgvChosenPayCategoryDataGridView.Rows.Count; intRow++)
                    {
                        DataRow MyDataRow = tempDataSet.Tables["PayCategory"].NewRow();

                        MyDataRow["PAY_CATEGORY_NO"] = this.dgvChosenPayCategoryDataGridView[3, intRow].Value.ToString();

                        if (Convert.ToBoolean(this.dgvChosenPayCategoryDataGridView[2, intRow].Value) == true)
                        {
                            MyDataRow["DEFAULT_IND"] = "Y";

                            if (blnDefault == false)
                            {
                                blnDefault = true;
                            }
                            else
                            {
                                CustomMessageBox.Show("Only 1 Cost Centre can be set to Default",
                                                      this.Text,
                                                      MessageBoxButtons.OK,
                                                      MessageBoxIcon.Error);

                                return;
                            }
                        }
                        else
                        {
                            MyDataRow["DEFAULT_IND"] = "N";
                        }

                        MyDataRow["REC_RATE"] = this.dgvChosenPayCategoryDataGridView[1, intRow].Value.ToString();

                        tempDataSet.Tables["PayCategory"].Rows.Add(MyDataRow);
                    }

                    if (blnDefault == false)
                    {
                        CustomMessageBox.Show("1 Cost Centre must be set to Default",
                                              this.Text,
                                              MessageBoxButtons.OK,
                                              MessageBoxIcon.Error);

                        return;
                    }
                }

                if (this.dgvLeaveShiftSelectedDataGridView.Rows.Count == 0)
                {
                    CustomMessageBox.Show("Select at least 1 Normal Leave / Sick Leave Category",
                                          this.Text,
                                          MessageBoxButtons.OK,
                                          MessageBoxIcon.Error);

                    return;
                }
                else
                {
                    if (this.dgvLeaveShiftSelectedDataGridView.Rows.Count == 1)
                    {
                        intLeaveShiftNo = Convert.ToInt32(this.dgvLeaveShiftSelectedDataGridView[1, 0].Value);
                    }
                    else
                    {
                        CustomMessageBox.Show("Only 1 Normal Leave / Sick Leave Category Record Allowed.",
                                              this.Text,
                                              MessageBoxButtons.OK,
                                              MessageBoxIcon.Error);

                        return;
                    }
                }

                DataView CurrentPayCategoryDataView = new DataView(pvtDataSet.Tables["CurrentPayCategory"],
                                                                   "EMPLOYEE_NO = " + pvtintEmployeeNo + " AND PAY_CATEGORY_TYPE = '" + pvtstrCurrentPayrollType + "'",
                                                                   "",
                                                                   DataViewRowState.CurrentRows);

                for (int intRow = 0; intRow < CurrentPayCategoryDataView.Count; intRow++)
                {
                    CurrentPayCategoryDataView[intRow].Delete();

                    intRow -= 1;
                }

                DataView EmployeeDataView = new DataView(pvtDataSet.Tables["Employee"],
                                                         "EMPLOYEE_NO = " + pvtintEmployeeNo + " AND PAY_CATEGORY_TYPE = '" + pvtstrCurrentPayrollType + "'",
                                                         "",
                                                         DataViewRowState.CurrentRows);

                for (int intRow = 0; intRow < EmployeeDataView.Count; intRow++)
                {
                    EmployeeDataView[intRow].Delete();

                    intRow -= 1;
                }

                byte[] bytCompress = clsISUtilities.Compress_DataSet(tempDataSet);

                object[] objParm = new object[6];
                objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                objParm[1] = pvtstrPayrollType;
                objParm[2] = pvtstrCurrentPayrollType;
                objParm[3] = pvtintEmployeeNo;
                objParm[4] = intLeaveShiftNo;
                objParm[5] = bytCompress;

                bytCompress = (byte[])clsISUtilities.DynamicFunction("Update_Employee", objParm);

                tempDataSet = clsISUtilities.DeCompress_Array_To_DataSet(bytCompress);
                pvtDataSet.Merge(tempDataSet);

                pvtDataSet.AcceptChanges();

                Load_CurrentForm_Records();

                btnCancel_Click(sender, e);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }
Esempio n. 18
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet TempDataSet = new DataSet();
                TempDataSet.Tables.Add(this.pvtDataSet.Tables["EmployeePayCategoryLevel"].Clone());

                for (int intRow = 0; intRow < this.dgvLeaveDataGridView.Rows.Count; intRow++)
                {
                    DataRow drDataRow = TempDataSet.Tables["EmployeePayCategoryLevel"].NewRow();

                    drDataRow["COMPANY_NO"]        = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                    drDataRow["EMPLOYEE_NO"]       = pvtLeaveDataView[Convert.ToInt32(this.dgvLeaveDataGridView[pvtintColLeaveHoldingIndex, intRow].Value)]["EMPLOYEE_NO"].ToString();
                    drDataRow["PAY_CATEGORY_NO"]   = pvtLeaveDataView[Convert.ToInt32(this.dgvLeaveDataGridView[pvtintColLeaveHoldingIndex, intRow].Value)]["PAY_CATEGORY_NO"].ToString();
                    drDataRow["PAY_CATEGORY_TYPE"] = pvtstrPayrollType;
                    drDataRow["EARNING_NO"]        = pvtLeaveDataView[Convert.ToInt32(this.dgvLeaveDataGridView[pvtintColLeaveHoldingIndex, intRow].Value)]["EARNING_NO"].ToString();
                    drDataRow["LEVEL_NO"]          = pvtintAuthoriseLevel;
                    drDataRow["LEAVE_REC_NO"]      = pvtLeaveDataView[Convert.ToInt32(this.dgvLeaveDataGridView[pvtintColLeaveHoldingIndex, intRow].Value)]["LEAVE_REC_NO"].ToString();

                    if (Convert.ToBoolean(this.dgvLeaveDataGridView[pvtintColAuthorisation, intRow].Value) == true)
                    {
                        drDataRow["AUTHORISED_IND"] = "Y";
                    }
                    else
                    {
                        drDataRow["AUTHORISED_IND"] = "N";
                    }

                    TempDataSet.Tables["EmployeePayCategoryLevel"].Rows.Add(drDataRow);
                }

                //Delete - New Records will be Passed Back for CostCentre
                for (int intRow = 0; intRow < pvtEmployeePayCategoryLevelDataView.Count; intRow++)
                {
                    pvtEmployeePayCategoryLevelDataView[intRow].Delete();

                    intRow -= 1;
                }

                for (int intRow = 0; intRow < pvtAuthorsiseLevelDataView.Count; intRow++)
                {
                    pvtAuthorsiseLevelDataView[intRow].Delete();

                    intRow -= 1;
                }

                //Compress DataSet
                pvtbytCompress = clsISUtilities.Compress_DataSet(TempDataSet);

                object[] objParm = new object[7];
                objParm[0] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("CompanyNo"));
                objParm[1] = pvtstrPayrollType;
                objParm[2] = this.pvtintAuthoriseLevel;
                objParm[3] = Convert.ToInt64(AppDomain.CurrentDomain.GetData("UserNo"));
                objParm[4] = AppDomain.CurrentDomain.GetData("AccessInd").ToString();
                objParm[5] = AppDomain.CurrentDomain.GetData("FromProgramInd").ToString();
                objParm[6] = pvtbytCompress;

                pvtbytCompress = null;
                pvtbytCompress = (byte[])clsISUtilities.DynamicFunction("Update_Record", objParm);

                TempDataSet = clsISUtilities.DeCompress_Array_To_DataSet(pvtbytCompress);
                pvtDataSet.Merge(TempDataSet);

                this.pvtDataSet.AcceptChanges();

                btnCancel_Click(sender, e);
            }
            catch (Exception eException)
            {
                clsISUtilities.ErrorHandler(eException);
            }
        }