示例#1
0
        public int InsertData(DataOrm dataOrm)
        {
            cmd.CommandText = $"insert into Employee values({dataOrm.DataID},'{dataOrm.DataInfo}',{dataOrm.DataKey})";
            cnn.Open();
            int affetcted = cmd.ExecuteNonQuery();

            cnn.Close();
            return(affetcted);
        }
示例#2
0
        public int UpdateData(DataOrm dataOrm)
        {
            cmd.CommandText = $"update Employee set EmpName='{dataOrm.DataInfo}',EmpDept={dataOrm.DataKey} where EmpID={dataOrm.DataID}";
            cnn.Open();
            int affetcted = cmd.ExecuteNonQuery();

            cnn.Close();
            return(affetcted);
        }
示例#3
0
        public DataOrm GetData(int id)
        {
            cmd.CommandText = $"select * from Employee where EmpID={id}";
            cnn.Open();
            DataOrm       orm    = null;
            SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

            if (reader.Read())
            {
                orm = new DataOrm {
                    DataID = (int)reader[0], DataInfo = reader[1].ToString(), DataKey = (int)reader[2]
                }
            }
            ;
            reader.Close();
            return(orm);
        }