private void cmbSubsidiary_SelectedValueChanged(object sender, EventArgs e) { if (FormState == FormStates.fsView) { return; } object ATCId; if (cmbSubsidiary.SelectedValue != null && cmbSubsidiary.SelectedValue != DBNull.Value) { ATCId = VLookupProvider.DataSetLookup(VLookupProvider.dstSubsidiaries, "Id", cmbSubsidiary.SelectedValue, "ATCId"); if (ATCId != null && ATCId != DBNull.Value) { dstDetail.Columns.Find(c => c.Name == "ATCId").DefaultValue = ATCId.ToString(); foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Index != dataGridView.NewRowIndex) { row.Cells[dataGridView.GetCellIndex("ATCId")].Value = ATCId; } } } } }
protected override void Preview() { base.Preview(); //print the first item on selection String reportFormName = VLookupProvider.DataSetLookup(VLookupProvider.dstSystemPrintouts, "FormCaption", this.Caption, "PrintoutFormName").ToString(); IParentForm reportForm = IAppHandler.FindForm(reportFormName, "Printout", true); if (reportForm == null) { IMessageHandler.ShowError(ISystemMessages.PrintoutNotSet); } else { IAppHandler.AddUsedForm(this); this.Hide(); if (reportForm.Parameters.Find(p => p.Name == "Id") != null) { reportForm.Parameters.Find(p => p.Name == "Id").Value = this.Parameters.Find(pa => pa.Name == "Id").Value; } (reportForm as IReportForm).PrintoutHeader = this.Caption; reportForm.Run(); } }
private void ComputeDetailAmount() { int VATTypeId = int.Parse(dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("VATTypeId")].Value.ToString()); double Amount = double.Parse(dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("Amount")].Value.ToString()); double VATAmount = 0, GrossAmount = 0, WTAX = 0, ATCRate = 0; object ATCId; if (Amount == 0 || Modifying) { return; } try { Modifying = true; //VAT dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("VATAmount")].Value = ComputeVATAmount(VATTypeId, Amount).ToString(); VATAmount = double.Parse(dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("VATAmount")].Value.ToString()); //GrossAmount if (VATTypeId == 1) //Inclusive { GrossAmount = Amount - VATAmount; } else { GrossAmount = Amount; } dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("GrossAmount")].Value = GrossAmount; //WithholdingTax ATCId = dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("ATCId")].Value; if (ATCId != null && ATCId != DBNull.Value) { ATCRate = double.Parse(VLookupProvider.DataSetLookup(VLookupProvider.dstATC, "Id", ATCId, "Rate").ToString()); WTAX = Math.Round(GrossAmount * (ATCRate / 100), 2); } dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("WithholdingTax")].Value = WTAX; //Total if (VATTypeId == 1) //Inclusive { dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("Total")].Value = Amount.ToString(); } else { dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("Total")].Value = (Amount + VATAmount).ToString(); } } finally { Modifying = false; } }
private void EAccountForm_SetupData() { PluralizationService ps = PluralizationService.CreateService(CultureInfo.GetCultureInfo("en-us")); String cap = VLookupProvider.DataSetLookup(VLookupProvider.dstAccountTypes, "Id", Parameters.Find(p => p.Name == "AccountTypeId").Value, "Name").ToString(); Caption = ps.Singularize(cap); MasterColumns.Find(mc => mc.Name == "AccountTypeId").DefaultValue = Parameters.Find(p => p.Name == "AccountTypeId").Value; }
private double ComputeVATAmount(int VATTypeId, double Amount) { double VATAmount = 0, VATRate; VATRate = Double.Parse(VLookupProvider.DataSetLookup(VLookupProvider.dstVATTypes, "Id", VATTypeId, "Rate").ToString()); if (VATTypeId == 1) //Inclusive { VATAmount = Amount - (Amount / (1 + (VATRate / 100))); } else if (VATTypeId == 2) //Exclusive { VATAmount = Amount * (VATRate / 100); } return(Math.Round(VATAmount, 2)); }
private void SetFormFooter() { lblMode.Text = "Mode: " + FormState.ToString().Substring(2); if (FormState == FormStates.fsNew) { return; } if (MasterColumns.Find(col => col.Name == "DateCreated") != null) { lblCreatedBy.Text = String.Format("Created By: {0} on {1}", VLookupProvider.DataSetLookup(VLookupProvider.dstSystemUsers, "Id", MasterColumns.Find(col => col.Name == "CreatedById").Value, "FormalName"), Convert.ToDateTime(MasterColumns.Find(col => col.Name == "DateCreated").Value).ToString("MM'/'dd'/'yyyy 'at' hh:mm:ss tt") ); } if (MasterColumns.Find(col => col.Name == "DateModified") != null) { lblModifiedBy.Text = String.Format("Modified By: {0} on {1}", VLookupProvider.DataSetLookup(VLookupProvider.dstSystemUsers, "Id", MasterColumns.Find(col => col.Name == "ModifiedById").Value, "FormalName"), Convert.ToDateTime(MasterColumns.Find(col => col.Name == "DateModified").Value).ToString("MM'/'dd'/'yyyy 'at' hh:mm:ss tt") ); if (MasterColumns.Find(col => col.Name == "DateCreated").Value.ToString() == MasterColumns.Find(col => col.Name == "DateModified").Value.ToString()) { lblCreatedBy.Visible = true; lblModifiedBy.Visible = false; lblCreatedBy.Padding = new Padding(5, 5, 5, 5); } else { lblCreatedBy.Visible = true; lblModifiedBy.Visible = true; lblCreatedBy.Padding = new Padding(5, 0, 0, 0); lblModifiedBy.Padding = new Padding(5, 0, 0, 0); } } }
protected override void UpdateControls() { base.UpdateControls(); btnPreview.Visible = (FormState == FormStates.fsView) && (VLookupProvider.DataSetLookup(VLookupProvider.dstSystemPrintouts, "FormCaption", this.Caption, "FormCaption") != null); toolStripSeparatorPreview.Visible = btnPreview.Visible; btnFirstRecord.Enabled = btnFirstRecord.Enabled && KeyId != 0; btnPreviousRecord.Enabled = btnPreviousRecord.Enabled && KeyId != 0; btnNextRecord.Enabled = btnLastRecord.Enabled && KeyId != KeyList.Count - 1; btnLastRecord.Enabled = btnLastRecord.Enabled && KeyId != KeyList.Count - 1; lblCreatedBy.Visible = (MasterColumns.Find(col => col.Name == "CreatedById") != null) && (FormState != FormStates.fsNew); lblModifiedBy.Visible = (MasterColumns.Find(col => col.Name == "ModifiedById") != null) && (FormState != FormStates.fsNew); if (FormState != FormStates.fsNew) { KeyId = _KeyId; } }
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == dataGridView.NewRowIndex || FormState == FormStates.fsView) { return; } String VATTypeId = dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("VATTypeId")].Value.ToString(); if (VATTypeId != null) { dataGridView.CurrentRow.Cells[dataGridView.GetCellIndex("VATRate")].Value = VLookupProvider.DataSetLookup(VLookupProvider.dstVATTypes, "Id", VATTypeId, "Rate"); } ComputeDetailAmount(); ComputeMasterAmount(); }