Forum

Hatalı paylaşım
 
Bildirimler
Hepsini Temizle

Hatalı paylaşım

1 Yazılar
1 Üyeler
0 Likes
252 Görüntüleme
(@Anonim)
Gönderiler: 0
Konu başlatıcı
 

paylaşılan kod telif hakkı gerektiriyor.

Forum: Nebim Yazılım Programları
Gönderilen:Mar 29, 1:32 [GMT 2]
Mesaj konusu: [url="/forums/post/163367.aspx"]Cevap : Nebim Winner da Iphone Benzeri Cep Telefonunda Mağaza Cirolarını Görebilirmiyim.[/url]
Mesaj yazarı[url="/members/volkan2010.aspx"]volkan2010[/url]


Asp ile Yapılmış Web Ciro Elime Geçti Server İle Bağlantı Da Kurdum Fakat Cirolar Sıfır Olarak Çıktı.


 ----webfoırm.aspx içeriği----


<%@ Page Language="C#" Debug="true"%>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


<script runat="server">


    public string serverip = "";
    public string database = "";
    public string DepoTipleri = "";
    public int StokUzunlugu = 0;
   


    protected void Page_Load(object sender, EventArgs e)
    {


        if (!IsPostBack)
        {
            System.IO.StreamReader Txt = new System.IO.StreamReader(Server.MapPath("server.txt"));
            serverip = Txt.ReadLine();
            database = Txt.ReadLine();
            DepoTipleri = Txt.ReadLine();
            StokUzunlugu = Convert.ToInt32(Txt.ReadLine());
           
            Txt.Close();
           
            Txt = null;
            dteTarih.Text = DateTime.Today.ToString("dd/MM/yyyy");
            Response.Cookies["txtUser"].Value = "";
            Response.Cookies["txtPass"].Value = "";
        }
        else
        {
            pnlVeri.Visible = true;
            pnlLogin.Visible = false;
        }
       


    }


   
    protected void SetYenile(object sender, EventArgs e)
    {
        try
        {
            if (serverip == "")
            {
                System.IO.StreamReader Txt = new System.IO.StreamReader(Server.MapPath("server.txt"));
                serverip = Txt.ReadLine();
                database = Txt.ReadLine();
                DepoTipleri = Txt.ReadLine();
                StokUzunlugu = Convert.ToInt32(Txt.ReadLine());
                Txt.Close();
               
                Txt = null;
            }
            SqlConnection db = new SqlConnection("Application Name=WebCiroSorgulama;Data Source=" + serverip + ";initial catalog=" + database + ";user id=" + Request.Cookies["txtUser"].Value + ";Password=" + Request.Cookies["txtPass"].Value + ";");
            db.Open();
            string SqlConnect = "select " + (StokUzunlugu == 0 ? "sAciklama" : "sAciklama=Substring(sAciklama, 1, " + StokUzunlugu.ToString() + ")") + " , Adet, Ciro from (select sAciklama=ltrim(rtrim(substring(tbDepo.sAciklama,charindex('/', tbDepo.sAciklama)+1,60))), sum(lToplamMiktar) as Adet, Sum(lNetTutar) As [Ciro] from tbAlisVeris, \n";
            SqlConnect += " tbDepo  where  sFisTipi  not in ('CP','KA','PC','PP') And  tbDepo.sDepo=tbAlisVeris.sMagaza And " + (DepoTipleri == "" ? "1=1" : "tbDepo.sDepoTipi in(" + DepoTipleri + ")") + "  \n";
           
                if (dteTarih.Text != "")
                    SqlConnect += "And dteFaturaTarihi='" + dteTarih.Text + "' \n";
                else
                    SqlConnect += "And dteFaturaTarihi=cast(convert(char(10), getDate(), 103) as smalldatetime) \n";
                SqlConnect += "group by tbDepo.sAciklama) as tbTemp order by sAciklama compute sum(Adet), sum(Ciro)\n";
                DataSet dt = new DataSet();
            SqlDataAdapter rs = new SqlDataAdapter(SqlConnect, db);
            rs.SelectCommand.CommandTimeout = 0;
            rs.Fill(dt);
            if (dt.Tables[1].Rows[0][0] == DBNull.Value)
                {
                    Session["cMiktar"] = 0;
                    Session["cTutar"] = 0;
           
                }
                else
                {
                    Session["cMiktar"] = dt.Tables[1].Rows[0][0];
                    Session["cTutar"] = dt.Tables[1].Rows[0][1];
     
                }
            grdMain.CurrentPageIndex = 0;
            grdMain.DataSource = dt.Tables[0];
            grdMain.DataBind();
            db.Close();
            db = null;
        }
        catch (Exception ex)
        {
            pnlVeri.Visible = false;
            pnlLogin.Visible = false;
            Response.Write(ex.Message + "<br><a href='WebForm.aspx'>Giris Sayfasi</a>");
        }


    }


    protected void SortChanged(object sender, DataGridSortCommandEventArgs e)
    {
        string Sorting = "";
        if (e.SortExpression.IndexOf("sAciklama") > -1)
        {
            if (Session["SortMagaza"] == null)
                Session["SortMagaza"] = "DESC";
            else
            {
                if(Session["SortMagaza"].ToString() == "DESC")
                    Session["SortMagaza"] = "ASC";
                else
                    Session["SortMagaza"] = "DESC";
            }
            Sorting = " order by sAciklama " + Session["SortMagaza"].ToString();
        }
        if (e.SortExpression.IndexOf("Adet") > -1)
        {
            if (Session["SortAdet"] == null)
                Session["SortAdet"] = "DESC";
            else
            {
                if (Session["SortAdet"].ToString() == "DESC")
                    Session["SortAdet"] = "ASC";
                else
                    Session["SortAdet"] = "DESC";
            }
            Sorting = " order by Adet " + Session["SortAdet"].ToString();
        }
        if (e.SortExpression.IndexOf("Ciro") > -1)
        {
            if (Session["SortCiro"] == null)
                Session["SortCiro"] = "DESC";
            else
            {
                if (Session["SortCiro"].ToString() == "DESC")
                    Session["SortCiro"] = "ASC";
                else
                    Session["SortCiro"] = "DESC";
            }
            Sorting = " order by Ciro " + Session["SortCiro"].ToString();
        }
        try
        {
            if (serverip == "")
            {
                System.IO.StreamReader Txt = new System.IO.StreamReader(Server.MapPath("server.txt"));
                serverip = Txt.ReadLine();
                database = Txt.ReadLine();
                DepoTipleri = Txt.ReadLine();
                StokUzunlugu = Convert.ToInt32(Txt.ReadLine());
                Txt.Close();


                Txt = null;
            }
            SqlConnection db = new SqlConnection("Application Name=WebCiroSorgulama;Data Source=" + serverip + ";initial catalog=" + database + ";user id=" + Request.Cookies["txtUser"].Value + ";Password=" + Request.Cookies["txtPass"].Value + ";");
            db.Open();
            string SqlConnect = "select " + (StokUzunlugu == 0 ? "sAciklama" : "sAciklama=Substring(sAciklama, 1, " + StokUzunlugu.ToString() + ")") + " , Adet, Ciro from (select sAciklama=ltrim(rtrim(substring(tbDepo.sAciklama,charindex('/', tbDepo.sAciklama)+1,60))), sum(lToplamMiktar) as Adet, Sum(lNetTutar) As [Ciro] from tbAlisVeris, \n";
            SqlConnect += " tbDepo  where  sFisTipi  not in ('CP','KA','PC','PP') And  tbDepo.sDepo=tbAlisVeris.sMagaza And " + (DepoTipleri == "" ? "1=1" : "tbDepo.sDepoTipi in(" + DepoTipleri + ")") + "  \n";
            if (dteTarih.Text != "")
                SqlConnect += "And dteFaturaTarihi='" + dteTarih.Text + "' \n";
            else
                SqlConnect += "And dteFaturaTarihi=cast(convert(char(10), getDate(), 103) as smalldatetime) \n";
            SqlConnect += "group by tbDepo.sAciklama) as tbTemp " + Sorting + " compute sum(Adet), sum(Ciro)\n";
            DataSet dt = new DataSet();
            SqlDataAdapter rs = new SqlDataAdapter(SqlConnect, db);
            rs.SelectCommand.CommandTimeout = 0;
            rs.Fill(dt);
            if (dt.Tables[1].Rows[0][0] == DBNull.Value)
            {
                Session["cMiktar"] = 0;
                Session["cTutar"] = 0;


            }
            else
            {
                Session["cMiktar"] = dt.Tables[1].Rows[0][0];
                Session["cTutar"] = dt.Tables[1].Rows[0][1];


            }
            grdMain.CurrentPageIndex = 0;
            grdMain.DataSource = dt.Tables[0];
            grdMain.DataBind();
            db.Close();
            db = null;
        }
        catch (Exception ex)
        {
            pnlVeri.Visible = false;
            pnlLogin.Visible = false;
            Response.Write(ex.Message + "<br><a href='WebForm.aspx'>Giris Sayfasi</a>");
        }


       
       
       


    }
   
    protected void Login_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtUserName.Text != "" && txtPassword.Text != "")
            {
                if (serverip == "")
                {
                    System.IO.StreamReader Txt = new System.IO.StreamReader(Server.MapPath("server.txt"));
                    serverip = Txt.ReadLine();
                    database = Txt.ReadLine();
                    DepoTipleri = Txt.ReadLine();
                    StokUzunlugu = Convert.ToInt32(Txt.ReadLine());
                    Txt.Close();
                   
                    Txt = null;
                }
                SqlConnection db = new SqlConnection("Application Name=WebCiroSorgulama;Data Source=" + serverip + ";initial catalog=" + database + ";user id=" + txtUserName.Text + ";Password=" + txtPassword.Text + ";");
                db.Open();
                Response.Cookies["txtUser"].Value = txtUserName.Text;
                Response.Cookies["txtPass"].Value = txtPassword.Text;
                Response.Cookies["txtUser"].Expires = DateTime.Now.AddYears(100);
                Response.Cookies["txtPass"].Expires = DateTime.Now.AddYears(100);


                string SqlConnect = "select " + (StokUzunlugu == 0 ? "sAciklama" : "sAciklama=Substring(sAciklama, 1, " + StokUzunlugu.ToString() + ")") + " , Adet, Ciro from (select sAciklama=ltrim(rtrim(substring(tbDepo.sAciklama,charindex('/', tbDepo.sAciklama)+1,60))), sum(lToplamMiktar) as Adet, Sum(lNetTutar) As [Ciro] from tbAlisVeris, \n";
                SqlConnect += "tbDepo  where  sFisTipi not in ('CP','KA','PC','PP') And tbDepo.sDepo=tbAlisVeris.sMagaza And " + (DepoTipleri == "" ? "1=1" : "tbDepo.sDepoTipi in(" + DepoTipleri + ")") + " \n";
                if (dteTarih.Text != "")
                    SqlConnect += "And dteFaturaTarihi='" + dteTarih.Text + "' \n";
                else
                    SqlConnect += "And dteFaturaTarihi=cast(convert(char(10), getDate(), 103) as smalldatetime) \n";
                SqlConnect += "group by tbDepo.sAciklama) as tbTemp order by sAciklama compute sum(Adet), sum(Ciro) \n";
              DataSet dt = new DataSet();
                SqlDataAdapter rs = new SqlDataAdapter(SqlConnect, db);
                rs.SelectCommand.CommandTimeout = 0;
                rs.Fill(dt);
                if (dt.Tables[1].Rows[0][0] == DBNull.Value)
                {
                    Session["cMiktar"] = 0;
                    Session["cTutar"] = 0;
            
                }
                else
                {
                    Session["cMiktar"] = dt.Tables[1].Rows[0][0];
                    Session["cTutar"] = dt.Tables[1].Rows[0][1];
     
                }
                grdMain.CurrentPageIndex = 0;
                grdMain.DataSource = dt.Tables[0];
                grdMain.DataBind();
                db.Close();
                db = null;
            }
        }
        catch(Exception ex) {
            pnlVeri.Visible = false;
            pnlLogin.Visible = false;
            Response.Write(ex.Message + "<br><a href='WebForm.aspx'>Giris Sayfasi</a>");
        }


    }


 


