Friday, March 19, 2010

Create webservice with access database and C#

Create webservice with access database and C#
<%@ WebHandler Language="C#" Class="rss" %>

using System;

using System.Web;

using System.Data.OleDb;

using System.Text;

using System.Xml;

public class rss : IHttpHandler {

public void ProcessRequest(HttpContext context)

{

string sTxt = BuildXmlString();

context.Response.ContentType = "text/xml";

context.Response.ContentEncoding = System.Text.Encoding.UTF8;

context.Response.Write(sTxt);

}

private string BuildXmlString()

{

string sTitle = "Super Value Deals and Deals of The Day";

string sSiteUrl = "http://www.cccc.com";

string sDescription = "Super Value Deals and Deals of The Day";

string sTTL = "60";

System.Text.StringBuilder oBuilder = new System.Text.StringBuilder();

oBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

oBuilder.Append("<rss version=\"2.0\"><channel>");

oBuilder.Append("<title>");

oBuilder.Append(sTitle);

oBuilder.Append("</title>");

oBuilder.Append("<link>");

oBuilder.Append(sSiteUrl);

oBuilder.Append("</link>");

oBuilder.Append("<description>");

oBuilder.Append(sDescription);

oBuilder.Append("</description>");

oBuilder.Append("<ttl>");

oBuilder.Append(sTTL);

oBuilder.Append("</ttl>");

AppendItems(oBuilder);

oBuilder.Append("</channel></rss>");

return oBuilder.ToString();

}

public void AppendItems(System.Text.StringBuilder oBuilder)

{

string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=c:\\sites\\Axxx.mdb";

OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);

OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();

string ProdTy = "M2";

string Strsql = "SELECT top 101 * from DetailUrl where ProdType='M2'";

myOleDbCommand.CommandText = Strsql;

myOleDbConnection.Open();

OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();

myOleDbDataReader.Read();

while (myOleDbDataReader.Read())

{

string sTitle = "Super Value Deals and Deals of The Day";

string sLink = "http://www.visli.com/";

string sDescription = "Super Value Deals and Deals of The Day";

string sPubDate = "System.DateTime.Now";

oBuilder.Append("<item>");

oBuilder.Append("<title>");

oBuilder.Append(myOleDbDataReader["TextUrl"].ToString());

oBuilder.Append("</title>");

oBuilder.Append("<link>");

oBuilder.Append(myOleDbDataReader["NameUrl"].ToString());

oBuilder.Append("</link>");

oBuilder.Append("<description>");

oBuilder.Append("&lt;img src=" + myOleDbDataReader["ImageUrl"].ToString() + "&gt;" + "&lt;br&gt;" + myOleDbDataReader["Price"].ToString() + "&lt;br&gt;visit &lt;a href=http://www.visli.com&gt;http://www.visli.com&lt;/a&gt;");

oBuilder.Append("</description>");

oBuilder.Append("<pubDate>");

oBuilder.Append(myOleDbDataReader["UpdDate"].ToString());

oBuilder.Append("</pubDate>");

oBuilder.Append("</item>");

}

}

public bool IsReusable {

get {

return false;

}

}

}

Wednesday, March 17, 2010

R10412 -Monthly Spreadsheet, some account are not displaying on the report

R10412 -Monthly Spreadsheet, some account are not displaying
 
See the account level detail field , if this is blank put your level of detail, that account balance will start displaying on that report.

Encrypt a QueryString

To encrypt our QueryString  we could do something like this:

string strValue = "yoursearch";
string strURL = "http://visli.com?search="     + encryptQueryString(strValue);
Response.Redirect(strURL);

Tuesday, March 16, 2010

Sales Override Calculations on GL Class Code

