Tuesday, June 29, 2010

Retrieve Client Date time using asp.net, C#

Get Client side date and time using asp.net C# code behind.
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
   
<form id="theForm" runat="server">

<div align="center">

   <input type="hidden"  name="cltOffset" id="cltOffset" runat="server" />

  

</div>
    </form>
</body>
</html>


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class Default6 : System.Web.UI.Page
{
    DateTime utcDate, localDate;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // set startup script to get client utc offset
            string sname = "getClientUtcOffset";
            Type stype = this.GetType();
            string sliteral = "var now = new Date ( );";
            sliteral += "document.theForm.cltOffset.value = now.getTimezoneOffset ( ) / 60 * ( -1 );";
            sliteral += "document.theForm.submit ( );";

            // register startup script
            ClientScriptManager cs = Page.ClientScript;
            if (!cs.IsStartupScriptRegistered(sname))
                cs.RegisterStartupScript(stype, sname, sliteral, true);
        }
        // get server time zone and utc date
        utcDate = TimeZone.CurrentTimeZone.ToUniversalTime(DateTime.Now);
        // set client date based on utc + offset
        localDate = utcDate.AddHours(Convert.ToInt32(Request.Form["cltOffset"])); ;
        //Response.Write(cltOffset.Value +"<br>");
        Response.Write(localDate.ToString());
    
    }

}

Thursday, June 24, 2010

Finding and fixing out of balance Account# for a company and fixing in JD Edwards

Finding and fixing out of balance Account#  for a company and fixing in JD Edwards

drop table jde_rk.dbo.outb0911
select glsbl,glaid,sum(glaa)glaa into jde_rk.dbo.outb0911 from proddta.f0911
where glco=860 and glfy=9 and glpn=10 and gllt='AA'and glaa<>0
group by glsbl,glaid

drop table jde_rk.dbo.outb0902
select sum(gban10)gban10,gbsbl,gbaid into jde_rk.dbo.outb0902
from proddta.f0902 where gbfy=9 and gbco=860 and gban10<>0 and gblt='AA'
group by gbsbl,gbaid

 


select * from jde_rk.dbo.outb0902
left outer join jde_rk.dbo.outb0911  on glsbl=gbsbl and glaid=gbaid
where gban10<>glaa

I found 2 account and  reposted them by using Program R099102

Wednesday, June 23, 2010

Convert Getdate() to julian date for JD Edwards


select  (datepart(yy,getdate()) - 1900) * 1000+ cast(datepart(dy,getdate()) as int)

Tuesday, June 22, 2010

Send Email Using SQL-Server 2005

Send Email Using SQL-Server 2005
 
Execute following stored proc:
 
Step 1
use master
go
sp_configure 'show advanced options',1
go
reconfigure with override
go
sp_configure 'Database Mail XPs',1
go
reconfigure
go

Step 2

EXECUTE msdb.dbo.sysmail_add_account_sp
    @account_name = 'RajeevailAccount',
    @description = 'Mail account for Database Mail',
    @email_address = 'makclaire@optonline.net',
    @display_name = 'MyAccount',
 @username='xxxx@xxxxx.net',
 @password='xxxxx',
    @mailserver_name = 'mail.xxxxxx.net'

Step 3
Send Email:-
EXEC msdb.dbo.sp_send_dbmail
@recipients=N'xxxxxxx@gmail.com',@body='Test Message Body',
@sensitivity ='Personal',
@importance ='High' ,
@copy_recipients ='yyyyyykum@gmail.com',@subject ='Test Message Subject',
@profile_name ='RajeevailAccount';

Friday, June 18, 2010

How to Quickly Fix a Picture's Color and Brightness in Adobe Photoshop Cs2 - wikiHow

How to Quickly Fix a Picture's Color and Brightness in Adobe Photoshop Cs2 - wikiHow

What is Service Broker? Sql-server

What is Service Broker?
 
Service Broker is a message‐queuing technology in SQL Server that allows developers to integrate SQL Server fully into distributed 
applications. Service Broker is feature which provides facility to SQL Server to send an asynchronous, transactional message. 
It allows a database to send a message to another database without waiting for the response, 
So that application will continue to function if the remote database is temporarily unavailable. 

