protected void Delete_Click(object sender, EventArgs e) { ArrayList list = new ArrayList(); foreach (DataListItem item in Repeater.Items) { CheckBox c = (CheckBox)item.FindControl("DeleteItem"); HtmlInputHidden h = (HtmlInputHidden)item.FindControl("CNDID"); if (c.Checked) { EClaimsAndDeductions obj = new EClaimsAndDeductions(); obj.CNDID = Int32.Parse(h.Value); list.Add(obj); } } WebUtils.StartFunction(Session, FUNCTION_CODE, CurID); foreach (EClaimsAndDeductions obj in list) { if (db.select(dbConn, obj)) { db.delete(dbConn, obj); } } WebUtils.EndFunction(dbConn); loadData(info, db, Repeater); }
protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e) { EClaimsAndDeductions obj = new EClaimsAndDeductions(); db.toObject(((DataRowView)e.Item.DataItem).Row, obj); Hashtable values = new Hashtable(); db.populate(obj, values); { //((Button)e.Item.FindControl("Edit")).Visible = IsAllowEdit; //if (obj.PayRecID != null) //{ // ((Button)e.Item.FindControl("Edit")).Visible = false; // ((CheckBox)e.Item.FindControl("DeleteItem")).Visible = false; //} HtmlInputHidden h = (HtmlInputHidden)e.Item.FindControl("CNDID"); h.Value = obj.CNDID.ToString(); Label CNDAmount = (Label)e.Item.FindControl("CNDAmount"); Label CNDRemark = (Label)e.Item.FindControl("CNDRemark"); Label EmpAccID = (Label)e.Item.FindControl("EmpAccID"); Binding ebinding = new Binding(dbConn, db); ebinding.add(CNDAmount); ebinding.add(CNDRemark); ebinding.add(new BlankZeroLabelVLBinder(EEmpBankAccount.db, EmpAccID, "EmpAccID", EEmpBankAccount.VLBankAccount).setTextDisplayForZero(HROne.Common.WebUtility.GetLocalizedString(EEmpBankAccount.DEFAULT_BANK_ACCOUNT_TEXT))); ebinding.init(Request, Session); ebinding.toControl(values); DBFilter empRankFilter = new DBFilter(); empRankFilter.add(WebUtils.AddRankFilter(Session, "EmpID", true)); empRankFilter.add(new Match("EmpID", obj.EmpID)); if (EEmpPersonalInfo.db.count(dbConn, empRankFilter) > 0) { CNDAmount.Text = obj.CNDAmount.ToString("$#,##0.00"); } else { CNDAmount.Text = "******"; CNDRemark.Text = "******"; if (obj.CNDPayMethod.Equals("A", StringComparison.CurrentCultureIgnoreCase)) { EmpAccID.Text = "******"; } } } }
public override void ImportToDatabase() { DataTable dataTable = GetImportDataFromTempDatabase(null); if (dataTable.Rows.Count > 0) { EClaimsAndDeductionsImportBatch batchDetail = new EClaimsAndDeductionsImportBatch(); batchDetail.CNDImportBatchDateTime = AppUtils.ServerDateTime(); //batchDetail.CNDImportBatchOriginalFilename = OriginalBatchFilename; batchDetail.CNDImportBatchRemark = Remark; batchDetail.CNDImportBatchUploadedBy = m_UserID; EClaimsAndDeductionsImportBatch.db.insert(dbConn, batchDetail); foreach (DataRow row in dataTable.Rows) { EUploadClaimsAndDeductions obj = new EUploadClaimsAndDeductions(); EUploadClaimsAndDeductions.db.toObject(row, obj); EClaimsAndDeductions CND = new EClaimsAndDeductions(); CND.CNDAmount = obj.CNDAmount; CND.CNDEffDate = obj.CNDEffDate; CND.CNDNumOfDayAdj = obj.CNDNumOfDayAdj; CND.CNDPayMethod = obj.CNDPayMethod; CND.CNDRemark = obj.CNDRemark; CND.CurrencyID = obj.CurrencyID; CND.EmpAccID = obj.EmpAccID; CND.EmpID = obj.EmpID; CND.PayCodeID = obj.PayCodeID; CND.CostCenterID = obj.CostCenterID; CND.CNDIsRestDayPayment = obj.CNDIsRestDayPayment; CND.CNDImportBatchID = batchDetail.CNDImportBatchID; EClaimsAndDeductions.db.insert(dbConn, CND); EUploadClaimsAndDeductions.db.delete(dbConn, obj); //DBFilter dbfilter = new DBFilter(); //dbfilter.add(new Match("EmpID", obj.EmpID)); //dbfilter.add(new Match("CNDEffDate", obj.CNDEffDate)); //dbfilter.add(new Match("PayCodeID", obj.PayCodeID)); //dbfilter.add(new Match("CNDPayMethod", obj.CNDPayMethod)); //dbfilter.add(new Match("EmpAccID", obj.EmpAccID)); //dbfilter.add(new Match(" } } }
protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e) { Button b = (Button)e.CommandSource; if (b.ID.Equals("Edit")) { Repeater.EditItemIndex = e.Item.ItemIndex; //CNDAddPanel.Visible = false; loadData(info, db, Repeater); WebUtils.SetEnabledControlSection(CNDAddPanel, false); } else if (b.ID.Equals("Cancel")) { Repeater.EditItemIndex = -1; //CNDAddPanel.Visible = IsAllowEdit; loadData(info, db, Repeater); WebUtils.SetEnabledControlSection(CNDAddPanel, true); } else if (b.ID.Equals("Save")) { Binding ebinding; // Hard code set Currency to HKD ((DropDownList)e.Item.FindControl("CurrencyID")).SelectedValue = "HKD"; ebinding = new Binding(dbConn, db); ebinding.add(EmpID); ebinding.add(new TextBoxBinder(db, ((WebDatePicker)e.Item.FindControl("CNDEffDate")).TextBox, "CNDEffDate")); ebinding.add((HtmlInputHidden)e.Item.FindControl("CNDID")); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("PayCodeID"), EPaymentCode.VLPaymentCode)); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CurrencyID"), Values.VLCurrency)); ebinding.add((TextBox)e.Item.FindControl("CNDAmount")); ebinding.add(new CheckBoxBinder(db, (CheckBox)e.Item.FindControl("CNDIsRestDayPayment"))); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CNDPayMethod"), Values.VLPaymentMethod).setNotSelected(null)); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CostCenterID"), ECostCenter.VLCostCenter).setNotSelected(HROne.Common.WebUtility.GetLocalizedString(ECostCenter.DEFAULT_COST_CENTER_TEXT))); ebinding.add((TextBox)e.Item.FindControl("CNDNumOfDayAdj")); ebinding.add((TextBox)e.Item.FindControl("CNDRemark")); DBFilter empBankAccountFilter = new DBFilter(); OR bankAccountORTerm = new OR(); bankAccountORTerm.add(new Match("EmpID", CurID)); { EEmpPersonalInfo tmpEmpInfo = new EEmpPersonalInfo(); tmpEmpInfo.EmpID = CurID; if (EEmpPersonalInfo.db.select(dbConn, tmpEmpInfo) && tmpEmpInfo.MasterEmpID > 0) { bankAccountORTerm.add(new Match("EmpID", tmpEmpInfo.MasterEmpID)); } } empBankAccountFilter.add(bankAccountORTerm); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("EmpAccID"), EEmpBankAccount.VLBankAccount, empBankAccountFilter).setNotSelected(HROne.Common.WebUtility.GetLocalizedString(EEmpBankAccount.DEFAULT_BANK_ACCOUNT_TEXT))); ebinding.init(Request, Session); EClaimsAndDeductions obj = new EClaimsAndDeductions(); Hashtable values = new Hashtable(); PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); ebinding.toValues(values); db.validate(errors, values); if (!errors.isEmpty()) { HROne.Common.WebUtility.WebControlsLocalization(this, e.Item.Controls); return; } db.parse(values, obj); if (obj.CNDPayMethod.Equals("A")) { if (obj.EmpAccID == 0) { EEmpBankAccount bankAccount = EEmpBankAccount.GetDefaultBankAccount(dbConn, int.Parse(EmpID.Value)); if (bankAccount != null) { //obj.EmpAccID = bankAccount.EmpBankAccountID; } else { errors.addError("EmpAccID", HROne.Translation.PageErrorMessage.ERROR_ACCOUNT_REQUIRED); } } } else { obj.EmpAccID = 0; } if (!errors.isEmpty()) { HROne.Common.WebUtility.WebControlsLocalization(this, e.Item.Controls); return; } WebUtils.StartFunction(Session, FUNCTION_CODE, obj.EmpID); db.update(dbConn, obj); WebUtils.EndFunction(dbConn); Repeater.EditItemIndex = -1; //CNDAddPanel.Visible = IsAllowEdit; loadData(info, db, Repeater); WebUtils.SetEnabledControlSection(CNDAddPanel, true); } }
protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e) { Binding ebinding; EClaimsAndDeductions obj = new EClaimsAndDeductions(); db.toObject(((DataRowView)e.Item.DataItem).Row, obj); if (e.Item.ItemIndex == Repeater.EditItemIndex) { ebinding = new Binding(dbConn, db); ebinding.add(new TextBoxBinder(db, ((WebDatePicker)e.Item.FindControl("CNDEffDate")).TextBox, "CNDEffDate")); ebinding.add((HtmlInputHidden)e.Item.FindControl("CNDID")); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("PayCodeID"), EPaymentCode.VLPaymentCode)); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CurrencyID"), Values.VLCurrency)); ebinding.add((TextBox)e.Item.FindControl("CNDAmount")); ebinding.add(new CheckBoxBinder(db, (CheckBox)e.Item.FindControl("CNDIsRestDayPayment"))); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CNDPayMethod"), Values.VLPaymentMethod).setNotSelected(null)); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CostCenterID"), ECostCenter.VLCostCenter).setNotSelected(HROne.Common.WebUtility.GetLocalizedString(ECostCenter.DEFAULT_COST_CENTER_TEXT))); ebinding.add((TextBox)e.Item.FindControl("CNDNumOfDayAdj")); ebinding.add((TextBox)e.Item.FindControl("CNDRemark")); DBFilter empBankAccountFilter = new DBFilter(); OR bankAccountORTerm = new OR(); bankAccountORTerm.add(new Match("EmpID", CurID)); { EEmpPersonalInfo tmpEmpInfo = new EEmpPersonalInfo(); tmpEmpInfo.EmpID = CurID; if (EEmpPersonalInfo.db.select(dbConn, tmpEmpInfo) && tmpEmpInfo.MasterEmpID > 0) { bankAccountORTerm.add(new Match("EmpID", tmpEmpInfo.MasterEmpID)); } } empBankAccountFilter.add(bankAccountORTerm); ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("EmpAccID"), EEmpBankAccount.VLBankAccount, empBankAccountFilter).setNotSelected(HROne.Common.WebUtility.GetLocalizedString(EEmpBankAccount.DEFAULT_BANK_ACCOUNT_TEXT))); ebinding.init(Request, Session); Hashtable values = new Hashtable(); db.populate(obj, values); ebinding.toControl(values); ((HtmlTableCell)e.Item.FindControl("CostCenterDetailCell")).Visible = WebUtils.productLicense(Session).IsCostCenter; ((HtmlTableCell)e.Item.FindControl("RemarkCell")).ColSpan = ((HtmlTableRow)e.Item.FindControl("detailRow")).Cells.Count - 5 - (WebUtils.productLicense(Session).IsCostCenter ? 0 : 1); } else { ((Button)e.Item.FindControl("Edit")).Visible = IsAllowEdit; ((CheckBox)e.Item.FindControl("DeleteItem")).Visible = IsAllowEdit; if (obj.PayRecID != null) { ((Button)e.Item.FindControl("Edit")).Visible = false; ((CheckBox)e.Item.FindControl("DeleteItem")).Visible = false; } ebinding = new Binding(dbConn, db); ebinding.add((HtmlInputHidden)e.Item.FindControl("CNDID")); ebinding.add(new BlankZeroLabelVLBinder(db, (Label)e.Item.FindControl("CostCenterID"), ECostCenter.VLCostCenter).setTextDisplayForZero(HROne.Common.WebUtility.GetLocalizedString(ECostCenter.DEFAULT_COST_CENTER_TEXT))); DBFilter empBankAccountFilter = new DBFilter(); OR bankAccountORTerm = new OR(); bankAccountORTerm.add(new Match("EmpID", CurID)); { EEmpPersonalInfo tmpEmpInfo = new EEmpPersonalInfo(); tmpEmpInfo.EmpID = CurID; if (EEmpPersonalInfo.db.select(dbConn, tmpEmpInfo) && tmpEmpInfo.MasterEmpID > 0) { bankAccountORTerm.add(new Match("EmpID", tmpEmpInfo.MasterEmpID)); } } empBankAccountFilter.add(bankAccountORTerm); ebinding.add(new BlankZeroLabelVLBinder(db, (Label)e.Item.FindControl("EmpAccID"), EEmpBankAccount.VLBankAccount, empBankAccountFilter).setTextDisplayForZero(HROne.Common.WebUtility.GetLocalizedString(EEmpBankAccount.DEFAULT_BANK_ACCOUNT_TEXT))); Label PayPeriodID = (Label)e.Item.FindControl("PayPeriodID"); if (PayPeriodID != null) { ebinding.add(new BlankZeroLabelVLBinder(db, PayPeriodID, EPayrollPeriod.VLPayrollPeriod)); } ebinding.init(Request, Session); Hashtable values = new Hashtable(); db.populate(obj, values); if (obj.EmpPayrollID is int) { int EmpPayrollID = (int)obj.EmpPayrollID; if (EmpPayrollID > 0) { EEmpPayroll empPayroll = new EEmpPayroll(); empPayroll.EmpPayrollID = EmpPayrollID; if (EEmpPayroll.db.select(dbConn, empPayroll)) { values.Add("PayPeriodID", empPayroll.PayPeriodID.ToString()); } } } ebinding.toControl(values); ((HtmlTableCell)e.Item.FindControl("CostCenterDetailCell")).Visible = WebUtils.productLicense(Session).IsCostCenter; ((HtmlTableCell)e.Item.FindControl("RemarkCell")).ColSpan = ((HtmlTableRow)e.Item.FindControl("detailRow")).Cells.Count - 5 - (WebUtils.productLicense(Session).IsCostCenter ? 0 : 1) - (PayPeriodID != null ? 2 : 0); } HROne.Common.WebUtility.WebControlsLocalization(this, e.Item.Controls); }
protected void Add_Click(object sender, EventArgs e) { // Hard code set Currency to HKD CurrencyID.SelectedValue = "HKD"; Repeater.EditItemIndex = -1; EClaimsAndDeductions c = new EClaimsAndDeductions(); Hashtable values = new Hashtable(); newBinding.toValues(values); PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); db.validate(errors, values); if (!errors.isEmpty()) { return; } db.parse(values, c); if (c.CNDPayMethod.Equals("A")) { if (c.EmpAccID == 0) { EEmpBankAccount bankAccount = EEmpBankAccount.GetDefaultBankAccount(dbConn, c.EmpID); if (bankAccount != null) { //c.EmpAccID = bankAccount.EmpBankAccountID; } else { errors.addError("EmpAccID", HROne.Translation.PageErrorMessage.ERROR_ACCOUNT_REQUIRED); } } } else { c.EmpAccID = 0; } if (!errors.isEmpty()) { return; } WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID); db.insert(dbConn, c); WebUtils.EndFunction(dbConn); CNDEffDate.Value = string.Empty; PayCodeID.SelectedIndex = 0; CurrencyID.SelectedIndex = 0; CNDAmount.Text = string.Empty; CNDPayMethod.SelectedIndex = 0; CNDRemark.Text = string.Empty; EmpAccID.SelectedIndex = 0; CNDIsRestDayPayment.Checked = false; CNDNumOfDayAdj.Text = string.Empty; loadData(info, db, Repeater); }
public override DataTable UploadToTempDatabase(string Filename, int UserID, string ZipPassword) { DataTable rawDataTable = HROne.Import.ExcelImport.parse(Filename, ZipPassword).Tables[0]; ArrayList results = new ArrayList(); int rowCount = 0; string m_errorMessage; string m_colName; try { dbConn.BeginTransaction(); foreach (DataRow row in rawDataTable.Rows) { rowCount++; if (!ValidateInputData(row, out m_errorMessage, out m_colName)) { errors.addError(m_errorMessage, new string[] { rowCount.ToString("0"), m_colName }); } else { EBackpayBatchDetail m_upload = Transform(row, UserID); // m_util.Transform(row); if (!ValidateBusinessRule(m_upload, out m_errorMessage)) { errors.addError(m_errorMessage + " (row#={0})", new string[] { rowCount.ToString("0") }); } else { // update payscalemap DBFilter m_existingRecordFilter = new DBFilter(); m_existingRecordFilter.add(new Match("SchemeCode", AppUtils.Encode(EBackpayBatchDetail.db.getField("SchemeCode"), m_upload.SchemeCode))); m_existingRecordFilter.add(new NullTerm("ExpiryDate")); m_existingRecordFilter.add(new Match("Point", m_upload.Point)); ArrayList m_existingRecordList = EPayScaleMap.db.select(dbConn, m_existingRecordFilter); EPayScaleMap m_newMap = new EPayScaleMap(); m_newMap.SchemeCode = m_upload.SchemeCode; m_newMap.Point = m_upload.Point; m_newMap.Salary = m_upload.Salary; m_newMap.EffectiveDate = m_upload.EffectiveDate; if (m_existingRecordList.Count > 0) { EPayScaleMap m_currentMap = (EPayScaleMap)m_existingRecordList[0]; if (m_upload.EffectiveDate < m_currentMap.EffectiveDate) { errors.addError("Invalid Effective Date({0}). It must be before current effective date({1}).", new string[] { m_upload.EffectiveDate.ToString("yyyy-MM-dd"), m_currentMap.EffectiveDate.ToString("yyyy-MM-dd") }); break; } else { // expire current map m_currentMap.ExpiryDate = m_upload.EffectiveDate.AddDays(-1); EPayScaleMap.db.update(dbConn, m_currentMap); // insert new salary EPayScaleMap.db.insert(dbConn, m_newMap); EBackpayBatchDetail.db.insert(dbConn, m_upload); } } else { EPayScaleMap.db.insert(dbConn, m_newMap); EBackpayBatchDetail.db.insert(dbConn, m_upload); } // go through recurring payment DBFilter m_recurringPaymentFilter = new DBFilter(); DBFilter m_paymentTypeFilter = new DBFilter(); DBFilter m_paymentCodeFilter = new DBFilter(); m_paymentTypeFilter.add(new Match("PaymentTypeCode", "BASICSAL")); m_paymentCodeFilter.add(new IN("PaymentTypeID", "SELECT PaymentTypeID FROM PaymentType", m_paymentTypeFilter)); m_recurringPaymentFilter.add(new IN("PayCodeID", "SELECT PaymentCodeID FROM PaymentCode", m_paymentCodeFilter)); m_recurringPaymentFilter.add(new Match("SchemeCode", AppUtils.Encode(EEmpRecurringPayment.db.getField("SchemeCode"), m_upload.SchemeCode))); m_recurringPaymentFilter.add(new Match("Point", m_upload.Point)); m_recurringPaymentFilter.add(new Match("EmpRpEffFr", "<=", m_upload.EffectiveDate)); OR m_orDate = new OR(); m_orDate.add(new NullTerm("EmpRpEffTo")); m_orDate.add(new Match("EmpRPEffTo", ">=", m_upload.EffectiveDate)); m_recurringPaymentFilter.add(m_orDate); m_recurringPaymentFilter.add("EmpID", true); m_recurringPaymentFilter.add("EmpRpEffFr", true); foreach (EEmpRecurringPayment m_rp in EEmpRecurringPayment.db.select(dbConn, m_recurringPaymentFilter)) { // find payment records of each recurring payment DBFilter m_PaymentRecordFilter = new DBFilter(); DBFilter m_EmpPayrollFilter = new DBFilter(); DBFilter m_PayrollPeriodFilter = new DBFilter(); m_PayrollPeriodFilter.add(new Match("PayPeriodFr", ">=", m_upload.EffectiveDate)); m_EmpPayrollFilter.add(new Match("EmpID", m_rp.EmpID)); m_EmpPayrollFilter.add(new IN("PayPeriodID", "SELECT PayPeriodID FROM PayrollPeriod", m_PayrollPeriodFilter)); m_PaymentRecordFilter.add(new Match("PaymentCodeID", m_rp.PayCodeID)); m_PaymentRecordFilter.add(new IN("EmpPayrollID", "SELECT EmpPayrollID FROM EmpPayroll", m_EmpPayrollFilter)); string m_remarks = ""; double m_amount = 0; foreach (EPaymentRecord m_payRecords in EPaymentRecord.db.select(dbConn, m_PaymentRecordFilter)) { if (m_remarks != "") { m_remarks = m_remarks + " + "; } m_remarks = ((m_payRecords.PayRecActAmount / m_rp.EmpRPAmount) * (System.Convert.ToDouble(m_upload.Salary) - m_rp.EmpRPAmount)).ToString("0.00"); m_amount = ((m_payRecords.PayRecActAmount / m_rp.EmpRPAmount) * (System.Convert.ToDouble(m_upload.Salary) - m_rp.EmpRPAmount)); } // insert to claims & deduction EClaimsAndDeductions m_cnd = new EClaimsAndDeductions(); m_cnd.CNDEffDate = m_upload.BackpayDate; m_cnd.CNDAmount = m_amount; m_cnd.EmpID = m_rp.EmpID; m_cnd.CNDRemark = m_remarks; m_cnd.EmpAccID = m_rp.EmpAccID; m_cnd.CNDPayMethod = m_rp.EmpRPMethod; m_cnd.CostCenterID = m_rp.CostCenterID; m_cnd.CurrencyID = m_rp.CurrencyID; m_cnd.PayCodeID = HROne.Import.Parse.GetPaymentCodeID(dbConn, m_upload.PaymentCode); EClaimsAndDeductions.db.insert(dbConn, m_cnd); } } } } dbConn.CommitTransaction(); } catch (SqlException sqlEx) { errors.addError(sqlEx.Message, new string[] { }); dbConn.RollbackTransaction(); } return(rawDataTable); }