I have make below fuction which update NoOfSoldShares in Stock Entry.
this function work perfectly in 32 bit system,
but in 64 bit system NoOfSoldShares not update.
becoz of some 64 bit related issue this function not working,
but i have not 64 bit system to check for problem...
so please help me for issue...if any one has idea about this...
What I have tried:
public static void UpdateStockEntry()
{
try
{
string Query = "select concat('C',CompanyCode,myear,'SHARE_MKT') AS Databasename,CompanyCode,myear \n" +
"from yearmaster y inner join companymaster c on y.CompanyAuto=c.autotrno order by myear,CompanyCode asc";
DataTable database = Program.GetDataTable(Query, Program.SysConn);
DataTable SysDB = Program.GetDataTable("Select DISTINCT TABLE_SCHEMA from information_schema.TABLES where TABLE_SCHEMA like '%SHARE_MKT%' ", Program.Conn);
if (database.Rows.Count > 0)
{
for (int j = 0; j < database.Rows.Count; j++)
{
string Databasename = database.Rows[j]["Databasename"].ToString();
SysDB.DefaultView.RowFilter = "";
SysDB.DefaultView.RowFilter = "TABLE_SCHEMA='" + Databasename + "'";
if (SysDB.DefaultView.Count > 0)
{
decimal DbYear = decimal.Parse(database.Rows[j]["myear"].ToString());
decimal PrevYear = DbYear - 1;
string PrevDatabasename = Databasename.Replace(DbYear.ToString(), PrevYear.ToString());
SysDB.DefaultView.RowFilter = "";
SysDB.DefaultView.RowFilter = "TABLE_SCHEMA='" + PrevDatabasename + "'";
if (SysDB.DefaultView.Count > 0)
{
Program.Execute("update " + Databasename + ".StockEntry s\n" +
", " + PrevDatabasename + ".StockEntry sb\n" +
"set s.OpeningIssueShare=ifnull(sb.NoofSoldShares,0)\n" +
"where sb.autotrno=s.autotrno", Program.Conn);
}
if (Databasename != "")
{
Program.Execute("update " + Databasename + ".StockEntry set NoofSoldShares=ifnull(OpeningIssueShare,0)", Program.Conn);
Program.Execute("update " + Databasename + ".StockEntry s\n" +
",(select AgainstAuto,sum(SubQty) SubQty from " + Databasename + ".salesentrysub group by AgainstAuto) sb\n" +
"set NoofSoldShares=ifnull(NoofSoldShares,0)+ifnull(SubQty,0)\n" +
"where sb.AgainstAuto=s.autotrno", Program.Conn);
}
}
}
}
}
catch (Exception)
{
}
}