[WebMethod] public DataSet newleger(string accno, string fromdate, string todate) { SqlConnection con = new SqlConnection(@"Data Source=123-PC;Initial Catalog=bcounts;Persist Security Info=True;User ID=Saba;Password=123"); con.Open(); SqlCommand cmd = new SqlCommand("select gt.Value_Date,gt.Voucher_no+'-'+gr.VchrType as voucher,gt.Acct_Nirration,gr.InstrumentNo,gt.Dr_Amount,gt.Cr_Amount from gl_transaction gt, Gl_Ref gr where gt.Accountno = '" + accno + "' and gt.Voucher_No=gr.Voucher_no and gt.Value_Date between '" + fromdate + "' and '" + todate + "'", con); SqlDataAdapter adp = new SqlDataAdapter(cmd); SqlDataReader rdr = cmd.ExecuteReader(); decimal crsum = 0; decimal drsum = 0; decimal balance = 0; DataSet ds = new DataSet("Ledger");; adp.Fill(ds); if (rdr.HasRows) { while (rdr.Read()) { if (rdr.GetDecimal(4) > 0) { balance = balance + rdr.GetDecimal(4); drsum += rdr.GetDecimal(4); DataRow dr = ds.Tables[0].NewRow(); dr[0] = rdr.GetDateTime(0).ToShortDateString(); dr[1] = rdr.GetString(1); dr[2] = rdr.GetString(2); dr[3] = rdr.GetString(3); dr[4] = rdr.GetDecimal(4).ToString(); dr[5] = "-"; ds.Tables[0].Rows.Add(dr); //data.Add(new datalist7(rdr.GetDateTime(0).ToShortDateString(), rdr.GetString(1), rdr.GetString(2), rdr.GetString(3), rdr.GetDecimal(4).ToString(), "-", balance.ToString())); } else { balance = balance - rdr.GetDecimal(5); crsum += rdr.GetDecimal(5); DataRow dr = ds.Tables[0].NewRow(); dr[0] = rdr.GetDateTime(0).ToShortDateString(); dr[1] = rdr.GetString(1); dr[2] = rdr.GetString(2); dr[3] = rdr.GetString(3); dr[4] = "-"; dr[5] = rdr.GetDecimal(5).ToString(); ds.Tables[0].Rows.Add(dr); // data.Add(new datalist7(rdr.GetDateTime(0).ToShortDateString(), rdr.GetString(1), rdr.GetString(2), rdr.GetString(3), "-", rdr.GetDecimal(5).ToString(), balance.ToString())); } } DataRow dd = ds.Tables[0].NewRow(); dd[0] = "-"; dd[1] = "-"; dd[2] = "-"; dd[3] = "-"; dd[4] = drsum.ToString(); dd[5] = crsum.ToString(); //data.Add(new datalist7("-", "-", "-", "-", drsum.ToString(), crsum.ToString(), "-")); } con.Close(); return ds; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)