/// <summary> /// 收件人信息增加 /// </summary> /// <param name="item"></param> /// <returns></returns> public int Add(Mail.Model.T_Base_Recipient item) { SqlConnection co = new SqlConnection(); co.ConnectionString = connstring; co.Open(); SqlCommand cm = new SqlCommand(); cm.Connection = co; cm.CommandText = "Insert into T_Base_Recipient(Id, phoneNum, Name, Job, Dept) values (@Id,@phoneNum,@Name,@Job,@Dept)"; cm.Parameters.AddWithValue("@Id", item.Id); cm.Parameters.AddWithValue("@phoneNum", item.PhoneNum); cm.Parameters.AddWithValue("@Name", item.Name); cm.Parameters.AddWithValue("@Job", item.Job); cm.Parameters.AddWithValue("@Dept", item.Dept); int result = cm.ExecuteNonQuery(); co.Close(); return(result); }
public int Update(Mail.Model.T_Base_Recipient item) { SqlConnection co = new SqlConnection(); co.ConnectionString = connstring; co.Open(); SqlCommand cm = new SqlCommand(); cm.Connection = co; cm.CommandText = "update T_Base_Recipient set Id=@Id,phoneNum=@phoneNum,Name=@Name,Job=@Job,Dept=@Dept where Id=@Id"; cm.Parameters.AddWithValue("@Id", item.Id); cm.Parameters.AddWithValue("@phoneNum", item.PhoneNum); cm.Parameters.AddWithValue("@Name", item.Name); cm.Parameters.AddWithValue("@Job", item.Job); cm.Parameters.AddWithValue("@Dept", item.Dept); cm.Parameters.AddWithValue("@Id", item.Id); int result = cm.ExecuteNonQuery(); co.Close(); return(result); }