Program

Standar

Web config

<connectionStrings>

<add name=”coninv” connectionString=”Data Source=saTDMG-DBM05;Initial Catalog=calloutbound;User;Password=Indosat2008″ providerName=”System.Data.SqlClient”/>

</connectionStrings>

<authentication mode=”Forms”>

<forms defaultUrl=”default.aspx” loginUrl=”login.aspx” name=”apaaja” protection=”All”></forms>

</authentication>

<authorization>

      <deny users=”?”/>

      <allow users=”*”/>

</authorization>

Login.aspx

<asp:Label ID=”Label1″ runat=”server” Text=””></asp:Label>

<table>

<tr>

  <td>Username</td>

  <td>

      <asp:TextBox ID=”txtuser” runat=”server”></asp:TextBox>

  </td>

</tr>

<tr>

  <td>Password</td>

  <td>

<asp:TextBox ID=”txtpass” TextMode=”Password” runat=”server”>  </asp:TextBox>

  </td>

</tr>

<tr>

   <td></td>

   <td>

<asp:Button ID=”Button1″ runat=”server” Text=”Ok”   onclick=”Button1_Click” />

      <asp:Button ID=”Button2″ runat=”server” Text=”Cancel” />

   </td>

</tr>

</table>

Login.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data.SqlClient;

using System.IO;

using System.Configuration;

using System.Web.Security;

using System.Data;

public partial class login : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    protected void Button1_Click(object sender, EventArgs e)

    {

     SqlConnection coninv = new SqlConnection(ConfigurationManager.ConnectionStrings[“coninv”].ConnectionString);

     try

     {

       coninv.Open();

SqlCommand cmd = new SqlCommand(“select * from tb_user where nik='” + txtuser.Text + “‘ and user_pass='” + txtpass.Text + “‘ and status=’0′”, coninv);

        SqlDataReader rdr = cmd.ExecuteReader();

        if (rdr.Read())

        {              

        FormsAuthenticationTicket authTicket =

        new FormsAuthenticationTicket(1, // version

txtuser.Text + “-” + rdr[“username”] + “-” + rdr[“user_priv”]  + “-” + rdr[“id_user”] + “-” + rdr[“region”],

        DateTime.Now,

        DateTime.Now.AddMinutes(Session.Timeout), false, txtpass.Text);                   

        string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

        HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

        Response.Cookies.Add(authCookie);         

        Response.Redirect(FormsAuthentication.GetRedirectUrl(txtuser.Text, false));                       

        }

        else

        {

                Label1.Text = “username tdk dapat mengakses”;

        }

      }

      catch (Exception ex)

      {

            if (coninv.State == ConnectionState.Open)

            {

                Label1.Text = ex.Message;

                coninv.Close();

            }

      }

    }

}

Home.aspx

<asp:Label ID=”Label1″ runat=”server” Text=””></asp:Label>

<asp:LinkButton ID=”LinkButton1″ runat=”server” OnClick=”log”>Logout</asp:LinkButton>

<table>

  <tr>

      <td>MSISDN</td>

      <td><asp:TextBox ID=”txtmsisdn” runat=”server”></asp:TextBox></td>           

  </tr>

  <tr>

      <td>Nama</td>

      <td><asp:TextBox ID=”txtnama” runat=”server”></asp:TextBox></td>

  </tr>

   <tr>

      <td>Program</td>

<td><asp:DropDownList ID=”ddlprog” AppendDataBoundItems=”true” runat=”server” DataSourceID=”SqlDataSource1″ DataTextField=”nama” DataValueField=”id_prog”>

          <asp:ListItem Value=”” Text=””>–</asp:ListItem>

          </asp:DropDownList>

          <asp:SqlDataSource ID=”SqlDataSource1″ runat=”server” ConnectionString=”<%$ ConnectionStrings:coninv%>”

          SelectCommand=”SELECT * FROM [tb_progname]”></asp:SqlDataSource>

       </td>

   </tr>    

   <tr>

       <td></td>

       <td><asp:Button ID=”btnsearch” runat=”server” Text=”Search” onclick=”btnsearch_Click” /></td>

   </tr>

  </table>

  <table>

   <tr>

       <td><asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”false”>

            <Columns>

            <asp:TemplateField>

           <HeaderTemplate>No</HeaderTemplate>

           <ItemTemplate>

           <%# Container.DataItemIndex +1 %>

           </ItemTemplate>

            </asp:TemplateField>

            <asp:BoundField HeaderText=”MSISDN” SortExpression=”MSISDN” DataField=”MSISDN” />

            <asp:BoundField HeaderText=”NAMA” SortExpression=”NAMA” DataField=”NAMA” />

            <asp:TemplateField>

            <HeaderTemplate>Ket</HeaderTemplate>

            <ItemTemplate>

