示例#1
0
        public void CreateAdministrationSet(AdministrationSet adminSet)
        {
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"INSERT INTO dbo.Administration_Set_To_Patient (
                            PatientId, MiniDripFlag, MaxiDripFlag
                            ) VALUES (
                            @PatientId, @MiniDripFlag, @MaxiDripFlag
                            )";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = adminSet.PatientId;
                if (adminSet.MiniDripFlag == -1)
                    cmd.Parameters.Add("@MiniDripFlag", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MiniDripFlag", SqlDbType.Int).Value = adminSet.MiniDripFlag;

                if (adminSet.MaxiDripFlag == -1)
                    cmd.Parameters.Add("@MaxiDripFlag", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MaxiDripFlag", SqlDbType.Int).Value = adminSet.MaxiDripFlag;

                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
示例#2
0
        public int UpdateAdministrationSet(AdministrationSet adminSet)
        {
            int returnNum = 0;
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"UPDATE dbo.Administration_Set_To_Patient SET
                            MiniDripFlag = @MiniDripFlag, MaxiDripFlag = @MaxiDripFlag
                            WHERE
                            PatientId = @PatientId";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = adminSet.PatientId;
                if (adminSet.MiniDripFlag == -1)
                    cmd.Parameters.Add("@MiniDripFlag", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MiniDripFlag", SqlDbType.Int).Value = adminSet.MiniDripFlag;

                if (adminSet.MaxiDripFlag == -1)
                    cmd.Parameters.Add("@MaxiDripFlag", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MaxiDripFlag", SqlDbType.Int).Value = adminSet.MaxiDripFlag;
                try
                {
                    conn.Open();
                    returnNum = cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return returnNum;
        }