Ejemplo n.º 1
0
    // <Snippet1>
    protected void Add_Click(object sender, EventArgs e)
    {
        System.Collections.Specialized.ListDictionary listDictionary
            = new System.Collections.Specialized.ListDictionary();
        listDictionary.Add("ProductName", TextBox1.Text);
        listDictionary.Add("ProductCategory", "General");
        listDictionary.Add("Color", "Not assigned");
        listDictionary.Add("ListPrice", null);
        LinqDataSource1.Insert(listDictionary);

        TextBox1.Text = String.Empty;
        DetailsView1.DataBind();
    }
Ejemplo n.º 2
0
    protected void submit_Click(object sender, EventArgs e)
    {
        ListDictionary customerRow = new ListDictionary();

        customerRow.Add("ContactName", firstname.Text + " " + lastname.Text);
        customerRow.Add("CustomerID", (firstname.Text.Substring(0, 3) + lastname.Text.Substring(0, 2)));
        customerRow.Add("CompanyName", company_name.Text);
        customerRow.Add("Phone", phone.Text);
        LinqDataSource1.Insert(customerRow);
        GridView1.DataBind();
        form1.Visible = false;
        form2.Visible = true;
        Label1.Text   = firstname.Text.Substring(0, 3) + lastname.Text.Substring(0, 2);
    }
Ejemplo n.º 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        ListDictionary insertParameters = new ListDictionary();

        TextBox      name   = FormView1.FindControl("nameBox") as TextBox;
        TextBox      author = FormView1.FindControl("authorBox") as TextBox;
        DropDownList type   = FormView1.FindControl("DropDownMovieList") as DropDownList;

        //check if data exists already

        bool exists = false;

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            String valueName = GridView1.Rows[i].Cells[1].Text.ToString();
            if ((valueName.Equals(name.Text)))
            {
                //record exists
                exists = true;
                //ShowPopUpMsg("Name already exists in the database. Please check details in 'name' field");

                break;
            }
            else
            {
                exists = false;
                //record not exists
            }
        }
        //insert if valid
        if (exists == false)
        {
            insertParameters.Add("Name", name.Text);
            insertParameters.Add("AuthorName", author.Text);
            insertParameters.Add("Type", type.SelectedItem.Text);
            insertParameters.Add("DateAdded", DateTime.Now.ToShortDateString());

            LinqDataSource1.Insert(insertParameters);

            GridView1.DataBind();
            insertParameters.Clear();
            messagePanel.Visible = true;
            messagePanel.Dispose();
        }
        else if (exists == true)
        {
            PanelWarning.Visible = true;
            PanelWarning.Dispose();
        }
    }
Ejemplo n.º 4
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Insert")
            {
                var tb = (TextBox)GridView1.FooterRow.FindControl("tbInsertName");


                LinqDataSource1.Insert(new Dictionary <string, string>()
                {
                    { "Name", tb.Text }
                });
                tb.Text = "";
                GridView1.DataBind();
            }
        }
Ejemplo n.º 5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            TextBox TextBox1 = (TextBox)GridView1.FooterRow.FindControl("TextBox1");
            TextBox TextBox2 = (TextBox)GridView1.FooterRow.FindControl("TextBox2");
            TextBox TextBox3 = (TextBox)GridView1.FooterRow.FindControl("TextBox3");

            System.Collections.Specialized.ListDictionary listDictionary = new System.Collections.Specialized.ListDictionary();
            listDictionary.Add("c_code", TextBox1.Text);
            listDictionary.Add("c_name", TextBox2.Text);
            listDictionary.Add("c_credit", TextBox3.Text);
            LinqDataSource1.Insert(listDictionary);

            TextBox1.Text = String.Empty;
            TextBox2.Text = String.Empty;
            TextBox3.Text = String.Empty;
            GridView1.DataBind();
        }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int orderidd = 0;

        if (!IsPostBack)
        {
            foreach (var v in database.Orders)
            {
                if (v.OrderID > orderidd)
                {
                    orderidd = v.OrderID;
                }
            }
            DateTime now = new DateTime();
            now = DateTime.Now.Date;
            ListDictionary NWorderRow = new ListDictionary();
            NWorderRow.Add("CustomerID", (string)Session["UserID"]);
            NWorderRow.Add("OrderDate", now);
            NWorderRow.Add("OrderID", orderidd + 1);
            LinqDataSource1.Insert(NWorderRow);
            GridView1.DataBind();
            getData(orderidd + 1);
        }
    }