drop table jde_rk.dbo.temp_123
select  sdan8 Soldto,
DATEADD(dy, cast(SDTRDJ as varchar(10)) % 1000, DATEADD(yy, cast(SDTRDJ as varchar(10)) / 1000,-1)) OrdDate,
sddcto OrdTy,sddoco O#, sdglc GL,sdshan Shipto,rtrim(wwgnnm) +' '+wwsrnm "Owner Name",sdlitm I#,sddsc1 Dsc,sum(sdsoqs)Qty
,avg(cost02)Cost02,avg(cost21) Cost21,avg(cost25)Cost25,sum(cost02*sdsoqs) COGS,sum(cost21*sdsoqs) Sales,sum(cost25*sdsoqs)RBT,
(sum(cost21*sdsoqs)-sum(cost25*sdsoqs)) NetSale ,
Comm =case
when sdglc='PRCO'  then (sum(cost21*sdsoqs)-sum(cost25*sdsoqs))*.20
when sdglc='PRQU'  then (sum(cost21*sdsoqs)-sum(cost25*sdsoqs))*.20
when sdglc='PSFO'  then (sum(cost21*sdsoqs)-sum(cost25*sdsoqs))*.20
when sdglc='DDPR'  then (sum(cost21*sdsoqs)-sum(cost25*sdsoqs))*.25
when sdglc='LLEB'  then (sum(cost21*sdsoqs)-sum(cost25*sdsoqs))*.25
when sdglc='BBC4'  then (sum(cost21*sdsoqs)-sum(cost25*sdsoqs))*.25
else 0  end,
sdmcu,abalph shiptoname,'                           ' hubname,
dc1.edan82 dc1Add,avg(isnull(dc1.eduncs,0)/10000) DC1per,dc1.edalph dc1alph,
dc2.edan82 dc2Add,avg(isnull(dc2.eduncs,0)/10000) DC2per,dc2.edalph dc2alph,
dc3.edan82 dc3Add,avg(isnull(dc3.eduncs,0)/10000) DC3per,dc3.edalph dc3alph,
dc4.edan82 dc4Add,avg(isnull(dc4.eduncs,0)/10000) DC4per,dc4.edalph dc4alph,
dcvp.edan82 dcvpAdd,avg(isnull(dcvp.eduncs,0)/10000) DCvpper,dcvp.edalph dcvpalph,
dcnc.edan82 dcncAdd,avg(isnull(dcnc.eduncs,0)/10000) DCncper,dcnc.edalph dcncalph,
avg(isnull(dc1.eduncs,0)+isnull(dc2.eduncs,0)+isnull(dc3.eduncs,0)+isnull(dc4.eduncs,0)+isnull(dcvp.eduncs,0)+isnull(dcnc.eduncs,0))/10000 "OR Total"
into jde_rk.dbo.temp_123 from proddta.f4211
left outer join proddta.f0101 on sdshan=aban8
left outer join proddta.f0111 on sdshan=wwan8
left outer join proddta.F5542845 dc1 on dc1.edglc=sdglc and sdan8=dc1.edan81 and sdtrdj>=dc1.edeftb and sdtrdj<=dc1.edefte and rtrim(dc1.edast)='DC1' and sddcto=dc1.eddcto
left outer join proddta.F5542845 dc2 on dc2.edglc=sdglc and sdan8=dc2.edan81 and sdtrdj>=dc2.edeftb and sdtrdj<=dc2.edefte and rtrim(dc2.edast)='DC2' and sddcto=dc2.eddcto
left outer join proddta.F5542845 dc3 on dc3.edglc=sdglc and sdan8=dc3.edan81 and sdtrdj>=dc3.edeftb and sdtrdj<=dc3.edefte and rtrim(dc3.edast)='DC3' and sddcto=dc3.eddcto
left outer join proddta.F5542845 dc4 on dc4.edglc=sdglc and sdan8=dc4.edan81 and sdtrdj>=dc4.edeftb and sdtrdj<=dc4.edefte and rtrim(dc4.edast)='DC4' and sddcto=dc4.eddcto
left outer join proddta.F5542845 dcvp on dcvp.edglc=sdglc and sdan8=dcvp.edan81 and sdtrdj>=dcvp.edeftb and sdtrdj<=dcvp.edefte and rtrim(dcvp.edast)='DCVP' and sddcto=dcvp.eddcto
left outer join proddta.F5542845 dcnc on dcnc.edglc=sdglc and sdan8=dcnc.edan81 and sdtrdj>=dcnc.edeftb and sdtrdj<=dcnc.edefte and rtrim(dcnc.edast)='DCNC' and sddcto=dcnc.eddcto
left outer join vAllcostinRow on sdlitm=colitm and sdmcu=comcu
--left outer join zdev.dbo.hubmgr on sdshan=hubno
where  sdkcoo=600 and sdnxtr=999 and sdlttr<>980 and sdlnty='S'  and SDTRDJ>=110032 and SDTRDJ<=110059

group by sdtrdj,sddcto,sdglc,abac11,sdshan,abalph,sdlitm,sddsc1,wwgnnm,wwsrnm,sdmcu,sdan8--,hubname
,dc1.edan82,dc1.edalph,dc2.edan82,dc2.edalph,dc3.edan82,dc3.edalph,dc4.edan82,dc4.edalph,dcvp.edan82,
dcvp.edalph,dcnc.edan82,dcnc.edalph,sddoco


update jde_rk.dbo.temp_123 set hubname =isnull(b.hubname,'')
from jde_rk.dbo.temp_123
left outer join vHubmgr b on hubno=Soldto
select * from jde_rk.dbo.temp_123

Friday, March 12, 2010

Calculate Sales order details F4211 with Tax amount in JD Edwards

Calculate Sales order details F4211 with Tax amount in JD Edwards
 
alter view ABAddress as
select    aban8 ,abalph,rtrim(aladd1) address ,rtrim(alcty1) City, rtrim(aladds)State,rtrim(alctr)Country,aladdz from jde_production.proddta.f0101
left outer join jde_production.proddta.f0116 on aban8=alan8 and abeftb=aleftb
where aban8<>0
select  rpstam/100 rpstam,rpdoc into jde_rk.dbo.stxamt from proddta.f03b11
where rpdgj>=107060 and rpicut='IB' and rpdct='RI' and rpstam<>0

 

select  sddoc I#,sddoco O#,sdan8 Soldto,a.abalph Soldtoname,a.address Soldtoaddress,a.City SoTCity,a.state SoTsate,a.Country SoTCountry,
a.aladdz Soldtozip, sdshan Shipto,b.abalph Shiptonam, b.address ShiptoAdd,a.City ShTCity,b.state ShTsate,b.Country ShTCountry,
b.aladdz ShiptoZip,sdtxa1,
DATEADD(dy, cast(SDTRDJ as varchar(10)) % 1000, DATEADD(yy, cast(SDTRDJ as varchar(10)) / 1000,-1)) Orddate,
sum(sdaexp/100) sdaexp,avg(tatxr1/1000) tatxr1  --,sum(rpstam) Taxamt
into jde_rk.dbo.dffdf_1 from proddta.f4211
left outer join ABAddress a on sdan8=a.aban8
left outer join ABAddress b on sdshan=b.aban8
left outer join proddta.f4008 on ltrim(tatxa1)=ltrim(sdtxa1) and sdtrdj between  taeftj  and taefdj
--left outer join jde_rk.dbo.stxamt  on sddoc=rpdoc
where sdtrdj>=107060 and  sdtrdj<=109366
and sddcto in('SO','SA','SF','SR') and sdnxtr=999 and sdlttr<>980 and sdlnty='S'  and sddoc<>0
group by sddoc,sddoco,sdan8,a.abalph,a.address,a.aladdz, sdshan,b.abalph,b.address,b.aladdz,SDTRDJ,
a.City,a.state,a.Country ,b.City,b.state,b.Country ,sdtxa1

--drop table jde_rk.dbo.dffdf_1

select a.*,rpstam from jde_rk.dbo.dffdf_1 a
left outer join jde_rk.dbo.stxamt  on i#=rpdoc

 


 

Wednesday, March 10, 2010

window.close in c# code behind and passing value in parent window

Response.Write(

"<script language=\"Javascript\">window.opener.document.forms[0].submit(); self.close();window.close();</script>");

Page.ClientScript.RegisterStartupScript(

this.GetType(), "myCloseScript", "window.close()", true);

Window.open in code behind C#

Window.open in code behind C#

        winFeatures = "toolbar=no,status=no,menubar=no,location=center,scrollbars=no,resizable=no,height=500,width=657";
         ClientScript.RegisterStartupScript(this.GetType(), "newWindow", String.Format("<script>window.open('{0}');</script>", ("URL"), winFeatures));

Change autogenerateeditbutton text Asp.net

<

Columns>

<asp:commandfield ShowEditButton="True" EditText="Whatever"></asp:commandfield>
<asp:commandfield ShowSelectButton="true" EditText="Save"></asp:commandfield>
 
.
.
.
.
.
</Columns>

Logging execution time using AOP - CodeProject

Logging execution time using AOP - CodeProject

A Full Yahoo! Weather App,

A Full Yahoo! Weather App, Yes Another One - CodeProject

Tuesday, March 9, 2010

HTTP Push from SQL Server — Comet SQL

This article present how to implement functionality for presenting so-called real-time data using ASP.NET and SQL Server. This functionality is realized by implementing Comet functionality in ASP.NET and connecting this with Query Notification from SQL Server.
 
 
 

Monday, March 8, 2010

Populate GridView using stored proc. Sql-server C#

 Populate GridView using stored proc. Sql-server  C#, input from screen textbox.
 
 
private void PopulateGridView()

{

Button1.Visible = true;

Button3.Visible = true;

SqlConnection myConnection = new SqlConnection(ConnectionString);

String strSQL;

String strOwner;

strOwner = DropDownList1.SelectedItem.Text;

if (strOwner == "*" || strOwner == "")

{

strSQL = "ovfinrepFULL '" + TextBox1.Text + "' , '" + TextBox2.Text + "'";

}

else

{

strSQL =

"ovfinrepFULL '" + TextBox1.Text + "' , '" + TextBox2.Text + "','" + DropDownList1.SelectedItem.Text + "'";

}

//Response.Write(strSQL);

//Response.End();

SqlDataAdapter ad = new SqlDataAdapter(strSQL, myConnection);

DataSet ds = new DataSet();

ad.Fill(ds);

MyGridView.DataSource = ds;

MyGridView.DataBind();

}

Friday, March 5, 2010

Date Format Gridview

DataFormatString
="{0:MM/dd/yyyy}"
 
Sample field...

<

asp:BoundField DataField="ETD" HeaderText="ETD"

SortExpression="ETD" ReadOnly="True" ItemStyle-Wrap="false" DataFormatString="{0:MM/dd/yyyy}"/>

Wednesday, March 3, 2010

JD Edwards Fixing M batch in Error - Invalid Parameters

JD Edwards Fixing M - manual batch in Error - Invalid Parameters
 
 
My CFO forworded a batch not able to post. I found its a Manual payment batch with mixed company foreign(F) and domestic(D) , I was getting error in work center invalid parameters. In order to fix this I used SQL and changed Domestic currancy as posted. in file F0413 field RMISTP to D, and all the entries for this payment id I changed RNPOST field to D in F0414. After that I posted this batch again its worked fine and half of the enteries posted and I can see records in F0911 file. After that I changed back Domestic currency line , in F0414 RNpost field to P and F0413 RMISTP to D and posted again, all entries posted in JD EDWARDS.