<asp:ImageButton ID=”edit” OnClick=”edit” CommandArgument='<%# Bind(“id_jwb”) %>’ runat=”server” ToolTip=”detail” />

<asp:ImageButton ID=”del” OnClick=”del” CommandArgument='<%# Bind(“id_jwb”) %>’ runat=”server” ToolTip=”detail” />

            </ItemTemplate>

            </asp:TemplateField>           

            </Columns>           

            </asp:GridView>

        </td>

    </tr>

</table>

Home.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

using System.IO;

using System.Configuration;

using System.Web.Security;

public partial class home : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        Label1.Text = “sukses”;

    }

    protected void log(object sender, EventArgs e)

    {

        Response.Redirect(“logout.aspx”);

    }

    protected void edit(object sender, EventArgs e)

    {

        Response.Redirect(“edit.aspx?id_jwb= ” + ((ImageButton)sender).CommandArgument);

    }

    protected void del(object sender, EventArgs e)

    {

    }

    protected void btnsearch_Click(object sender, EventArgs e)

    {

    SqlConnection coninv = new SqlConnection(ConfigurationManager.ConnectionStrings[“coninv”].ConnectionString);

    try

    {

      string strsearch;

strsearch = “select a.msisdn,a.nama,a.id_prog,a.id_jwb from tb_jwbmentari a, tb_mentari b where a.status=’0′ and a.id_call=b.id_call “;

            if (txtmsisdn.Text != “”)

            {

                strsearch += ” and a.msisdn='” +txtmsisdn.Text +”‘”;

            }

            if (txtnama.Text !=””)

            {

                strsearch += ” and b.nama='”+txtnama.Text+”‘”;

            }

            if (ddlprog.SelectedValue != “”)

            {

                strsearch += ” and a.id_prog='”+ddlprog.SelectedValue+”‘”;

            }

            DataSet _ds = new DataSet();

            SqlDataAdapter ODA = new SqlDataAdapter(new SqlCommand(strsearch, coninv));

            ODA.Fill(_ds);

            GridView1.DataSource = _ds.Tables[0];

            GridView1.DataBind();           

     }

     catch (Exception ex)

     {

        if (coninv.State == ConnectionState.Open)

            {

                Label1.Text = ex.Message;

            }

     }

   }

}

Logout.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

using System.IO;

using System.Configuration;

using System.Web.Security;

public partial class logout : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        Session.Abandon();

        FormsAuthentication.SignOut();

        Response.Redirect(“login.aspx”);       

    }

}

Edit.aspx

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

<%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”cc1″ %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head runat=”server”>

    <title></title>

</head>

<body>

    <form id=”form1″ runat=”server”>

    <asp:ScriptManager ID=”ScriptManager1″ runat=”server”>

    </asp:ScriptManager>

    <div>

        <asp:Label ID=”Label1″ runat=”server” Text=”Label”></asp:Label>

        <asp:HiddenField ID=”HiddenField1″ runat=”server” />

    <table>

    <tr>

    <td>MSISDN</td>

    <td>

        <asp:TextBox ID=”txtmsisdn” runat=”server”></asp:TextBox></td>

    </tr>

    <tr>

    <td>Nama</td>

    <td>

        <asp:TextBox ID=”txtnama” runat=”server”></asp:TextBox></td>

    </tr>

    <tr>

    <td>Tanggal delivery</td>

    <td>

        <asp:TextBox ID=”txttgl” runat=”server”></asp:TextBox>