Wednesday, June 16, 2010

Security Configuration Wizard Windows server 2003

Security Configuration Wizard

The Security Configuration Wizard (SCW) is a new tool that is available with the installation of Windows Server 2003 Service Pack (SP)1.  The SCW reduces the attack surface of Microsoft Windows 2003 Servers by guiding an authorized administrator through a series of questions designed to determine the functional requirements of a server.  Any service functionality that is not required, by the roles being performed by the server, is then disabled.  This provides greater security for the server by eliminating the potential of those services being used as an avenue of attack.



Tuesday, June 15, 2010

Can the JD Edwards Job Number be retrieved at runtime?

The job number cannot be retrieved at run time.  The assignment of the job number happens at the kernel code level and the functionality does not exist to retrieve this job number through event rules.  

Wednesday, June 9, 2010

Load Checkbox from database asp.net 3.5 c# sql-server

Load Checkbox from database asp.net 3.5 c# sql-server

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="chkbx.aspx.cs" Inherits="chkbx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 25%;
        }
    </style>
</head>
<body text="dssdds">
    <form id="form1" runat="server">
    <div>
   
        <table align="center" class="style1">
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:DropDownList ID="DropDownList1" runat="server"
                        DataSourceID="SqlDataSource1" DataTextField="co" DataValueField="co">
                    </asp:DropDownList>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                        ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
                        SelectCommand="SELECT [co] FROM [boconn]"></asp:SqlDataSource>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox1" runat="server" Text="Media1"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox2" runat="server" Text="Media1 Date"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox3" runat="server" Text="Media3"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox4" runat="server" Text="Media3 Date"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox5" runat="server" Text="Boxes"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox61" runat="server" Text="Cryosettes"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox6" runat="server" Text="50ml Tubes"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox7" runat="server" Text="Gel Packs"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox8" runat="server" Text="Media Labels"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox9" runat="server" Text="Procurment Forms"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox10" runat="server" Text="Consent Forms"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox11" runat="server" Text="Last LN2 fill"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox12" runat="server" Text="Next LN2 fill"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox13" runat="server" Text="Fedex Forms"  />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
   
    </div>
    </form>
</body>
</html>

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class chkbx : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
         CheckBox1.Checked =false;
         CheckBox2.Checked = false;
         CheckBox3.Checked = false;
         CheckBox4.Checked = false;
         CheckBox5.Checked = false;
         CheckBox6.Checked = false;
         CheckBox61.Checked = false;
         CheckBox7.Checked = false;
         CheckBox8.Checked = false;
         CheckBox9.Checked = false;
         CheckBox10.Checked = false;
         CheckBox11.Checked = false;
         CheckBox12.Checked = false;
         CheckBox13.Checked = false;
//Load Data
        loadchkdata();
    }

    void loadchkdata()
    {
        string strSQL;
        SqlConnection myConnection = new SqlConnection(ConnectionString);
        strSQL = "select * FROM BOVBFL WHERE VBFLT='" + DropDownList1.SelectedItem.Text +"'";
        SqlCommand cmd = new SqlCommand(strSQL, myConnection);
        myConnection.Open();
        SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        while (myReader.Read())
        {
            if (myReader["VBROWS"].ToString() == "media1tr")
            {
                CheckBox1.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "media1datetr")
            {
                CheckBox2.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "Media3")
            {
                CheckBox3.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "media3datetr")
            {
                CheckBox4.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "Boxestr")
            {
                CheckBox5.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "Cryosettes")
            {
                CheckBox61.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "qutytr")
            {
                CheckBox6.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "GelPackstr")
            {
                CheckBox7.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "mediaTr")
            {
                CheckBox8.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "Procurmenttr")
            {
                CheckBox9.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "Consenttr")
            {
                CheckBox10.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "Fedextr")
            {
                CheckBox13.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "lnfilltr")
            {
                CheckBox11.Checked = true;
            }
            if (myReader["VBROWS"].ToString() == "shipfozenstr")
            {
                CheckBox12.Checked = true;
            }
  
        }

        myReader.Close();
        myConnection.Close();
    }

    private string ConnectionString
    {
        get
        {
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
            return connectionString;
        }
    }

}

