Beispiel #1
0
        public DataTable getNam()
        {
            DataTable dt = new DataTable();

            cmd.CommandText = "SELECT year(ngayban) as ngayban from HOADONBAN group by year(ngayban)";
            //cmd = new SqlCommand(cmd.CommandText, con.Connection);
            //SqlDataAdapter da = new SqlDataAdapter(cmd);
            //da.Fill(dt);
            //da.Dispose();
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(dt);
                con.CloseConn();
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
                cmd.Dispose();
                con.CloseConn();
            }
            return(dt);
        }
        private void BindData()
        {
            cmd.CommandText = "select * from Master.Customers";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn.Connection;
            conn.OpenConn();
            sda = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();

            sda.Fill(dt);
            dvitem             = dt.DefaultView;
            grvitem.DataSource = dvitem;
            grvitem.DataBind();
            Session["TaskTable"] = dt;
        }
        private void BindData()
        {
            cmd.CommandText = "SELECT * FROM [order].[Order]";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn.Connection;
            conn.OpenConn();
            sda = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();

            sda.Fill(dt);
            dvitem             = dt.DefaultView;
            grvitem.DataSource = dvitem;
            grvitem.DataBind();
            Session["TaskTable"] = dt;
        }
Beispiel #4
0
        public void tdl()
        {
            int x = 1;

            string[] a = new string[99];

            cmd.CommandText = "select orderdate from [order].[Order] where orderid = " + Session["idorder"];
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn.Connection;
            conn.OpenConn();
            sda = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();

            sda.Fill(dt);
            Label2.Text = "time: " + dt.Rows[0][0].ToString();
            Label1.Text = "orderid: " + Session["idorder"];

            cmd.CommandText = "SELECT [ItemId],[Price],[Quantity],[Discount],[Total]FROM [order].[OrderDetails] where orderid =" + Session["idorder"];
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn.Connection;
            conn.OpenConn();
            sda = new SqlDataAdapter(cmd);
            DataTable dt2 = new DataTable();

            sda.Fill(dt2);

            foreach (DataRow row in dt2.Rows)
            {
                cmd.CommandText = "SELECT [ItemName]FROM [Master].[Item] where itemid =" + row[0].ToString();
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = conn.Connection;
                conn.OpenConn();
                sda = new SqlDataAdapter(cmd);
                DataTable dt3 = new DataTable();
                sda.Fill(dt3);
                tenmon = dt3.Rows[0][0].ToString();

                a[x] = "id iteam= " + row[0].ToString() + " name item= " + tenmon + " price= " + row[1].ToString() + " quantyti= " + row[2].ToString() + " dicount= " + row[3].ToString() + " total= " + row[4].ToString() + "\n";
                x++;
            }
            string message = String.Join(" ", a);

            TextBox1.Text = message;
        }
Beispiel #5
0
        public bool GetID(string name, string pw)  //lấy tên đăng nhập
        {
            DataTable dt = new DataTable();

            cmd.CommandText = "select UN from loginn where UN = '" + name + "' and PW = '" + pw + "'";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn.Connection;
            try
            {
                conn.OpenConn();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
            }
            return(false);
        }
Beispiel #6
0
        public void tdl()
        {
            int[]    z = new int[99];
            int[]    x = new int[99];
            int[]    y = new int[99];
            string[] a = new string[99];
            int      t = 1;

            cmd.CommandText = "select itemid from [Master].[Item]";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn.Connection;
            conn.OpenConn();
            sda = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();

            sda.Fill(dt);
            foreach (DataRow row in dt.Rows)
            {
                z[t] = Convert.ToInt32(row[0]);
                t++;
            }

            for (int i = 1; i <= t; i++)
            {
                cmd.CommandText = "SELECT [Quantity],[Total]FROM [order].[OrderDetails] where ItemId= " + z[i].ToString();
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = conn.Connection;
                conn.OpenConn();
                sda = new SqlDataAdapter(cmd);
                DataTable dt2 = new DataTable();
                sda.Fill(dt2);
                x[z[i]] = 0;
                y[z[i]] = 0;
                foreach (DataRow row in dt2.Rows)
                {
                    int p = Convert.ToInt32(row[0]);
                    int q = Convert.ToInt32(row[1]);
                    x[z[i]] = x[z[i]] + p;
                    y[z[i]] = y[z[i]] + q;
                }
            }

            for (int i = 1; i < t; i++)
            {
                for (int j = i + 1; j <= t; j++)
                {
                    if (x[z[i]] < x[z[j]])
                    {
                        int c;
                        c    = z[i];
                        z[i] = z[j];
                        z[j] = c;
                    }
                }
            }

            for (int i = 1; i <= t; i++)
            {
                cmd.CommandText = "select itemname, ItemPirce from [Master].[Item] where itemid=" + z[i].ToString();
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = conn.Connection;
                conn.OpenConn();
                sda = new SqlDataAdapter(cmd);
                DataTable dt3 = new DataTable();
                sda.Fill(dt3);
                foreach (DataRow row in dt3.Rows)
                {
                    a[i] = "itemID= " + z[i].ToString() + " ItemName= " + row[0].ToString() + " price= " + row[1].ToString() + " tổng số lượng bán ra= " + x[z[i]].ToString() + " tổng doanh thu= " + y[z[i]].ToString() + "\n";
                }
            }

            string message = String.Join(" ", a);

            TextBox1.Text = message;
        }