Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » assertion error while setting focus on text field(hello all, I have a strange issue with my swt based application. I am using Eclispe 4.2 and every thing works perfectly on my Ubuntu 12.04 machine. But I have a situation where I have to add a few t)
assertion error while setting focus on text field [message #1220340] Wed, 11 December 2013 03:26
Krishnakant Mane is currently offline Krishnakant Mane
Messages: 1
Registered: December 2013
Junior Member
package gnukhata.views;



import gnukhata.controllers.transactionController;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;

import sun.org.mozilla.javascript.ast.ThrowStatement;

public class AddNewVoucherComposite extends Composite
{
static Display display;
String typeFlag;

double totalDrAmount = 0.00;
double totalCrAmount = 0.00;
List<Combo> CrDrFlags = new ArrayList<Combo>();
List<Combo> accounts = new ArrayList<Combo>();
List<Text> DrAmounts = new ArrayList<Text>();
List<Text> CrAmounts = new ArrayList<Text>();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
List<String> masterQueryParams = new ArrayList<String>();
List<Object> detailQueryParams = new ArrayList<Object>();
List<Button> removeButton = new ArrayList<Button>();
TabItem fdrecord ;
Label lbldate;
Text txtddate;
Label dash1;
Text txtmdate;
Label dash2;
Text txtyrdate;
Label lblvoucherno;
Text txtvoucherno;
Label lblDR_CR;
Label lblAccName;
Label lblDrAmount;
Label lblcrAmount;
Text txtDebAmt1;
Text txtCreAmt1;
Text txtDebAmt2;
Text txtCreAmt2;
Text txttotalDebAmt;
Text txttotalCrAmt;
Label lblTotal;
Label lblnarration;
Text txtnarration;
Label lblselprj ;
Combo comboselprj;
Button save;
Combo comboDr_cr1;
Combo comboDr_cr2;
Combo comboDr_CrAccName1;
Combo comboDr_CrAccName2;
Label lblPurchaseOrdNo;
Label lblPurchaseAmount;
Label lblEnterPurchaseOrdNo;
Label lblPurchasedate;
Text txtPurchaseddate;
Label dash3;
Text txtPurchasemdate;
Label dash4;
Text txtPurchaseyrdate;
Button btnpurchaseOdrNo;
Text txtPurchaseOrderNo;
Label lblEnterPurchaseOrdAmt;
Text txtEnterPurchaseOrdAmt;
Group addvoucher;
Button btnRemove1;
Button btnRemove2;
AddNewVoucherComposite(Composite parent, int Style, String voucherType)
{
super(parent,Style);
typeFlag= voucherType;
Date today = new Date();
String strToday = sdf.format(today);
FormLayout formlayout = new FormLayout();
this.setLayout(formlayout);
this.setLayout(new FormLayout());
addvoucher = new Group(this,SWT.BORDER);
addvoucher.setText(" Add " + typeFlag+ " voucher " );
addvoucher.setFont(new Font(display, "Times New Roman", 14, SWT.ITALIC ));
addvoucher.setLayout(formlayout);

btnpurchaseOdrNo = new Button(this,SWT.CHECK);
btnpurchaseOdrNo.setText("Purchase Order Number");
btnpurchaseOdrNo.setFont(new Font(display, "Time New Roman",14,SWT.NORMAL));
FormData layout = new FormData();
layout.top = new FormAttachment(2);
layout.left = new FormAttachment(3);
layout.right = new FormAttachment(30);
layout.bottom = new FormAttachment(9);
btnpurchaseOdrNo.setLayoutData(layout);
btnpurchaseOdrNo.setVisible(false);

lblEnterPurchaseOrdNo = new Label(this,SWT.NONE);
lblEnterPurchaseOrdNo.setText("Enter Purchase Order No :");
lblEnterPurchaseOrdNo.setFont(new Font(display, "Time New Roman",12,SWT.NORMAL));
layout = new FormData();
layout.top = new FormAttachment(10);
layout.left = new FormAttachment(3);
layout.right = new FormAttachment(22);
layout.bottom = new FormAttachment(16);
lblEnterPurchaseOrdNo.setLayoutData(layout);
lblEnterPurchaseOrdNo.setVisible(false);

txtPurchaseOrderNo = new Text(this,SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(9);
layout.left = new FormAttachment(lblEnterPurchaseOrdNo);
layout.right = new FormAttachment(40);
layout.bottom = new FormAttachment(16);
txtPurchaseOrderNo.setLayoutData(layout);
txtPurchaseOrderNo.setVisible(false);

lblPurchasedate = new Label(this,SWT.NONE);
lblPurchasedate.setText("Purchase Date :");
lblPurchasedate.setFont(new Font(display, "Time New Roman",12,SWT.NORMAL));
layout = new FormData();
layout.top = new FormAttachment(10);
layout.left = new FormAttachment(55);
layout.right = new FormAttachment(66);
layout.bottom = new FormAttachment(16);
lblPurchasedate.setLayoutData(layout);
lblPurchasedate.setVisible(false);

txtPurchaseddate = new Text(this,SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(9);
layout.left = new FormAttachment(69);
layout.right = new FormAttachment(74);
layout.bottom = new FormAttachment(16);
txtPurchaseddate.setLayoutData(layout);
txtPurchaseddate.setVisible(false);
dash3 = new Label(this,SWT.NONE);
dash3.setText("-");
dash3.setFont(new Font(display, "Time New Roman",14,SWT.BOLD));
layout = new FormData();
layout.top = new FormAttachment(9);
layout.left = new FormAttachment(74);
layout.right = new FormAttachment(75);
layout.bottom = new FormAttachment(16);
dash3.setLayoutData(layout);
dash3.setVisible(false);
txtPurchasemdate = new Text(this,SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(9);
layout.left = new FormAttachment(75);
layout.right = new FormAttachment(79);
layout.bottom = new FormAttachment(16);
txtPurchasemdate.setLayoutData(layout);
txtPurchasemdate.setVisible(false);
dash4 = new Label(this,SWT.NONE);
dash4.setText("-");
dash4.setFont(new Font(display, "Time New Roman",14,SWT.BOLD));
layout = new FormData();
layout.top = new FormAttachment(9);
layout.left = new FormAttachment(79);
layout.right = new FormAttachment(80);
layout.bottom = new FormAttachment(16);
dash4.setLayoutData(layout);
dash4.setVisible(false);
txtPurchaseyrdate = new Text(this,SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(9);
layout.left = new FormAttachment(80);
layout.right = new FormAttachment(86);
layout.bottom = new FormAttachment(16);
txtPurchaseyrdate.setLayoutData(layout);
txtPurchaseyrdate.setVisible(false);

lblEnterPurchaseOrdAmt = new Label(this,SWT.NONE);
lblEnterPurchaseOrdAmt.setText("Enter Purchase Amount :");
lblEnterPurchaseOrdAmt.setFont(new Font(display, "Time New Roman",12,SWT.NORMAL));
layout = new FormData();
layout.top = new FormAttachment(lblEnterPurchaseOrdNo,7);
layout.left = new FormAttachment(3);
layout.right = new FormAttachment(21);
layout.bottom = new FormAttachment(23);
lblEnterPurchaseOrdAmt.setLayoutData(layout);
lblEnterPurchaseOrdAmt.setVisible(false);
txtEnterPurchaseOrdAmt = new Text(this,SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(txtPurchaseOrderNo,7);
layout.left = new FormAttachment(lblEnterPurchaseOrdAmt);
layout.right = new FormAttachment(40);
layout.bottom = new FormAttachment(25);
txtEnterPurchaseOrdAmt.setLayoutData(layout);
txtEnterPurchaseOrdAmt.setVisible(false);
lbldate = new Label(this,SWT.NONE);
lbldate.setText("Date :");
lbldate.setFont(new Font(display, "Time New Roman",12,SWT.NORMAL));
layout = new FormData();
layout.top = new FormAttachment(30);
layout.left = new FormAttachment(10);
layout.right = new FormAttachment(15);
layout.bottom = new FormAttachment(36);
lbldate.setLayoutData(layout);

txtddate = new Text(this,SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(29);
layout.left = new FormAttachment(15);
layout.right = new FormAttachment(19);
layout.bottom = new FormAttachment(36);
txtddate.setLayoutData(layout);
txtddate.setText(strToday.substring(0,2));
dash1 = new Label(this,SWT.NONE);
dash1.setText("-");
dash1.setFont(new Font(display, "Time New Roman",14,SWT.BOLD));
layout = new FormData();
layout.top = new FormAttachment(29);
layout.left = new FormAttachment(19);
layout.right = new FormAttachment(20);
layout.bottom = new FormAttachment(36);
dash1.setLayoutData(layout);
txtmdate = new Text(this,SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(29);
layout.left = new FormAttachment(20);
layout.right = new FormAttachment(25);
layout.bottom = new FormAttachment(36);
txtmdate.setLayoutData(layout);
txtmdate.setText(strToday.substring(3,5));

dash2 = new Label(this,SWT.NONE);
dash2.setText("-");
dash2.setFont(new Font(display, "Time New Roman",14,SWT.BOLD));
layout = new FormData();
layout.top = new FormAttachment(29);
layout.left = new FormAttachment(25);
layout.right = new FormAttachment(26);
layout.bottom = new FormAttachment(36);
dash2.setLayoutData(layout);
txtyrdate = new Text(this,SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(29);
layout.left = new FormAttachment(26);
layout.right = new FormAttachment(32);
layout.bottom = new FormAttachment(36);
txtyrdate.setLayoutData(layout);
txtyrdate.setText(strToday.substring(6));


lblvoucherno = new Label(this,SWT.NONE);
lblvoucherno.setText("Voucher No *");
lblvoucherno.setFont(new Font(display, "Time New Roman",12,SWT.NORMAL));
layout =new FormData();
layout.top = new FormAttachment(30);
layout.left = new FormAttachment(60);
layout.right = new FormAttachment(70);
layout.bottom = new FormAttachment(36);
lblvoucherno.setLayoutData(layout);
txtvoucherno = new Text(this,SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(29);
layout.left = new FormAttachment(lblvoucherno);
layout.right = new FormAttachment(85);
layout.bottom = new FormAttachment(36);
txtvoucherno.setLayoutData(layout);
//GridLayout for Group to dynamically insert a debit and credit entry
Group voucherInfo = new Group(this, SWT.BORDER | SWT.V_SCROLL );
voucherInfo.setText("Voucher Records");
GridLayout gridlayout = new GridLayout();
gridlayout.numColumns = 5;
voucherInfo.setLayout(gridlayout);
layout = new FormData();
layout.top = new FormAttachment(37);
layout.left = new FormAttachment(6);
layout.right = new FormAttachment(95);
layout.bottom = new FormAttachment(70);
voucherInfo.setLayoutData(layout);

lblDR_CR = new Label(voucherInfo,SWT.BORDER);
lblDR_CR.setText(" DR/CR ");
GridData griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
lblDR_CR.setLayoutData(griddata);

lblAccName = new Label(voucherInfo,SWT.BORDER);
lblAccName.setText(" Account Name ");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
lblAccName.setLayoutData(griddata);

lblDrAmount = new Label(voucherInfo,SWT.BORDER);
lblDrAmount.setText(" Debit Amount ");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
lblDrAmount.setLayoutData(griddata);

lblcrAmount = new Label(voucherInfo,SWT.BORDER);
lblcrAmount.setText(" Credit Amount ");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
lblcrAmount.setLayoutData(griddata);

Label lblblankHeader = new Label(voucherInfo,SWT.BORDER);
lblblankHeader.setText(" ");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
lblblankHeader.setLayoutData(griddata);

comboDr_cr1 = new Combo(voucherInfo,SWT.READ_ONLY);
comboDr_cr1.add(" Dr");
comboDr_cr1.add(" Cr");
comboDr_cr1.select(0);
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
comboDr_cr1.setLayoutData(griddata);

comboDr_CrAccName1 = new Combo(voucherInfo,SWT.READ_ONLY);
comboDr_CrAccName1.add(" select ");
comboDr_CrAccName1.select(0);
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
comboDr_CrAccName1.setLayoutData(griddata);

txtDebAmt1 = new Text(voucherInfo,SWT.BORDER);
txtDebAmt1.setText("0.00");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
txtDebAmt1.setLayoutData(griddata);

txtCreAmt1 = new Text(voucherInfo,SWT.BORDER);
txtCreAmt1.setText("0.00");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
txtCreAmt1.setLayoutData(griddata);

btnRemove1 = new Button(voucherInfo,SWT.PUSH);
btnRemove1.setText("Remove");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
btnRemove1.setLayoutData(griddata);
btnRemove1.setEnabled(false);

comboDr_cr2 = new Combo(voucherInfo,SWT.READ_ONLY);
comboDr_cr2.add("Dr");
comboDr_cr2.add("Cr");
comboDr_cr2.select(1);
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
comboDr_cr2.setLayoutData(griddata);

comboDr_CrAccName2 = new Combo(voucherInfo,SWT.READ_ONLY);
comboDr_CrAccName2.add(" select ");
comboDr_CrAccName2.select(0);
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
comboDr_CrAccName2.setLayoutData(griddata);

txtDebAmt2 = new Text(voucherInfo,SWT.BORDER);
txtDebAmt2.setText("0.00");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
txtDebAmt2.setLayoutData(griddata);

txtCreAmt2 = new Text(voucherInfo,SWT.BORDER);
txtCreAmt2.setText("0.00");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
txtCreAmt2.setLayoutData(griddata);

btnRemove2 = new Button(voucherInfo,SWT.PUSH);
btnRemove2.setText("Remove");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
btnRemove2 .setLayoutData(griddata);
btnRemove2.setEnabled(false);

/*Label lblblank = new Label(voucherInfo,SWT.BORDER);
lblblank .setText(" ");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
lblblank.setLayoutData(griddata);

lblTotal = new Label(voucherInfo,SWT.BORDER);
lblTotal.setText(" Total ");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
lblTotal.setLayoutData(griddata);

txttotalDebAmt = new Text(voucherInfo,SWT.BORDER);
txttotalDebAmt.setText("0.00");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
txttotalDebAmt.setLayoutData(griddata);

txttotalCrAmt = new Text(voucherInfo,SWT.BORDER);
txttotalCrAmt.setText("0.00");
griddata = new GridData();
griddata.horizontalAlignment = GridData.FILL;
griddata.grabExcessHorizontalSpace = true;
txttotalCrAmt.setLayoutData(griddata);*/
//Narration
lblnarration = new Label(this,SWT.NONE);
lblnarration.setText("Narration :");
lblnarration.setFont(new Font(display, "Time New Roman",14,SWT.RIGHT));
layout = new FormData();
layout.top = new FormAttachment(voucherInfo,10);
layout.left = new FormAttachment(7);
layout.right = new FormAttachment(17);
layout.bottom = new FormAttachment(80);
lblnarration.setLayoutData(layout);
txtnarration = new Text(this,SWT.MULTI | SWT.BORDER);
layout = new FormData();
layout.top = new FormAttachment(voucherInfo,10);
layout.left = new FormAttachment(lblnarration);
layout.right = new FormAttachment(45);
layout.bottom = new FormAttachment(87);
txtnarration.setLayoutData(layout);
//txtnarration.setEnabled(false);

lblselprj = new Label(this,SWT.NONE);
lblselprj.setText("Select Project :");
lblselprj.setFont(new Font(display, "Time New Roman",14,SWT.RIGHT));
layout = new FormData();
layout.top = new FormAttachment(voucherInfo,10);
layout.left = new FormAttachment(48);
layout.right = new FormAttachment(61);
layout.bottom = new FormAttachment(80);
lblselprj.setLayoutData(layout);

comboselprj = new Combo(this,SWT.READ_ONLY);
comboselprj.setToolTipText("Select your Orgnization");
comboselprj.add(" No project ");
comboselprj.select(0);
comboselprj.setVisible(true);
layout = new FormData();
layout.top = new FormAttachment(voucherInfo,10);
layout.left = new FormAttachment(lblselprj,5);
layout.right = new FormAttachment(85);
layout.bottom = new FormAttachment(81);
comboselprj.setLayoutData(layout);

save = new Button(this,SWT.PUSH);
save.setText("Save");
save.setFont(new Font(display, "Time New Roman",14,SWT.RIGHT));
layout = new FormData();
layout.top = new FormAttachment(89);
layout.left = new FormAttachment(47);
layout.right = new FormAttachment(54);
layout.bottom = new FormAttachment(98);
save.setLayoutData(layout);
txtddate.setFocus();

CrDrFlags.add(comboDr_cr1);
CrDrFlags.add(comboDr_cr2);
accounts.add(comboDr_CrAccName1);
accounts.add(comboDr_CrAccName2);
DrAmounts.add(txtDebAmt1);
DrAmounts.add(txtDebAmt2);
CrAmounts.add(txtCreAmt1);
CrAmounts.add(txtCreAmt2);
removeButton.add(btnRemove1);
removeButton.add(btnRemove2);


this.pack();
this.getAccessible();
this.setEvents();

}
private void setEvents()
{

CrAmounts.get(0).setEnabled(false);
DrAmounts.get(1).setEnabled(false);
if(typeFlag.equals("Contra") )
{
comboDr_CrAccName1.setItems(transactionController.getContra());
comboDr_CrAccName2.setItems(transactionController.getContra());

}
if(typeFlag.equals("Journal") )
{
comboDr_CrAccName1.setItems(transactionController.getJournal());
comboDr_CrAccName2.setItems(transactionController.getJournal());

}
if(typeFlag.equals("Payment"))
{
comboDr_CrAccName1.setItems(transactionController.getPayment("Dr"));
comboDr_CrAccName2.setItems(transactionController.getPayment("Cr"));

}
if(typeFlag.equals("Receipt"))
{
comboDr_CrAccName1.setItems(transactionController.getReceipt("Dr"));
comboDr_CrAccName2.setItems(transactionController.getReceipt("Cr"));
}
if(typeFlag.equals("Credit Note"))
{
comboDr_CrAccName1.setItems(transactionController.getCreditNote("Dr"));
comboDr_CrAccName2.setItems(transactionController.getCreditNote("Cr"));
}
if(typeFlag.equals("Debit Note"))
{
comboDr_CrAccName1.setItems(transactionController.getDebitNote("Dr"));
comboDr_CrAccName2.setItems(transactionController.getDebitNote("Cr"));
}
if(typeFlag.equals("Sales"))
{
comboDr_CrAccName1.setItems(transactionController.getSales("Dr"));
comboDr_CrAccName2.setItems(transactionController.getSales("Cr"));
}
if(typeFlag.equals("Sales Return"))
{
comboDr_CrAccName1.setItems(transactionController.getSalesReturn("Dr"));
comboDr_CrAccName2.setItems(transactionController.getSalesReturn("Cr"));
}
if(typeFlag.equals("Purchase"))
{
comboDr_CrAccName1.setItems(transactionController.getPurchase("Dr"));
comboDr_CrAccName2.setItems(transactionController.getPurchase("Cr"));
}
if(typeFlag.equals("Purchase Return"))
{
comboDr_CrAccName1.setItems(transactionController.getPurchaseReturn("Dr"));
comboDr_CrAccName2.setItems(transactionController.getPurchaseReturn("Cr"));
}

CrDrFlags.get(0).addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {

String DrCrFlag = CrDrFlags.get(0).getItem(CrDrFlags.get(0).getSelectionIndex());
DrCrFlag = DrCrFlag.trim();



accounts.get(0).removeAll();



if(DrCrFlag.equals("Dr"))
{

DrAmounts.get(0).setEnabled(true);

// TODO Auto-generated catch block


CrAmounts.get(0).setEnabled(false);



}
if(DrCrFlag.equals("Cr"))
{


DrAmounts.get(0).setEnabled(false);



CrAmounts.get(0).setEnabled(true);


}

if (typeFlag.equals("Payment"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPayment(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Receipt"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getReceipt(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Credit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getCreditNote(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Debit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getDebitNote(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSales(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSalesReturn(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchase(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchaseReturn(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Contra"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getContra());
for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Journal"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getJournal());

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(0).add(finalAccounts.get(i));
}
}


}
});

CrDrFlags.get(1).addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
String DrCrFlag = CrDrFlags.get(1).getItem(CrDrFlags.get(1).getSelectionIndex());
DrCrFlag = DrCrFlag.trim();
MessageBox drcrinfo = new MessageBox(new Shell(),SWT.OK);
drcrinfo.setMessage(DrCrFlag );
drcrinfo.open();
accounts.get(1).removeAll();


if(DrCrFlag.equals("Dr"))
{
MessageBox msg = new MessageBox(new Shell(),SWT.OK);
msg.setMessage(" entered into if for DR");
msg.open();
DrAmounts.get(1).setEnabled(true);
CrAmounts.get(1).setEnabled(false);


}
if(DrCrFlag.equals("Cr"))
{
MessageBox msg = new MessageBox(new Shell(),SWT.OK);
msg.setMessage(" entered into if of Cr");
msg.open();
DrAmounts.get(1).setEnabled(false);
CrAmounts.get(1).setEnabled(true);


}
if (typeFlag.equals("Payment"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPayment(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Receipt"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getReceipt(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Credit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getCreditNote(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Debit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getDebitNote(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSales(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSalesReturn(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchase(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchaseReturn(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Contra"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getContra());

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Journal"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getJournal());

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(1).add(finalAccounts.get(i));
}
}
}
});

DrAmounts.get(0).addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
totalCrAmount = 0.00;
totalDrAmount = 0.00;
if(!DrAmounts.get(0).getText().equals("0.00") || DrAmounts.get(0).getText().equals("") )
{
CrAmounts.get(1).setText(DrAmounts.get(0).getText());

}
for (int drCounter =0; drCounter< DrAmounts.size(); drCounter++ )
{
if(DrAmounts.get(drCounter).getText().equals(""))
{
totalDrAmount = totalDrAmount + 0.00;
}
else
{
totalDrAmount = totalDrAmount + Double.valueOf(DrAmounts.get(drCounter).getText());

}
}
for (int crCounter =0; crCounter< CrAmounts.size(); crCounter++ )
{
if(CrAmounts.get(crCounter).getText().equals(""))
{
totalCrAmount = totalCrAmount + 0.00;
}
else
{
totalCrAmount = totalCrAmount + Double.valueOf(CrAmounts.get(crCounter).getText());

}
}
//txttotalDebAmt.setText(String.valueOf(totalDrAmount));
//txttotalCrAmt.setText(String.valueOf(totalCrAmount));
}
});
CrAmounts.get(0).addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
totalCrAmount = 0.00;
totalDrAmount = 0.00;
if(!CrAmounts.get(0).getText().equals("0.00") || CrAmounts.get(0).getText().equals("") )
{
DrAmounts.get(1).setText(CrAmounts.get(0).getText());
}
for (int crCounter =0; crCounter< CrAmounts.size(); crCounter++ )
{
if(CrAmounts.get(crCounter).getText().equals(""))
{
totalCrAmount = totalCrAmount + 0.00;
}
else
{
totalCrAmount = totalCrAmount + Double.valueOf(CrAmounts.get(crCounter).getText());
}
}
for (int drCounter =0; drCounter< DrAmounts.size(); drCounter++ )
{
if(DrAmounts.get(drCounter).getText().equals(""))
{
totalDrAmount = totalDrAmount + 0.00;
}
else
{
totalDrAmount = totalDrAmount + Double.valueOf(DrAmounts.get(drCounter).getText());
}
}
//txttotalCrAmt.setText(String.valueOf(totalCrAmount));
//txttotalDebAmt.setText(String.valueOf(totalDrAmount));
}
});

DrAmounts.get(1).addFocusListener(new FocusAdapter(){
@Override
public void focusLost(FocusEvent arg0) {

totalCrAmount = 0.00;
totalDrAmount = 0.00;
if( CrAmounts.get(0).isEnabled() && (CrAmounts.get(0).getText().equals("0.00") || CrAmounts.get(0).getText().equals("") ))
{
CrAmounts.get(0).setText(DrAmounts.get(1).getText());
}
if( DrAmounts.get(0).isEnabled() )
{
if(DrAmounts.get(0).getText().equals("0.00") || DrAmounts.get(0).getText().equals("") )
{
DrAmounts.get(0).setFocus();
}

}

for (int drCounter =0; drCounter< DrAmounts.size(); drCounter++ )
{
if(DrAmounts.get(drCounter).getText().equals(""))
{
totalDrAmount = totalDrAmount + 0.00;
}
else
{
totalDrAmount = totalDrAmount + Double.valueOf(DrAmounts.get(drCounter).getText());

}
}
for (int crCounter =0; crCounter< CrAmounts.size(); crCounter++ )
{
if(CrAmounts.get(crCounter).getText().equals(""))
{
totalCrAmount = totalCrAmount + 0.00;
}
else
{
totalCrAmount = totalCrAmount + Double.valueOf(CrAmounts.get(crCounter).getText());

}
}
//txttotalDebAmt.setText(String.valueOf(totalDrAmount));
//txttotalCrAmt.setText(String.valueOf(totalCrAmount));
if( totalDrAmount == totalCrAmount )
{
txtnarration.setFocus();
}

if(totalCrAmount> totalDrAmount)
{
double balanceAmount = totalCrAmount - totalDrAmount;
//addRow("Dr", balanceAmount);
//CrDrFlags.get(CrDrFlags.size()-1 ).setFocus();
}
if(totalDrAmount > totalCrAmount)
{
MessageBox msg = new MessageBox(new Shell(),SWT.OK);
msg.setMessage("Dr is greater than Cr");
msg.open();
double balanceAmount = totalDrAmount - totalCrAmount;
//addRow("Cr", balanceAmount);
//CrDrFlags.get(CrDrFlags.size()-1 ).setFocus();
}
}
});
CrAmounts.get(1).addFocusListener(new FocusAdapter() {

@Override
public void focusLost(FocusEvent arg0) {

// TODO Auto-generated method stub
//super.focusLost(arg0);

totalCrAmount = 0.00;
totalDrAmount = 0.00;
if( DrAmounts.get(0).isEnabled() && (DrAmounts.get(0).getText().equals("0.00") || DrAmounts.get(0).getText().equals("") ))
{
DrAmounts.get(0).setText( CrAmounts.get(1).getText());
}
if( CrAmounts.get(0).isEnabled() )
{
MessageBox msg = new MessageBox(new Shell(),SWT.OK);
msg.setMessage("both CR are enabled");
msg.open();
if(CrAmounts.get(0).getText().equals("0.00") || CrAmounts.get(0).getText().equals("") )
{
MessageBox msg1 = new MessageBox(new Shell(),SWT.OK);
msg1.setMessage("CR is enabled with blank");
msg1.open();
Text txtPreviousCr = CrAmounts.get(0);


txtPreviousCr.setFocus();
return;

}
else
{
//addRow();
}
}
for (int crCounter =0; crCounter< CrAmounts.size(); crCounter++ )
{
if(CrAmounts.get(crCounter).getText().equals(""))
{
totalCrAmount = totalCrAmount + 0.00;
}
else
{
totalCrAmount = totalCrAmount + Double.valueOf(CrAmounts.get(crCounter).getText());
}
}
for (int drCounter =0; drCounter<DrAmounts.size(); drCounter++ )
{
if(DrAmounts.get(drCounter).getText().equals(""))
{
totalDrAmount = totalDrAmount + 0.00;
}
else
{
totalDrAmount = totalDrAmount + Double.valueOf(DrAmounts.get(drCounter).getText());
}
}
//txttotalDebAmt.setText(String.valueOf(totalDrAmount));
//txttotalCrAmt.setText(String.valueOf(totalCrAmount));

if(totalCrAmount> totalDrAmount)
{
double balanceAmount = totalCrAmount - totalDrAmount;
//addRow("Dr", balanceAmount);
CrDrFlags.get(CrDrFlags.size()-1 ).setFocus();

}
if(totalDrAmount > totalCrAmount)
{
double balanceAmount = totalDrAmount - totalCrAmount;
//addRow("Cr", balanceAmount);

CrDrFlags.get(CrDrFlags.size()-1 ).setFocus();
}
if(totalDrAmount == totalCrAmount)
{
txtnarration.setFocus();
MessageBox msg = new MessageBox(new Shell(),SWT.OK);
msg.setMessage("Dr and Cr are equal");
msg.open();
}
}
});

}
public void makeaccssible(Control c)
{
c.getAccessible();
}
private ArrayList<String> getFilteredAccountList(String[] OrigList)
{
ArrayList<String> filterAccounts = new ArrayList<String>();

for(int i=0;i<OrigList.length;i++)
{
filterAccounts.add(OrigList[i]);
}
for(int drcounter = 0; drcounter <accounts.size(); drcounter ++)
{
if( accounts.get(drcounter).getSelectionIndex()>= 0)
{
Iterator<String> itr=filterAccounts.iterator();
while(itr.hasNext())

{
if (itr.next().equals(accounts.get(drcounter).getItem(accounts.get(drcounter).getSelectionIndex())))
{


itr.remove();
}
}
}
}

return filterAccounts;
}
/*private void addRow(String DrCrParam, double balanceAmount)
{

lblTotal.dispose();
txttotalCrAmt.dispose();
txttotalDebAmt.dispose();
voucherTable.remove(voucherTable.getItemCount()-1);
TableItem newRow = new TableItem(voucherTable, SWT.NONE);
TableItem totalRow = new TableItem(voucherTable, SWT.NONE);
TableEditor DrCrEditor = new TableEditor(voucherTable);
TableEditor accountNameEditor = new TableEditor(voucherTable);
TableEditor DrAmountEditor = new TableEditor(voucherTable);
TableEditor CrAmountEditor = new TableEditor(voucherTable);
TableEditor TotalLblEditor = new TableEditor(voucherTable);
TableEditor TotalDrEditor = new TableEditor(voucherTable);
TableEditor TotalCrEditor = new TableEditor(voucherTable);
TableEditor RemoveButtonEditor = new TableEditor(voucherTable);

Combo newCrDrCombo = new Combo(voucherTable, SWT.READ_ONLY);
DrCrEditor.setEditor(newCrDrCombo,newRow,0 );
DrCrEditor.grabHorizontal = true;
newCrDrCombo.add("Dr");
newCrDrCombo.add("Cr");
//CrDrFlags.get(CrDrFlags.size()-1 ).setFocus();
Combo newAccountsCombo = new Combo(voucherTable, SWT.READ_ONLY);
accountNameEditor.setEditor(newAccountsCombo,newRow,1 );
accountNameEditor.grabHorizontal = true;
newAccountsCombo.add(" Select ");

Text newTxtDrAmount = new Text(voucherTable, SWT.BORDER);
DrAmountEditor.setEditor(newTxtDrAmount,newRow,2 );
DrAmountEditor.grabHorizontal = true;
Text newTxtCrAmount = new Text(voucherTable, SWT.BORDER);
CrAmountEditor.setEditor(newTxtCrAmount,newRow,3 );
CrAmountEditor.grabHorizontal = true;
lblTotal = new Label(voucherTable,SWT.NONE);
TotalLblEditor.setEditor(lblTotal,totalRow,1);
TotalLblEditor.grabHorizontal = true;
txttotalDebAmt = new Text(voucherTable, SWT.BORDER | SWT.READ_ONLY);
TotalDrEditor.setEditor(txttotalDebAmt,totalRow,2);
TotalDrEditor.grabHorizontal = true;
txttotalCrAmt = new Text(voucherTable,SWT.BORDER | SWT.READ_ONLY);
TotalCrEditor.setEditor(txttotalCrAmt,totalRow,3);
TotalCrEditor.grabHorizontal = true;
Button btnNewRemoveButton = new Button(voucherTable, SWT.PUSH);
btnNewRemoveButton.setText("Remove");
RemoveButtonEditor.setEditor(btnNewRemoveButton,newRow,4);
RemoveButtonEditor.grabHorizontal = true;
btnNewRemoveButton.setVisible(false);
// since new widgets are added to a row we will add them to respective array list
CrDrFlags.add(newCrDrCombo);
accounts.add(newAccountsCombo);
DrAmounts.add(newTxtDrAmount);
CrAmounts.add(newTxtCrAmount);
removeButton.add(btnNewRemoveButton);
voucherTable.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent arg0) {
MessageBox msg = new MessageBox(new Shell(),SWT.OK);
msg.setMessage("Table get focus again........");
msg.open();
CrDrFlags.get(CrDrFlags.size() -1).setFocus();
}
});
if(DrCrParam.equals("Dr"))
{
//newCrDrCombo.select(0);
CrDrFlags.get(CrDrFlags.size() -1).select(0);
accounts.get(accounts.size() -1).setText(String.valueOf(balanceAmount));
CrAmounts.get(CrAmounts.size() -1).setEnabled(false);
if (typeFlag.equals("Payment"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPayment(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));

}
}

if (typeFlag.equals("Receipt"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getReceipt(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Credit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getCreditNote(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Debit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getDebitNote(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSales(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSalesReturn(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchase(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchaseReturn(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Contra"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getContra());
for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Journal"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getJournal());

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

totalCrAmount = 0.00;
totalDrAmount = 0.00;
for (int drCounter =0; drCounter< DrAmounts.size(); drCounter++ )
{
if(DrAmounts.get(drCounter).getText().equals(""))
{
totalDrAmount = totalDrAmount + 0.00;
}
else
{
totalDrAmount = totalDrAmount + Double.valueOf(DrAmounts.get(drCounter).getText());

}
}
for (int crCounter =0; crCounter< CrAmounts.size(); crCounter++ )
{
if(CrAmounts.get(crCounter).getText().equals(""))
{
totalCrAmount = totalCrAmount + 0.00;
}
else
{
totalCrAmount = totalCrAmount + Double.valueOf(CrAmounts.get(crCounter).getText());

}
}
txttotalDebAmt.setText(String.valueOf(totalDrAmount));
txttotalCrAmt.setText(String.valueOf(totalCrAmount));


}
if(DrCrParam.equals("Cr"))
{
//newCrDrCombo.select(1);
CrDrFlags.get(CrDrFlags.size() -1).select(1);
accounts.get(accounts.size() -1).setText(String.valueOf(balanceAmount));
DrAmounts.get(DrAmounts.size() -1).setEnabled(false);
if (typeFlag.equals("Payment"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPayment(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));

}
}

if (typeFlag.equals("Receipt"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getReceipt(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Credit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getCreditNote(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Debit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getDebitNote(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSales(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSalesReturn(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchase(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchaseReturn(DrCrParam));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Contra"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getContra());
for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Journal"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getJournal());

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}
totalCrAmount = 0.00;
totalDrAmount = 0.00;
for (int crCounter =0; crCounter< CrAmounts.size(); crCounter++ )
{
if(CrAmounts.get(crCounter).getText().equals(""))
{
totalCrAmount = totalCrAmount + 0.00;
}
else
{
totalCrAmount = totalCrAmount + Double.valueOf(CrAmounts.get(crCounter).getText());
}
}
for (int drCounter =0; drCounter<DrAmounts.size(); drCounter++ )
{
if(DrAmounts.get(drCounter).getText().equals(""))
{
totalDrAmount = totalDrAmount + 0.00;
}
else
{
totalDrAmount = totalDrAmount + Double.valueOf(DrAmounts.get(drCounter).getText());
}
}
txttotalDebAmt.setText(String.valueOf(totalDrAmount));
txttotalCrAmt.setText(String.valueOf(totalCrAmount));


}

for(int i = 0; i< removeButton.size(); i++ )
{
removeButton.get(i).setVisible(true);
}
CrDrFlags.get(CrDrFlags.size() -1 ).addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
//super.widgetSelected(arg0);
String DrCrFlag = CrDrFlags.get(CrDrFlags.size() -1 ).getItem(CrDrFlags.get(CrDrFlags.size() -1).getSelectionIndex() );
accounts.get(accounts.size() -1).removeAll();
if(DrCrFlag.equals("Dr"))
{
DrAmounts.get(DrAmounts.size() -1).setEnabled(true);
CrAmounts.get(CrAmounts.size() -1).setEnabled(false);


}
if(DrCrFlag.equals("Cr"))
{
DrAmounts.get(DrAmounts.size() -1).setEnabled(false);
CrAmounts.get(CrAmounts.size() -1).setEnabled(true);

}

if (typeFlag.equals("Payment"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPayment(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));

}
}

if (typeFlag.equals("Receipt"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getReceipt(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Credit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getCreditNote(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Debit Note"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getDebitNote(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSales(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Sales Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getSalesReturn(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchase(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

if (typeFlag.equals("Purchase Return"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getPurchaseReturn(DrCrFlag));

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Contra"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getContra());
for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}
if (typeFlag.equals("Journal"))
{
List<String> finalAccounts = getFilteredAccountList(gnukhata.controllers.transactionController.getJournal());

for (int i = 0; i< finalAccounts.size(); i++)
{
accounts.get(accounts.size() -1).add(finalAccounts.get(i));
}
}

}
});

DrAmounts.get(DrAmounts.size() -1 ).addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {

totalCrAmount = 0.00;
totalDrAmount = 0.00;
for (int drCounter =0; drCounter< DrAmounts.size(); drCounter++ )
{
if(DrAmounts.get(drCounter).getText().equals(""))
{
totalDrAmount = totalDrAmount + 0.00;
}
else
{
totalDrAmount = totalDrAmount + Double.valueOf(DrAmounts.get(drCounter).getText());

}
}
for (int crCounter =0; crCounter< CrAmounts.size(); crCounter++ )
{
if(CrAmounts.get(crCounter).getText().equals(""))
{
totalCrAmount = totalCrAmount + 0.00;
}
else
{
totalCrAmount = totalCrAmount + Double.valueOf(CrAmounts.get(crCounter).getText());

}
}
txttotalDebAmt.setText(String.valueOf(totalDrAmount));
txttotalCrAmt.setText(String.valueOf(totalCrAmount));

if(totalCrAmount> totalDrAmount)
{
double balanceAmount = totalCrAmount - totalDrAmount;
addRow("Dr", balanceAmount);
CrDrFlags.get(CrDrFlags.size()-1 ).setFocus();

}
if(totalDrAmount > totalCrAmount)
{
double balanceAmount = totalDrAmount - totalCrAmount;
addRow("Cr", balanceAmount);
CrDrFlags.get(CrDrFlags.size()-1 ).setFocus();
}
if(totalDrAmount == totalCrAmount)
{
txtnarration.setFocus();
MessageBox msg = new MessageBox(new Shell(),SWT.OK);
msg.setMessage("Dr and Cr are
Previous Topic:Juno crashes on Ubuntu 13.10
Next Topic:How to setup a swt source workspace
Goto Forum:
  


Current Time: Fri Aug 22 19:35:48 EDT 2014

Powered by FUDForum. Page generated in 0.02496 seconds