Friday, June 4, 2010

Hide AutoGenerateDeleteButton

Hide Auto Generated Delete Button
 
this
.GridView1.AutoGenerateDeleteButton = false;

Create your countdown clock using asp.net ,ajax,c#

Date time calculation , Create your countdown clock using asp.net ,ajax,c#, format TimeSpan etc.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="cloc.aspx.cs" Inherits="cloc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" language="JavaScript">

            function DisplayDynamicClock()
            {
                setInterval("__doPostBack('upDynamicClock', '');", 1000);
            }
            window.onload = DisplayDynamicClock;
   
    </script>
</head>
<body>
    <form id="form1" runat="server">
   

<asp:ScriptManager ID="smDynamicClock" runat="server" />

<div style="font-family: Trebuchet MS;">

<asp:UpdatePanel runat="server" ID="upDynamicClock" >
    <ContentTemplate>

        <strong>Current Date and Time is:</strong>
        <asp:Label ForeColor="Red" runat="server" ID="lblDynamicClock" />
        <br />
        <asp:Label ID="Label2" runat="server" Text="Compare To:"></asp:Label>
        <asp:TextBox ID="TextBox2" runat="server">5/4/2010 11:01:25 AM</asp:TextBox>
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </ContentTemplate>
</asp:UpdatePanel>

</div>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class cloc : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime fdat;
        lblDynamicClock.Text = DateTime.Now.ToString();
        fdat = Convert.ToDateTime(TextBox2.Text);
        DateTime dt1 = DateTime.Now;
        DateTime dt2 =  Convert.ToDateTime(TextBox2.Text);
        TimeSpan ts = dt1.Subtract(dt2);
        Label1.Text = "Days:-" + (int)ts.Days + "<br/>Hours:-" + (int)ts.Hours + "<br/>Mins:-" + (int)ts.Minutes + "<br/>Seconds:-" + ts.Seconds;
     

    }
}

Thursday, June 3, 2010

Upload file to server from webpage using C# asp.net 3.5

Upload file to server from webpage using C# asp.net 3.5

The folder you want to upload you have to have permmission to read/write


using System;
using System.Data;
using System.Configuration;
using System.Collections;
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="uploadfile.aspx.cs" Inherits="uploadfile" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table style="width:50%;"  align="center">
            <tr>
                <td>
                </td>
                <td align="center">
                    <br />
                    <br />
                    <asp:Label ID="Label2" runat="server"></asp:Label></td>
            </tr>
            <tr>
                <td align="right" valign="top">  
                    <asp:Label ID="Label3" runat="server" Text="Select a File to Upload:"></asp:Label>
                    &nbsp;
                    </td>
                <td align="left" >
                    <asp:FileUpLoad id="FileUpLoad1" runat="server" Height="24px" Width="209px" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <br />
                        </td>
            </tr>
            <tr>
                <td align="right" valign="top">  
                    <asp:Label ID="Label4" runat="server" Text="File Description:"></asp:Label>
                    </td>
                <td align="left" >
                    <asp:TextBox ID="TextBox1" runat="server" Width="120px"></asp:TextBox>
                    <asp:Button id="UploadBtn" Text="Upload File" OnClick="UploadBtn_Click"
                        runat="server" Width="78px" />

                </td>
            </tr>
            <tr>
                <td align="right" valign="top">   &nbsp;</td>
                <td align="center" >
                        <asp:Label ID="Label1" runat="server" Width="416px"></asp:Label></td>
            </tr>
            </table>
             <table style="width: 81%; " align="center">
            <tr>
                <td>
                </td>
                <td align="center" >
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                            CellPadding="4" DataSourceID="SqlDataSource1"   DataKeyNames="FLID"
                            ForeColor="#333333" GridLines="None" AutoGenerateDeleteButton="true">
                            <RowStyle BackColor="#EFF3FB" />
                            <Columns>
                            <asp:BoundField DataField="FLID" HeaderText="Id"
                                    SortExpression="FLID" />
                            <asp:BoundField DataField="FLDESC" HeaderText="Description"
                                    SortExpression="FLDESC" />
                                <asp:BoundField DataField="FLFOLDER" HeaderText="Folder"
                                    SortExpression="FLFOLDER"  Visible="false"/>
                                <asp:BoundField DataField="FLNAME" HeaderText="Name"
                                    SortExpression="FLNAME" />
                                <asp:BoundField DataField="FLTYPE" HeaderText="Type"
                                    SortExpression="FLTYPE" />
                                <asp:BoundField DataField="FLDATCR" HeaderText="Date"
                                    SortExpression="FLDATCR" />
                                    <asp:BoundField DataField="FLCO" HeaderText="CO"
                                    SortExpression="FLCO" />
                                     <asp:HyperLinkField  DataNavigateUrlFields="FLNAME"  DataNavigateUrlFormatString="files/{0}"  DataTextField="FLNAME"  HeaderText="Download&nbsp;&nbsp;" />
                            </Columns>
                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#2461BF" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                            ConnectionString="<%$ ConnectionStrings:JDE_RKConnectionString3 %>"
                           
                             DeleteCommand="delete FROM [BOFLUPD] where FLID=@FLID" >
                             <SelectParameters>
                                <asp:SessionParameter Name="FLCO" SessionField="Usrcop" Type="String" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <br />
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    &nbsp; &nbsp; &nbsp;
                </td>
            </tr>
        </table>
