public List<CompositeType> DoWork() { comm_sqlDataContext mylinq = new comm_sqlDataContext(); ISingleResult<adrbook> bb = mylinq.getdata(); var peoples = new List<CompositeType> (); foreach (adrbook cast in bb) { CompositeType p = new CompositeType(); p.Lid= cast.id; p.Ltype = cast.type; p.Lsubtype = cast.subtype; p.Llastname = cast.lastname; p.Lfirstname = cast.firstname; p.Lmiddlename = cast.middlename; p.Lpost = cast.post; p.Lemail1 = cast.email1; p.Lemail2 = cast.email2; p.Lroom = cast.room; p.Lphone1 = cast.phone1; p.Lphone2 = cast.phone2; p.Lphone3 = cast.phone3; peoples.Add(p); } return peoples; }
protected void GvDeleting(object sender, GridViewDeleteEventArgs e) { int id; if (int.TryParse(string.Format("{0}", e.Keys["p_Id"]), out id)) { Peoples = Peoples.Where(x => x.p_Id != id).ToList(); comm_sqlDataContext mylinq = new comm_sqlDataContext(); int bb = mylinq.deleterow(id); UpdateGrid(); } }
protected void searchpeople(object sender, EventArgs e) { comm_sqlDataContext mylinq = new comm_sqlDataContext(); var s = search_textbox.Text; ISingleResult<getlikeResult> bb = mylinq.getlike(s); hfPeoplesViewState.Value = ""; var str = hfPeoplesViewState.Value; if (string.IsNullOrEmpty(str)) { hfPeoplesViewState.Value = string.Format("Peoples_{0}", Guid.NewGuid()); str = hfPeoplesViewState.Value; } if (ViewState[str] == null || !(ViewState[str] is List<People>)) { var peoples = new List<People> { }; foreach (getlikeResult cast in bb) { var pp = new People {p_Id = cast.id, p_type = cast.type, p_subtype = cast.subtype, p_lastname = cast.lastname, p_firstname = cast.firstname, p_middlename = cast.middlename, p_post = cast.post, p_email1 = cast.email1, p_email2 = cast.email2, p_room = cast.room, p_phone1 = cast.phone1, p_phone2 = cast.phone2, p_phone3 = cast.phone3}; peoples.Add(pp); } ViewState[str] = peoples; } gv.DataSource = ViewState[str]; gv.DataBind(); search_textbox.Text = ""; Button3.Style.Add("display", ""); }
protected void BtAddPeople(object sender, EventArgs e) { hfPeoplesViewState.Value = ""; UpdateGrid(); if (!string.IsNullOrEmpty(tbltype.Text) && !string.IsNullOrEmpty(tblsubtype.Text) && !string.IsNullOrEmpty(tbllastname.Text) && !string.IsNullOrEmpty(tblfirstname.Text) && !string.IsNullOrEmpty(tblmiddlename.Text) && !string.IsNullOrEmpty(tblpost.Text) && !string.IsNullOrEmpty(tblemail1.Text) && !string.IsNullOrEmpty(tblemail2.Text) && !string.IsNullOrEmpty(tblroom.Text) && !string.IsNullOrEmpty(tblphone1.Text) && !string.IsNullOrEmpty(tblphone2.Text) && !string.IsNullOrEmpty(tblphone3.Text)) { var id = Peoples.Count > 0 ? Peoples.Max(x => x.p_Id) + 1 : 1; var p = new People { p_Id = id, p_type = tbltype.Text, p_subtype = tblsubtype.Text, p_lastname = tbllastname.Text, p_firstname = tblfirstname.Text, p_middlename = tblmiddlename.Text, p_post = tblpost.Text, p_email1 = tblemail1.Text, p_email2 = tblemail2.Text, p_room = tblroom.Text, p_phone1 = tblphone1.Text, p_phone2 = tblphone2.Text, p_phone3 = tblphone3.Text }; Peoples.Add(p); comm_sqlDataContext mylinq = new comm_sqlDataContext(); int bb = mylinq.addrow(tbltype.Text, tblsubtype.Text, tbllastname.Text, tblfirstname.Text, tblmiddlename.Text, tblpost.Text, tblemail1.Text, tblemail2.Text, tblroom.Text, tblphone1.Text, tblphone2.Text, tblphone3.Text); UpdateGrid(); Button3.Style.Add("display", "none"); } }
protected void GvUpdating(object sender, GridViewUpdateEventArgs e) { int id; if (int.TryParse(string.Format("{0}", e.Keys["p_Id"]), out id)) { comm_sqlDataContext mylinq = new comm_sqlDataContext(); Peoples .Where(x => x.p_Id == id) .ToList() .ForEach(x => { x.p_type = string.Format("{0}", e.NewValues["p_type"]); x.p_subtype = string.Format("{0}", e.NewValues["p_subtype"]); x.p_lastname = string.Format("{0}", e.NewValues["p_lastname"]); x.p_firstname = string.Format("{0}", e.NewValues["p_firstname"]); x.p_middlename = string.Format("{0}", e.NewValues["p_middlename"]); x.p_post = string.Format("{0}", e.NewValues["p_post"]); x.p_email1 = string.Format("{0}", e.NewValues["p_email1"]); x.p_email2 = string.Format("{0}", e.NewValues["p_email2"]); x.p_room = string.Format("{0}", e.NewValues["p_room"]); x.p_phone1 = string.Format("{0}", e.NewValues["p_phone1"]); x.p_phone2 = string.Format("{0}", e.NewValues["p_phone2"]); x.p_phone3 = string.Format("{0}", e.NewValues["p_phone3"]); int bb = mylinq.updaterow(x.p_type, x.p_subtype, x.p_lastname, x.p_firstname, x.p_middlename, x.p_post, x.p_email1, x.p_email2, x.p_room, x.p_phone1, x.p_phone2, x.p_phone3, id); }); gv.EditIndex = -1; UpdateGrid(); } }
protected void searchpeople(object sender, EventArgs e) { comm_sqlDataContext mylinq = new comm_sqlDataContext(); var s = search_textbox.Text; ISingleResult<getlikeResult> bb = mylinq.getlike(s); hfPeoplesViewState.Value = ""; var str = hfPeoplesViewState.Value; if (string.IsNullOrEmpty(str)) { hfPeoplesViewState.Value = string.Format("Peoples_{0}", Guid.NewGuid()); str = hfPeoplesViewState.Value; } if (ViewState[str] == null || !(ViewState[str] is List<People>)) { var peoples = new List<People> { }; foreach (getlikeResult cast in bb) { var pp = new People { p_Id = cast.id, p_type = cast.type, p_subtype = cast.subtype, p_lastname = cast.lastname, p_firstname = cast.firstname, p_middlename = cast.middlename, p_post = cast.post, p_email1 = cast.email1, p_email2 = cast.email2, p_room = cast.room, p_phone1 = cast.phone1, p_phone2 = cast.phone2, p_phone3 = cast.phone3 }; peoples.Add(pp); } ViewState[str] = peoples; } gv.DataSource = ViewState[str]; gv.DataBind(); if (search_textbox.Text.Equals("") == true) { Button3.Visible = false; } else { Button3.Visible = true; } search_textbox.Text = ""; Table1.Visible = false; Table2.Visible = false; c_edit.Visible = false; c_ok.Visible = false; add.Visible = false; delete.Visible = false; mylinq.Connection.Close(); }
protected void okedit(object sender, EventArgs e) { People ff = Peoples[Convert.ToInt32(e_id.Value)]; Table1.Rows[0].Cells[0].Text = add_lastname.Text + " " + add_firstname.Text + " " + add_middlename.Text; Table1.Rows[1].Cells[0].Text = add_type.Text; Table1.Rows[2].Cells[0].Text = add_subtype.Text; Table1.Rows[2].Cells[1].Text = add_room.Text; Table1.Rows[3].Cells[0].Text = add_post.Text; Table1.Rows[4].Cells[1].Text = add_phone1.Text; Table1.Rows[5].Cells[1].Text = add_email1.Text; Table1.Rows[6].Cells[1].Text = add_phone2.Text; Table1.Rows[7].Cells[1].Text = add_phone3.Text; Table1.Rows[8].Cells[1].Text = add_email2.Text; int id; if (int.TryParse(string.Format("{0}", ff.p_Id), out id)) { comm_sqlDataContext mylinq = new comm_sqlDataContext(); Peoples .Where(x => x.p_Id == id) .ToList() .ForEach(x => { x.p_type = string.Format("{0}", add_type.Text); x.p_subtype = string.Format("{0}", add_subtype.Text); x.p_lastname = string.Format("{0}", add_lastname.Text); x.p_firstname = string.Format("{0}", add_firstname.Text); x.p_middlename = string.Format("{0}", add_middlename.Text); x.p_post = string.Format("{0}", add_post.Text); x.p_email1 = string.Format("{0}", add_email1.Text); x.p_email2 = string.Format("{0}", add_email2.Text); x.p_room = string.Format("{0}", add_room.Text); x.p_phone1 = string.Format("{0}", add_phone1.Text); x.p_phone2 = string.Format("{0}", add_phone2.Text); x.p_phone3 = string.Format("{0}", add_phone3.Text); int bb = mylinq.updaterow(x.p_type, x.p_subtype, x.p_lastname, x.p_firstname, x.p_middlename, x.p_post, x.p_email1, x.p_email2, x.p_room, x.p_phone1, x.p_phone2, x.p_phone3, id); }); gv.EditIndex = -1; UpdateGrid(); mylinq.Connection.Close(); } c_edit.Visible = true; c_ok.Visible = false; add.Visible = false; Table1.Visible = true; Table2.Visible = false; delete.Visible = true; }
protected void goDelPeople(object sender, EventArgs e) { int id; People ff = Peoples[Convert.ToInt32(e_id.Value)]; if (int.TryParse(string.Format("{0}", ff.p_Id), out id)) { Peoples = Peoples.Where(x => x.p_Id != id).ToList(); comm_sqlDataContext mylinq = new comm_sqlDataContext(); int bb = mylinq.deleterow(id); UpdateGrid(); mylinq.Connection.Close(); } c_edit.Visible = false; c_ok.Visible = false; add.Visible = false; Table1.Visible = false; Table2.Visible = false; delete.Visible = false; }
protected void goAddPeople(object sender, EventArgs e) { hfPeoplesViewState.Value = ""; UpdateGrid(); if (!string.IsNullOrEmpty(add_type.Text) || !string.IsNullOrEmpty(add_subtype.Text) || !string.IsNullOrEmpty(add_lastname.Text) || !string.IsNullOrEmpty(add_firstname.Text) || !string.IsNullOrEmpty(add_middlename.Text) || !string.IsNullOrEmpty(add_post.Text) || !string.IsNullOrEmpty(add_email1.Text) || !string.IsNullOrEmpty(add_email2.Text) || !string.IsNullOrEmpty(add_room.Text) || !string.IsNullOrEmpty(add_phone1.Text) || !string.IsNullOrEmpty(add_phone2.Text) || !string.IsNullOrEmpty(add_phone3.Text)) { var id = Peoples.Count > 0 ? Peoples.Max(x => x.p_Id) + 1 : 1; var p = new People { p_Id = id, p_type = add_type.Text, p_subtype = add_subtype.Text, p_lastname = add_lastname.Text, p_firstname = add_firstname.Text, p_middlename = add_middlename.Text, p_post = add_post.Text, p_email1 = add_email1.Text, p_email2 = add_email2.Text, p_room = add_room.Text, p_phone1 = add_phone1.Text, p_phone2 = add_phone2.Text, p_phone3 = add_phone3.Text }; Peoples.Add(p); comm_sqlDataContext mylinq = new comm_sqlDataContext(); int bb = mylinq.addrow(add_type.Text, add_subtype.Text, add_lastname.Text, add_firstname.Text, add_middlename.Text, add_post.Text, add_email1.Text, add_email2.Text, add_room.Text, add_phone1.Text, add_phone2.Text, add_phone3.Text); UpdateGrid(); mylinq.Connection.Close(); Button3.Visible = false; Table1.Visible = false; Table2.Visible = false; c_edit.Visible = false; c_ok.Visible = false; add.Visible = false; delete.Visible = false; } }