public static List <LinkMan> GetAllLinkMan() { List <LinkMan> link = new List <LinkMan>(); string strsql = "select * from users"; DataTable dt = DBHelper.GetTable(strsql); LinkMan lm; for (int i = 0; i < dt.Rows.Count; i++) { lm = new LinkMan(); lm.Name = dt.Rows[i][0].ToString(); lm.Type = Convert.ToInt32(dt.Rows[i][1]); lm.Tel = dt.Rows[i][2].ToString(); lm.Email = dt.Rows[i][3].ToString(); lm.Address = dt.Rows[i][4].ToString(); link.Add(lm); } return(link); }
private void btnSave_Click(object sender, EventArgs e) { LinkMan lm = new LinkMan(); lm.Name = txtName.Text.Trim(); lm.Tel = txtTel.Text.Trim(); lm.Email = txtEmail.Text.Trim(); lm.Address = txtAddress.Text.Trim(); int cnt = LinkManop.InsertLinkMan(lm); if (cnt > 0) { MessageBox.Show("提示", "保存成功!", MessageBoxButtons.YesNo, MessageBoxIcon.Information); } else { Console.WriteLine("保存失败!"); } }
public static int InsertLinkMan(LinkMan LM) { string strsql = "insert into Friends values('" + LM.Name + "','" + LM.Type + "','" + LM.Tel + "','" + LM.Email + "','" + LM.Address + "')"; return(DBHelper.ExecuteCommand(strsql)); }