</asp:Content>

 


using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using System.Data.Common;


public partial class uploadfile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Usrcop"].ToString() == "ALL")
        {
              SqlDataSource1.SelectCommand = "SELECT  * FROM BOFLUPD";
        }
        else
        {
            SqlDataSource1.SelectCommand = "SELECT  * FROM BOFLUPD WHERE  FLCO='" + Session["Usrcop"].ToString() + "'";
        }
    }

    protected void UploadBtn_Click(object sender, EventArgs e)
    {
        if (FileUpLoad1.HasFile)
        {
            string filePath = FileUpLoad1.PostedFile.FileName;
            string FileType = FileUpLoad1.PostedFile.ContentType;
            //FileUpLoad1.SaveAs(@"C:\\sites\\Single15\\visli\\database\\files\\" + FileUpLoad1.FileName);
            string fn = System.IO.Path.GetFileName(FileUpLoad1.PostedFile.FileName);
            string SaveLocation = Server.MapPath("files") + "\\" + fn;
            try
            {
                FileUpLoad1.PostedFile.SaveAs(SaveLocation);
                // "F"+"-"+DateTime.Now.ToShortTimeString()+"-"+
                Label1.Text = "The file has been uploaded.";
                insFileName(FileUpLoad1.FileName, FileType);
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.Message);
                //Note: Exception.Message returns a detailed message that describes the current exception.
                //For security reasons, we do not recommend that you return Exception.Message to end users in
                //production environments. It would be better to put a generic error message.
            }

        }
    }

    void insFileName(string FileName, string FileType)
    {

        SqlConnection myConnection = new SqlConnection(ConnectionString);
        string strSQL;
        string FileFolder = "http://localhost/bioprj/files/" + FileName;
        strSQL = "insert into BOFLUPD(FLFOLDER,FLNAME,FLTYPE,FLDATCR,FLDESC,FLCO)values(@FLFOLDER,@FLNAME,@FLTYPE,@FLDATCR,@FLDESC,@FLCO)";
        SqlCommand cmd = new SqlCommand(strSQL, myConnection);
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@FLFOLDER", FileFolder);
        cmd.Parameters.AddWithValue("@FLNAME", FileName);
        cmd.Parameters.AddWithValue("@FLTYPE", FileType);
        cmd.Parameters.AddWithValue("@FLDATCR", DateTime.Now.ToShortDateString());
        cmd.Parameters.AddWithValue("@FLDESC", TextBox1.Text);
        cmd.Parameters.AddWithValue("@FLCO", Session["Usrcop"].ToString());
      

        myConnection.Open();
        cmd.ExecuteNonQuery();
        myConnection.Close();
        Label1.Text = "Added..";
        Response.Redirect("uploadfile.aspx");
    }

 

    private string ConnectionString
    {
        get
        {
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
            return connectionString;
        }
    }
}