Пример #1
0
    public void Showdata()
    {
        string nameEn = "";
        string name   = "";
        //string detail = "";
        //string price = "";
        //string promotion = "";
        DataTable dt = new DataTable();

        dt.Columns.Add("IDProduct");
        dt.Columns.Add("Name");
        dt.Columns.Add("NameEN");
        CommonClassLibrary.CommonDataSet.TableDataTable collection = new CommonClassLibrary.CommonDataSetTableAdapters.TableTableAdapter().GetData();
        foreach (CommonClassLibrary.CommonDataSet.TableRow item in collection)
        {
            CommonClassLibrary.CommonDataSet.TextContentDataTable collection3 = new CommonClassLibrary.CommonDataSetTableAdapters.TextContentTableAdapter().GetDataById(long.Parse(item.Name));
            foreach (CommonClassLibrary.CommonDataSet.TextContentRow item3 in collection3)
            {
                name   = item3.Thai;
                nameEn = item3.English;
            }
            dt.Rows.Add(item.Id, name, nameEn);
        }


        this.CategoryTa.DataSource = dt;
        this.CategoryTa.DataBind();
    }
Пример #2
0
    protected void CategoryTa_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        Label idlabel = (Label)e.Item.FindControl("idLabel");

        this.aaa_TextBox.Text = idlabel.Text;
        if (e.CommandName == "EditBtn")
        {
            //this.getImage();
            CommonClassLibrary.CommonDataSet.TableDataTable collection = new CommonClassLibrary.CommonDataSetTableAdapters.TableTableAdapter().GetDataById(int.Parse(idlabel.Text));
            foreach (CommonClassLibrary.CommonDataSet.TableRow item in collection)
            {
                this.Labelidname.Text = item.Name;
            }
            this.EditPanel.Visible = true;
            this.AddPanel.Visible  = false;
            this.ShowPanel.Visible = false;
            CommonClassLibrary.CommonDataSet.TextContentDataTable collection1 = new CommonClassLibrary.CommonDataSetTableAdapters.TextContentTableAdapter().GetDataById(int.Parse(Labelidname.Text));
            foreach (CommonClassLibrary.CommonDataSet.TextContentRow item1 in collection1)
            {
                editName_TextBox.Text   = item1.Thai;
                editNameEN_TextBox.Text = item1.English;
            }

            this.EditPanel.Visible = true;
            this.AddPanel.Visible  = false;
            this.ShowPanel.Visible = false;
        }
        else if (e.CommandName == "DeleteBtn")
        {
            try
            {
                if (new CommonClassLibrary.CommonDataSetTableAdapters.TableTableAdapter().DeleteQuery(int.Parse(aaa_TextBox.Text)) == 1)
                {
                    this.SuccessPanel.Visible = true;
                    this.ErrorPanel.Visible   = false;
                    this.SuccessLabel.Text    = "ลบข้อมูลสำเร็จ";
                }
                else
                {
                    this.SuccessPanel.Visible = false;
                    this.ErrorPanel.Visible   = true;
                    this.ErrorLabel.Text      = "ลบข้อมูลไม่สำเร็จ";
                }
            }
            catch (Exception)
            {
            }

            this.Showdata();
        }
    }