Пример #1
0
        /// <summary>
        ///  绑定Users信息的数据源
        /// </summary>
        private void BindSource(int start, string goodId, int yearmonth)
        {
            Purchase purchase = new Purchase();

            purchase.Good_Id    = goodId;
            purchase.Year_Month = yearmonth;

            PurchaseProvider provider = new PurchaseProvider();
            DataTable        table    = provider.Select(purchase, start, this.ListPager1.PageSize);

            this.GridView1.DataSource = table.DefaultView;
            this.GridView1.DataBind();
        }
Пример #2
0
        private void BindText()
        {
            Purchase purchase = new Purchase();

            purchase.Purchase_Id = Convert.ToInt32(id);
            PurchaseProvider provider = new PurchaseProvider();
            DataTable        table    = new DataTable();

            table = provider.Select(purchase);

            this.ddl_GoodId.SelectedIndex     = this.ddl_GoodId.Items.IndexOf(this.ddl_GoodId.Items.FindByValue(table.Rows[0]["good_id"].ToString()));
            this.txt_price.Text               = table.Rows[0]["purchase_price"].ToString();
            this.txt_num.Text                 = table.Rows[0]["purchase_num"].ToString();
            this.txt_datetime.Text            = table.Rows[0]["purchase_datetime"].ToString();//DateTime.Now.ToString();//table.Rows[0]["purchase_datetime"].ToString();
            this.ddl_supplierid.SelectedIndex = this.ddl_supplierid.Items.IndexOf(this.ddl_supplierid.Items.FindByValue(table.Rows[0]["supplier_id"].ToString()));
            this.txt_goodname.Text            = table.Rows[0]["good_name"].ToString();
        }
Пример #3
0
        protected void btn_Export_Click(object sender, EventArgs e)
        {
            System.Web.UI.WebControls.GridView dg = new System.Web.UI.WebControls.GridView();

            /*
             *          BoundField field1 = new BoundField();
             *          field1.DataField = "sale_id";
             *          field1.HeaderText = "销售单号";
             *          dg.Columns.Add(field1);
             *
             *          BoundField field2 = new BoundField();
             *          field2.DataField = "good_id";
             *          field2.HeaderText = "商品编号";
             *          dg.Columns.Add(field2);
             *
             *          BoundField field3 = new BoundField();
             *          field3.DataField = "sale_price";
             *          field3.HeaderText = "销售单价";
             *          dg.Columns.Add(field3);
             *
             *          BoundField field4 = new BoundField();
             *          field4.DataField = "purchase_price";
             *          field4.HeaderText = "采购单价";
             *          dg.Columns.Add(field4);
             *
             *          BoundField field5 = new BoundField();
             *          field5.DataField = "purchase_total";
             *          field5.HeaderText = "成本总价";
             *          dg.Columns.Add(field5);
             *
             *          BoundField field6 = new BoundField();
             *          field6.DataField = "sale_num";
             *          field6.HeaderText = "销售数量";
             *          dg.Columns.Add(field6);
             *
             *
             *          BoundField field7 = new BoundField();
             *          field7.DataField = "sale_total";
             *          field7.HeaderText = "销售总价";
             *          dg.Columns.Add(field7);
             *
             *          BoundField field8 = new BoundField();
             *          field8.DataField = "sale_profit";
             *          field8.HeaderText = "利润";
             *          dg.Columns.Add(field8);
             *
             *          BoundField field9 = new BoundField();
             *          field9.DataField = "sale_datetime";
             *          field9.HeaderText = "销售时间";
             *          dg.Columns.Add(field9);
             *
             *          BoundField field10 = new BoundField();
             *          field10.DataField = "buyer_bh";
             *          field10.HeaderText = "采购商编号";
             *          dg.Columns.Add(field10);
             */
            Purchase purchase = new Purchase();

            purchase.Good_Id    = "";
            purchase.Year_Month = 0;
            if (this.txt_Name.Text != "")
            {
                purchase.Good_Id = this.txt_Name.Text.ToString();
            }
            if (this.txt_Yearmonth.Text != "")
            {
                purchase.Year_Month = Convert.ToInt32(this.txt_Yearmonth.Text);
            }

            PurchaseProvider provider = new PurchaseProvider();
            DataTable        table    = provider.Select(purchase, 0, 0);

            dg.DataSource = table.DefaultView;
            dg.DataBind();

            Response.Clear();
            Response.Buffer      = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("content-disposition", "attachment;filename=PurchaseRecords.xls");
            Response.Charset     = "";
            this.EnableViewState = false;

            System.IO.StringWriter       sw  = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);

            dg.RenderControl(htw);

            Response.Write(sw.ToString());
            Response.End();
        }