<cc1:MaskedEditExtender ID=”MaskedEditExtender1″ runat=”server” Mask=”99/99/9999″ MaskType=”Date”   TargetControlID=”txttgl”>

        </cc1:MaskedEditExtender>

        <cc1:CalendarExtender ID=”CalendarExtender1″ runat=”server” Format=”dd/MM/yyyy” TargetControlID=”txttgl” PopupButtonID=”txttgl”>

        </cc1:CalendarExtender>

    </td>

    </tr>

    <tr>

    <td>Program</td>

    <td>

        <asp:DropDownList ID=”ddlprog” runat=”server” DataSourceID=”SqlDataSource1″ DataTextField=”nama” DataValueField=”id_prog”>

        </asp:DropDownList>

        <asp:SqlDataSource ID=”SqlDataSource1″ runat=”server”

            ConnectionString=”<%$ ConnectionStrings:coninv %>”

            SelectCommand=”SELECT * FROM [tb_progname] WHERE ([Status] = @Status)”>

            <SelectParameters>

                <asp:Parameter DefaultValue=”0″ Name=”Status” Type=”String” />

            </SelectParameters>

        </asp:SqlDataSource>

    </td>

    </tr>

    <tr>

    <td></td>

    <td>

        <asp:Button ID=”Button1″ runat=”server” Text=”ok” onclick=”Button1_Click” /></td>

    </tr>

    </table>

        <asp:GridView ID=”GridView1″ runat=”server”>

        </asp:GridView>

    </div>

    </form>

</body>

</html>

Edit.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data.SqlClient;

using System.IO;

using System.Configuration;

using System.Data;

using System.Web.Security;

public partial class edit : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            HiddenField1.Value = Request.QueryString[“id_jwb”];

            goview();

        }

    }

    private void goview()

    {

    SqlConnection coninv = new SqlConnection(ConfigurationManager.ConnectionStrings[“coninv”].ConnectionString);

        try

        {

            coninv.Open();

SqlCommand cmd = new SqlCommand(“select a.msisdn,a.nama,a.id_prog,a.id_jwb,convert(varchar,a.tgl_delivery,103) as tgl_delivery from tb_jwbmentari a, tb_mentari b where a.status=’0’ and a.id_call=b.id_call and a.id_jwb=”+HiddenField1.Value+””, coninv);

            SqlDataReader rdr = cmd.ExecuteReader();

            if (rdr.Read())

            {

                txtmsisdn.Text = rdr[“msisdn”].ToString();

                txtnama.Text = rdr[“nama”].ToString();

                txttgl.Text = rdr[“tgl_delivery”].ToString();

                ddlprog.DataBind();

                ddlprog.SelectedValue = rdr[“id_prog”].ToString();

            }

            gohist();

        }

        catch (Exception ex)

        {

            if (coninv.State == ConnectionState.Open)

            {

                Label1.Text = ex.Message;

            }

        }

    }

    private void gohist()

    {

    SqlConnection coninv = new SqlConnection(ConfigurationManager.ConnectionStrings[“coninv”].ConnectionString);

        try

        {

            coninv.Open();

            string str;

            str =”select * from tb_log where msisdn='”+txtmsisdn.Text+”‘”;

            DataSet _DS=new DataSet();

            SqlDataAdapter ODA=new SqlDataAdapter(new SqlCommand(str,coninv));

            ODA.Fill(_DS);

            GridView1.DataSource=_DS.Tables[0];

            GridView1.DataBind();

        }

        catch (Exception ex)

        {

            if (coninv.State == ConnectionState.Open)

            {

                Label1.Text = ex.Message;

            }

        }

    }

    protected void Button1_Click(object sender, EventArgs e)

    {

    SqlConnection coninv = new SqlConnection(ConfigurationManager.ConnectionStrings[“coninv”].ConnectionString);

        try

        {

            coninv.Open();

            string str;

str= “update tb_jwbmentari set tgl_delivery=(convert(datetime,'”+txttgl.Text+”‘,103)) where id_jwb=”+HiddenField1.Value+””;

            SqlCommand cmd = new SqlCommand(str, coninv);

            cmd.ExecuteNonQuery();

        }

       catch (Exception ex)

        {

            if (coninv.State == ConnectionState.Open)

                Label1.Text = ex.Message;

            coninv.Close();

       }

        Response.Redirect(“home.aspx”);

    }

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s