// ------------------to check available cash ------------------------------
private void CashHandling()
{
this.Refresh();
Cursor.Current = Cursors.WaitCursor;
string sTot = "";
double totIncCus = 0.00;
double totIncService = 0.00;
double totIncomeMachine = 0.00;
double totInc = 0.00;
double totExp = 0.00;
DateTime dFrdt = DateTime.Today;//DateTime.Parse(dtpNetTotal.Text);
//Income
string str = "Select IncDte,TotAmount from T_IncomeInv";
Con = new OleDbConnection(dbCon());
OleDbCommand cmd = new OleDbCommand(str, Con);
Con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr.IsDBNull(0) == false)
{
string sDt = dr.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = dr.GetValue(1).ToString();
if (sTot != "")
{
totInc += Convert.ToDouble(sTot);
}
}
}
}
dr.Close();
// From Customer Income
string strCus = "Select BillDate,GrandTotal from T_CustBill Where Status<>'Cancel'";
OleDbCommand cmdCus = new OleDbCommand(strCus, Con);
OleDbDataReader drCus = cmdCus.ExecuteReader();
while (drCus.Read())
{
if (drCus.IsDBNull(0) == false)
{
string sDt = drCus.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = drCus.GetValue(1).ToString();
if (sTot != "")
{
totIncCus += Convert.ToDouble(sTot);
}
}
}
}
drCus.Close();
// ----------------------- Service Income ----------------------
// From Customer Income
string strService = "Select BillDate,NetRs from T_ServiceInv";
OleDbCommand cmdService = new OleDbCommand(strService, Con);
OleDbDataReader drService = cmdService.ExecuteReader();
while (drService.Read())
{
if (drService.IsDBNull(0) == false)
{
string sDt = drService.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = drService.GetValue(1).ToString();
if (sTot != "")
{
totIncService += Convert.ToDouble(sTot);
}
}
}
}
drService.Close();
//------------------------- Service Income End ----------------------
// ----------------------- Machine Income ----------------------
// From Customer Income
string strMachine = "Select BillDate,NsuRs from T_QuoBillInvoice";
OleDbCommand cmdMachine = new OleDbCommand(strMachine, Con);
OleDbDataReader drMachine = cmdMachine.ExecuteReader();
while (drMachine.Read())
{
if (drMachine.IsDBNull(0) == false)
{
string sDt = drMachine.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = drMachine.GetValue(1).ToString();
if (sTot != "")
{
totIncomeMachine += Convert.ToDouble(sTot);
}
}
}
}
drMachine.Close();
//------------------------- Machine Income End ----------------------
//
//Expenditure
string strExp = "Select ExpDte,TotAmount from T_ExpenditureInv";
OleDbCommand cmdExp = new OleDbCommand(strExp, Con);
OleDbDataReader drExp = cmdExp.ExecuteReader();
while (drExp.Read())
{
if (drExp.IsDBNull(0) == false)
{
string sDt = drExp.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = drExp.GetValue(1).ToString();
if (sTot != "")
{
totExp += Convert.ToDouble(sTot);
}
}
}
}
drExp.Close();
string SOthInc = totInc.ToString("N2");
string Sexpense = totExp.ToString("N2");
string SCusSpare = totIncCus.ToString("N2");
string SMachine = totIncomeMachine.ToString("N2");
string Sservice = totIncService.ToString("N2");
string sNetTotal = "0.00";
sNetTotal = ((totIncCus + totInc + totIncService + totIncomeMachine) - totExp).ToString("N2");
timer1.Enabled = true;
scrText = "Net Balance:" + sNetTotal.ToString() + " " + "Expense:" + Sexpense.ToString() + " " + "Other Income:" + SOthInc.ToString() + " " + "Spare:" + SCusSpare.ToString() + " " + "Invoice:" + SMachine.ToString()+" "+"Service:"+Sservice .ToString ();
// tsslAmt.Text = scrText.ToString();
Cursor.Current = Cursors.Default;
}
private void CashHandling()
{
this.Refresh();
Cursor.Current = Cursors.WaitCursor;
string sTot = "";
double totIncCus = 0.00;
double totIncService = 0.00;
double totIncomeMachine = 0.00;
double totInc = 0.00;
double totExp = 0.00;
DateTime dFrdt = DateTime.Today;//DateTime.Parse(dtpNetTotal.Text);
//Income
string str = "Select IncDte,TotAmount from T_IncomeInv";
Con = new OleDbConnection(dbCon());
OleDbCommand cmd = new OleDbCommand(str, Con);
Con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr.IsDBNull(0) == false)
{
string sDt = dr.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = dr.GetValue(1).ToString();
if (sTot != "")
{
totInc += Convert.ToDouble(sTot);
}
}
}
}
dr.Close();
// From Customer Income
string strCus = "Select BillDate,GrandTotal from T_CustBill Where Status<>'Cancel'";
OleDbCommand cmdCus = new OleDbCommand(strCus, Con);
OleDbDataReader drCus = cmdCus.ExecuteReader();
while (drCus.Read())
{
if (drCus.IsDBNull(0) == false)
{
string sDt = drCus.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = drCus.GetValue(1).ToString();
if (sTot != "")
{
totIncCus += Convert.ToDouble(sTot);
}
}
}
}
drCus.Close();
// ----------------------- Service Income ----------------------
// From Customer Income
string strService = "Select BillDate,NetRs from T_ServiceInv";
OleDbCommand cmdService = new OleDbCommand(strService, Con);
OleDbDataReader drService = cmdService.ExecuteReader();
while (drService.Read())
{
if (drService.IsDBNull(0) == false)
{
string sDt = drService.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = drService.GetValue(1).ToString();
if (sTot != "")
{
totIncService += Convert.ToDouble(sTot);
}
}
}
}
drService.Close();
//------------------------- Service Income End ----------------------
// ----------------------- Machine Income ----------------------
// From Customer Income
string strMachine = "Select BillDate,NsuRs from T_QuoBillInvoice";
OleDbCommand cmdMachine = new OleDbCommand(strMachine, Con);
OleDbDataReader drMachine = cmdMachine.ExecuteReader();
while (drMachine.Read())
{
if (drMachine.IsDBNull(0) == false)
{
string sDt = drMachine.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = drMachine.GetValue(1).ToString();
if (sTot != "")
{
totIncomeMachine += Convert.ToDouble(sTot);
}
}
}
}
drMachine.Close();
//------------------------- Machine Income End ----------------------
//
//Expenditure
string strExp = "Select ExpDte,TotAmount from T_ExpenditureInv";
OleDbCommand cmdExp = new OleDbCommand(strExp, Con);
OleDbDataReader drExp = cmdExp.ExecuteReader();
while (drExp.Read())
{
if (drExp.IsDBNull(0) == false)
{
string sDt = drExp.GetValue(0).ToString();
DateTime dDt = Convert.ToDateTime(sDt);
if (dFrdt == dDt)
{
// string str1 = "Select GrandTotal from T_CustBill Where CBillNo=" + billNo;
sTot = drExp.GetValue(1).ToString();
if (sTot != "")
{
totExp += Convert.ToDouble(sTot);
}
}
}
}
drExp.Close();
string SOthInc = totInc.ToString("N2");
string Sexpense = totExp.ToString("N2");
string SCusSpare = totIncCus.ToString("N2");
string SMachine = totIncomeMachine.ToString("N2");
string Sservice = totIncService.ToString("N2");
string sNetTotal = "0.00";
sNetTotal = ((totIncCus + totInc + totIncService + totIncomeMachine) - totExp).ToString("N2");
timer1.Enabled = true;
scrText = "Net Balance:" + sNetTotal.ToString() + " " + "Expense:" + Sexpense.ToString() + " " + "Other Income:" + SOthInc.ToString() + " " + "Spare:" + SCusSpare.ToString() + " " + "Invoice:" + SMachine.ToString()+" "+"Service:"+Sservice .ToString ();
// tsslAmt.Text = scrText.ToString();
Cursor.Current = Cursors.Default;
}
No comments:
Post a Comment