</script>



<html xmlns=" http://www.w3.org/1999/xhtml " >
<head runat="server">
<style type="text/css">
<!--
body,input{
.font-size:9px;
}
//-->
</style>
    <title>Magaza Satislar</title>
</head>
<body>
    <form id="form1" runat="server">
    <input type="hidden" name="cookUser" value="<%=Request.Cookies["txtUser"].Value%>" />
    <input type="hidden" name="cookPassword" value="<%=Request.Cookies["txtPass"].Value%>" />
    <div>
    <asp:Panel runat="server" ID="pnlLogin" Visible="true">
    <table width="100%" cellpadding="2" cellspacing="0" id="tbTest">
    <tr>
    <td>Kullanici Adi</td>
    </tr>
    <tr>
    <td>
    <asp:TextBox ID="txtUserName" runat="server" ReadOnly="true" Text="WebCiro"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td>Sifre</td>
    </tr>
    <tr>
    <td>
    <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td>Tarih</td>
    </tr>
    <tr>
    <td>
    <asp:TextBox ID="dteTarih" runat="server"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td colspan="2" align="left">
    <asp:Button id="btkTamam" runat="server" Text="Giris" OnClick="Login_Click" />
    </td>
    </tr>
    </table>
    </asp:Panel>
    <asp:Panel runat="server" ID="pnlVeri" Visible="false">
    <asp:DataGrid AllowSorting="true" ID="grdMain" runat="server" OnSortCommand="SortChanged" AutoGenerateColumns="False" PageSize="8" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal" CellSpacing="1" ShowFooter="True">
        <PagerStyle Mode="NumericPages" BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <ItemStyle
            VerticalAlign="Top" BackColor="#E7E7FF" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" ForeColor="#4A3C8C" />
        <Columns>
            <asp:TemplateColumn HeaderText="Mağaza" SortExpression="sAciklama">
                <EditItemTemplate>
                    <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.sAciklama") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.sAciklama") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                <b>Toplam</b>
                </FooterTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Adet" SortExpression="Adet">
                <EditItemTemplate>
                    <asp:TextBox runat="server" Text='<%# Convert.ToDouble(DataBinder.Eval(Container, "DataItem.Adet")).ToString("N0") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label runat="server" Text='<%# Convert.ToDouble(DataBinder.Eval(Container, "DataItem.Adet")).ToString("N0") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                 <b><%
                        if (Session["cMiktar"] != null)
                        {
                            Response.Write(Convert.ToDouble(Session["cMiktar"]).ToString("N0"));
                        }
                           
                             %></b>
                </FooterTemplate>
                <FooterStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                    Font-Underline="False" HorizontalAlign="Right" />
                <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                    Font-Underline="False" HorizontalAlign="Right" />
                <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                    Font-Underline="False" HorizontalAlign="Right" />
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Ciro" SortExpression="Ciro">
                <EditItemTemplate>
                    <asp:TextBox runat="server" Text='<%# Convert.ToDouble(DataBinder.Eval(Container, "DataItem.Ciro")).ToString("N2") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label runat="server" Text='<%# Convert.ToDouble(DataBinder.Eval(Container, "DataItem.Ciro")).ToString("N2") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                 <b><%
                        if (Session["cTutar"] != null)
                        {
                            Response.Write(Convert.ToDouble(Session["cTutar"]).ToString("N2"));
                        }
                           
                             %></b>
                </FooterTemplate>
                <FooterStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                    Font-Underline="False" HorizontalAlign="Right" />
                <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                    Font-Underline="False" HorizontalAlign="Right" />
                <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                    Font-Underline="False" HorizontalAlign="Right" />
            </asp:TemplateColumn>
  


        </Columns>
        <FooterStyle BackColor="#B5C7DE" Font-Bold="False" Font-Italic="False" Font-Overline="False"
            Font-Strikeout="False" Font-Underline="False" ForeColor="#4A3C8C" />
        <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingItemStyle BackColor="#F7F7F7" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
    </asp:DataGrid>
    <br />
    <asp:Button ID="btnYenile" runat="server" Text="Yenile" OnClick="SetYenile" />
    </asp:Panel>
    </div>
    </form>
</body>
</html>

 
Gönderildi : 29/03/2010 20:09
Paylaş: